Rs-232 interface methods, Rs232_open() – Echelon i.LON SmartServer 2.0 User Manual
Page 239

i.LON SmartServer 2.0 Programming Tools User’s Guide
225
extern "C" STATUS fnRebootSmartServer (int a_nBootFlag);
#endif
…
void CUFPTmath::Work()
{
printf("\nCUFPTmath::Work():
");
if (Changed( in1 ) || Changed( in2 ))
{
out3 = in1 + in2;
printf("out3 = %d = %d + %d", *out3, *in1, *in2 );
}
if (Changed(str))
{
printf("str = %s", (char*) str->ascii );
}
// REBOOT here
if(100 < *out3)
{
fnRebootSmartServer(0x00);
}
}
RS-232 Interface Methods
You can use RS-232 interface methods to connect an FPM driver to the devices attached to the RS-232
serial port on the SmartServer, initialize the RS-232 connection, read and write values to the data
points on the devices, and close the RS-232 connection . For more information on connecting a device
to the RS-232 serial port, see the i.LON SmartServer 2.0 Hardware Guide.
Note: The RS-232 interface transmit and receive buffers are both 512 bytes.
rs232_open()
You can use the rs232_open()method in the Initialize() routine to open the RS-232 interface
on the SmartServer.
SYNTAX
int rs232_open(unsigned int BaudRate);
The BaudRate parameter specifies the baud rate at which RS-232 interface communicates with
the serial port. The SmartServer’s RS-232 interface does not support handshakes; therefore, you
should select a baud rate that is less than or equal to 19,200. See the documentation for your RS-
232 interface for more information on baud rates supported for your device. When setting the baud
rate, you should consider the number of bytes the interface sends over the network per second, and
the calculations performed between poll cycles.
The method returns the file handle (a value greater than or equal to 0) on success, and it returns a
negative value on failure. A failure could occur if another FPM is using the interface, or if the
interface is not properly connected to the RS-232 port.
Verify that the file handle is specified in a global variable so that you can reference it from the
Work()
and Shutdown() routines.
EXAMPLE
The following example demonstrates a rs232_open()method that opens an RS-232 connection
with a baud rate of 9600.