serialOpen
Top  Previous  Next

serialOpen ( integer Com [, string Settings = "9600,N,8,1", integer InpThresh =1,
integer OutThresh =0 ] )  

Use this function to open a serial port and set up its attributes.

Parameters
 
Com  
 
A positive integer specifying the port number.  
 
Settings  
 
A string specifying the serial port's baud rate, parity, data bit, and stop bit attributes. It is composed of four settings and has the following format: "BBBB,P,D,S", where BBBB is the baud rate, P is the parity, D is the number of data bits, and S is the number of stop bits.  
 
The following table lists the valid baud rates.  
110
300
600
1200
2400
4800
9600 (Default)
14400
19200
28800
38400
56000
57600
115200
128000
256000

 
The following table describes the valid parity values.  
 
E
Even
M
Mark
N
(Default) None
O
Odd
S
Space

 
The following table lists the valid data bit values.  
 
4
5
6
7
8 (Default)

 
The following table lists the valid stop bit values.  
 
1 (Default)
1.5
2

   
 
Default value: "9600,N,8,1"  
 
InpThresh  
 
An optional integer specifying the number of characters to receive before the communication event is raised. Setting this parameter to zero disables generating communication events when characters are received. See serialWait for more details.  
Default value: 1  
 
OutThresh  
 
An optional integer specifying the minimum number of characters allowable in the transmit buffer before the communication event is raised. Setting this parameter to zero disables generating communication events for data transmission. See serialWait for more details.  
Default value: 0  
 
Error flags
 
ERR_OK  
 
The flag set if successful.  
 
ERR_FAILED  
 
The flag set if failed.  
 
ERR_NOTFOUND  
 
No open port found.  
 

Example
 
This set of statements opens a serial port using specified communication attributes and sends a string of characters to it.  
 
serialOpen (1,"19200,N,8,1")  
serialWrite("Serial port test")  
serialClose()