For UNIX Users Chapter 4
29
4.5 Programming the MOXA Non-TTY Ports Using MOXA UNIX API-232
Even though C360 SuperPort system provides up to 1024 serial ports, maximum
of 256 ports can serve as standard UNIX TTY devices while the rest of the ports,
up to 768, can only be used as MOXA non-TTY devices.
To control MOXA non-TTY ports, MOXA proprietary functions in the MOXA
UNIX API-232 library should be used, which are listed below. Note that
UNIX system services, such as open( ), close( ), read( ), write( ), and ioctl( ),
can not be applied to MOXA non-TTY ports.
The MOXA UNIX API-232 functions are almost the same as those in MOXA
DOS API-232 library. Hence it is easier for porting applications from DOS
platform to UNIX one. One thing to notice is that all the MOXA non-TTY
ports can only be accessed in one UNIX application (process). In other word,
two or more applications accessing any MOXA non-TTY ports are not allowed.
Remember to include the header file, mxapi232.h, in the application program
and link with the library, mxapi232.o. User can use the example program
(example.c), header file (mxapi232.h), library (mxapi232.o) and makefile in the
directory, /usr/lib/moxa to shorten the learning curve.
Function List:
1. sio_open( ) Open a non-TTY port.
2. sio_close( ) Close a non-TTY port.
3. sio_read( ) Read data from a non-TTY port.
4. sio_write( ) Write a string of data to Rx buffer.
5. sio_putb( ) Put a block of data to Tx buffer.
6. sio_ioctl( ) Non-TTY port parameter setting.
7. sio_break( ) Send break signal.
8. sio_flush( ) Flush Tx/Rx buffer data.
9. sio_iqueue( ) Read the length of data queued in Rx buffer.
10. sio_oqueue( ) Read the length of data queued in Tx buffer.
11. sio_lstatus( ) Get modem line status.
12. sio_lctrl( ) Set modem line control.
13. sio_DTR( ) Set modem line control signal DTR.