serial_open()

Opens serial COM port and sets communication parameters.

Syntax

serial_open(port, baudrate, bits, parity, stopbits, flowcontrol);

Parameters

port COM port name. Use string type, e.g. “COM10”.
baudrate Baudrate value. Available values are: (optional)
4800 - 4800bd
9600 - 9600bd
192200 - 192200bd
115200 - 115200bd
bits Data bits value. Available values are: (optional)
5 - 5 data bits
6 - 6 data bits
7 - 7 data bits
8 - 8 data bits
9 - 9 data bits
parity Parity value. Available values are: (optional)
0 - no parity
1 - odd parity
2 - even parity
stopbits Stop bit value. Available values are: (optional)
0 - no stop bit
1 - one stop bit
2 - two stop bits
flowcontrol Flowcontrol. Available values are: (optional)
0 - no flow control
1 - flow control enabled
Return Value Returned value is 0 when port is successfully opened. Returned value is 1 when port cannot be opened. Returned value is integer number.
0 - port successfully opened
1 - port unsuccessfully opened

Example

result = serial_open("COM10", 9600, 8, 0, 1, 0); 

result:

0

See also

serial_list, serial_info, serial_close, serial_config