beautypg.com

Rs485_setbuffersize(), Rs485_read() – Echelon i.LON SmartServer 2.0 User Manual

Page 245

background image

i.LON SmartServer 2.0 Programming Tools User’s Guide

231

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 are as follows:

cmd

parameter

data

parameter

IOCTL_BAUDRATE

Specify the baud rate at which the RS-485 interface will
communicate with the serial port on the i.LON.

IOCTL_RCVBUFSIZE

Specify the receive buffer size. For more information, see the
rs485_setbuffersize() section.

IOCTL_RCVTIMEOUT

Specify the timeout period (in seconds) after which the RS-485
interface stops trying to receive failed messages from the
network.

IOCTL_SNDTIMEOUT

Specify the timeout period (in seconds) after which the RS-485
interface stops trying to send a failed messages over the
network.

This method returns the 0 upon success, and it returns -1 upon failure. A failure could occur if
another FPM is using the interface, or if the interface is not properly connected to the RS-485 port.

EXAMPLE

The following example demonstrates a rs485_ioctl()method that sets the buffer size to be
used for the RS-485 connection to 256 bytes.

rs485_IOCTL(fd, IOCTL_RCVTIMEOUT, 256);

rs485_setbuffersize()

You can use the rs485_setbuffersize()method in the Initialize() routine to modify the
receive buffer size.

SYNTAX

int rs485_setbuffersize(int fd, unsigned int size);

The fd parameter specifies the file handle returned when the RS-485 interface was opened with
the rs485_open() method.

The size parameter specifies the new size of the receive buffer to be set. The initial size of the
receive buffer is set to 1024.

EXAMPLE

The following example demonstrates the rs485_setbuffersize()method.

rs485_setbuffersize(fd, 2048);

rs485_read()

You can use the rs485_read() method in the OnTimer() routine to read data from the RS-485
interface.

SYNTAX

int rs485_read(int fd, unsigned char * buf, int length);

The fd parameter specifies the file handle returned when the RS-485 interface was opened with
the rs485_open() method.

The buf parameter specifies a pointer to the memory area to where the data read from the RS-485
interface is to be stored. The memory area must have enough space to store the data or else the
SmartServer may fail as a result of a call to this method.