Roserialport – BrightSign HD2000 Object Reference Manual User Manual
Page 31
roSerialPort
This object controls the RS232 serial port, allowing you to receive input and send responses.
roSerialPort has these interfaces:
1.
ifStream
2.
ifSerialControl
ifStream has these member functions:
rotVOID SendByte(rotINT32 byte)
rotVOID SendLine(rotSTRING line)
rotVOID SendBlock(rotSTRING block)
rotVOID SetEol(rotSTRING eol)
rotVOID SetLineEventPort(rotOBJECT port)
rotVOID SetByteEventPort(rotOBJECT port)
ifSerialControl has these member functions:
rotBOOL SetBaudRate(roINT32 baud_rate)
Supported baud rates are:
1800, 2000, 2400, 3600, 4800, 7200, 9600,
12800, 14400, 19200, 23040, 28800, 38400, 57600,
115200
rotBOOL SetMode(rotSTRING mode)
o
Set the serial mode in “8N1” syntax. The first character is the number of data bits and can either
be 5, 6, 7 or 8. The second is the parity and can be “N”one, “O”dd or “E”ven. The third is the
number of stop bits and can be 1 or 2.
o
HD2000 only
rotBOOL SetEcho(rotBOOL enable)
o
Enables or disables serial echo. Returns true on success and false on failure.
o
HD2000 only
roSerialPort sends events of the following type:
1. roStreamLineEvent - The line event is generated whenever the end of line string set using
SetEol is found and contains a rotString for the whole line.
2. roStreamByteEvent - The byte event is generated on every byte received.
Example: This code waits for a serial event, and echos the input received on the serial port to the
shell
serial = CreateObject("roSerialPort", 0, 9600)
p = CreateObject("roMessagePort")
serial.SetLineEventPort(p)
serial_only:
msg = wait(0,p) ' Wait forever for a message.
if(type(msg) <> "roStreamLineEvent") goto serial_only 'Accept serial
messages only.
serial.SendLine(msg) ' Echo the message back to serial.
31