This function will activate a serial port for access, send or receive data and close it after access is done.
|1 f/c/e||Required - What to do:|
spActivate - Setup the serial port for access.
spRead - Read characters from the serial port.
spWrite - Write characters to the serial port.
spClose - Close the serial port after access is complete.
|2 f/c/e||This part depends on the option specified in part 1.|
spActivate - Required - The port number, from 1 to 16.
spRead - Required - The field that receives the data in the buffer.
spWrite - Required - The A type field that will be used to output data.
|3 sac||This part depends on the option specified in part 1.|
spActivate - Required - The baud rate. Options are: br110, br300, br600, br1200, br2400, br4800, br9600, br14400, br19200, br38400, br56000, br57600, br115200, br128000, br256000. The number represents the actual baud rate, so br9600 is a baud rate of 9600.
spRead - The maximum number of characters to read. If no value is specified here the function will return all the characters in the buffer, up to the size of the field specified in part 2.
spWrite - The maximum number of characters to write. If no value is specified here the function will send the entire field that was specified in part 2.
|4 f/c/e||spActivate - Required - Hardware flow control. Options are: hwfcOff (no hardware flow control), hwfcRTSOn (Request To Send only), hwfcBothOn (both Request To Send and Clear ToSend active).|
|5 f/c/e||spActivate - Required - Parity setting. Options are: parNone (no parity), parOdd (odd parity check), parEven (even parity check), parMark, parSpace.|
|6 f/c/e||spActivate - Required - Software flow control. Options are: swfcOff (XonXoff is off), swfcOn (XonXoff is on).|
|7 f/c/e||spActivate - Required - Stop bits. Options are: sb1 (1 stop bit), sb1.5 (1 1/2 stop bits), sb2 (2 stop bits).|
|8 f/c/e||spActivate - Required - Data bits. Options are: db5, db6, db7, db8. The number represents the number of data bits, so db8 is 8 data bits.|
RETURN TYPE - I
Returns the result from the operation. spActivate - 0 if Successful
spClose - 0 if Successful
spRead - Number of character read
spWrite - Number of character Written.
This function eliminates the need for outside programs to access the serial port.
NOTE: The special alpha constants above are defined in COMPILERCONSTANTS.TXT.
The following example was a short test to put data out to a POS pole display that connected to com1.
//test of pole device
//open the serial port first
define s type a size 50
define i type i
if serial_port(spActivate, 1, br9600, hwfcRTSOn, parNone, swfcOff, sb1, db8)=0
msg 'port opened'
s = chr(18)
i = serial_port(spWrite, s, 1)
s = chr(13)+chr(10)+'This is a test: '+str(cntr,2)
i = serial_port(spWrite, s, size(s,'a'))
i = serial_port(spClose)