RS0

This command reads from and writes to the COM port buffer for COM ports 0 and higher.

Syntax

Use this syntax when you want to read a string from a COM port.

The port_number must be from 0 to 12.

If you set the "settings" to an empty string, then the program will use the communication parameters that are set in the template for this COM port. Otherwise, the "settings" must specify the communication parameters for the specified COM port, using one of the following formats:

Valid options for these settings include:

setting:

valid options

explanation

baud=

any valid baud rate
(9600, 14400, 19200, etc.)

 

parity=

E

Even

O

Odd

N

None

M

Mark

S

Space

data=

5, 6, 7  or 8

number of data bits

stop=

1, 1.5 or 2

number of stop bits

xon=

on

optional setting to turn on Xon/Xoff (when needed)

Use this syntax when you want to send a string to a COM port.

See above for explanations of port_number and "settings" .

"Text_output" must be a string. This is the text that you will send to the specified COM port.

Return value

When used to read from the COM port, this command returns the first numeric value found in the string that was read from the COM port.

When used to write to the COM port, this command does not return a value.

Notes

When you use this command to read from COM port n, it reads the first ASCII string from the queue in that COM port buffer and places that ASCII string in the GainSeeker text buffer (where you can use other commands such as COL_S, COLUMN or FIELD to extract specific values). To read the next ASCII string in the queue, execute another RS0 command for the same COM port.

The variable named MySVar "RS0_n" is used to manage the remaining ASCII strings that were queued for this COM port buffer. If it is useful for the logic of your template or for troubleshooting purposes, you can check for values in this variable.

When your template uses this command to work with a COM port, this template should not use the RS232 command to work with the same COM port.

If your template also needs to use RS232 input mode cells to read from COM port 0, you should use the formula DE_OPT 30, 1 to make this input mode compatible with COM port 0. This DE_OPT command should be executed before the template encounters the first cell in RS232 input mode.

Note:  If a data entry operator presses CTRL+K during data entry to bypass the RS-232 device and enter data values via keyboard, the data entry session will replace any RS232 input mode cells with Keyboard input mode cells. However, the data entry session will still try to execute all commands in the template – including the RS0 command – and the operator may not be able to complete data entry without access to the RS-232 device.
If this will cause significant problems during data entry, you may need to use only RS232 input mode cells (and avoid using the RS0 command) or create a second template for keyboard data entry that can be used when the RS-232 device is not available.

See also: FL0, DE_OPT 30

Examples

RS0 0, ""

This formula uses the communication parameters set in the template for COM port 0 to read the first ASCII string in the queue for COM port 0. The entire ASCII string is placed in the text buffer, and the formula returns the first numeric value in that string.

RS0 0, "baud=2400 parity=E data=7 stop=1", "/A"

This formula uses the communication parameters of baud rate 2400, even parity, 7 data bits and 1 stop bit to send the text string "/A" to COM port 0.