Rs232_ioctl() – Echelon i.LON SmartServer 2.0 User Manual
Page 240

226
Appendix A - Programmer’s Reference
int fd = rs232_open(9600);
rs232_ioctl()
You can use the rs232_ioctl() method in the Initialize() routine to initialize and send
commands to the RS-232 interface. You should call this method immediately after opening the RS-
232 interface with the rs232_open() method. Note that you can send commands to the RS-232
interface using other I/O control methods besides the rs232_ioctl() method.
SYNTAX
int rs232_ioctl(int fd, int cmd, int data);
The fd parameter specifies the file handle that was returned when the RS-232 interface was
opened with the rs232_open() method.
The cmd parameter specifies the command to be sent to the RS-232 interface. The data
parameter specifies the corresponding value to be used with the cmd parameter. The values for
the cmd and data parameters are defined in the FPMLibrary.h file in the
iLON/Development/eclipse/plugins/com.echelon.eclipse.ilon100.fpm_0.9.0/compiler/echelon/fpm
/include folder in your L
ON
W
ORKS
directory. The values you can specify for the cmd and data
parameters include the following:
cmd
parameter
data
parameter
IOCTL_BAUDRATE
Specifies the baud rate at which the RS-232 interface will
communicate with the serial port.
IOCTL_RCVBUFSZ
Specifies the receive buffer size.
IOCTL_SIO_HW_OPTS_GET
Gets the current configuration of the hardware options used by
the RS-232 interface.
Before using this function, you must call the following
function to avoid overriding the existing configuration
parameters:
int options = rs232_ioctl(fd,
IOCTL_SIO_HW_OPTS_GET, 0);
To set the character size, use the following function:
rs232_ioctl(fd, IOCTL_SIO_HW_OPTS_SET,
((options & ~CSIZE) | CS6));
To set odd parity, use the following function:
rs232_ioctl(fd, IOCTL_SIO_HW_OPTS_SET,
(options | PARENB | PARODD));
IOCTL_SIO_HW_OPTS_SET
Specify the hardware options for the RS-232 interface.
If the RS-232 interface supports hardware handshakes, enter
the following:
((options & ~CSIZE) | CS8| HUPCL | CREAD)
If the RS-232 interface does not support hardware handshakes,
enter the following:
((options & ~CSIZE) | CS8| HUPCL | CREAD |
CLOCAL)
See the FPMLibrary.h file for more information on the values
you can pass in as the data parameter when the cmd