Open_com, Read_com – Argox PA-20 Programming Guide User Manual
Page 93

PT-20 Programming Guide
91
transmitted one by one until the specified number of character is sent. Use
the argument “port” as the connect port which is chosen to open. You can
c
hoose 1(RS232). The argument “count” is the number of words of sending
data.
If you select RS-232 and set hardware flow control(CTS/RTS), this function
will wait while data be transmitted.
Returns: -1 : error
Other value: the number of words that success writing into.
Purpose: Initialize and enable specified RS232 port
Syntax: int open_com(int com_port, int setting);
Example call: open_com(1,0x0b);/*openCOM1,baud rate 38400,8 data bits,no parity,no
handshake*/
Includes:
#include “SDK.h ”
Description: The open_com function initializes the specified RS-232 port. It clears the
receive buffer, stops any data transmission under going, reset the status of
the port, and set the RS-232 specification according to parameters set. Use
the argument “port” as the connect port which is chosen to open. You can
choose 1(RS232).
Each bit of the argument “setting”:
D0
~
D2
baud rate
0 :115200 1-2 : 57600
3 : 38400 4 : 19200
5 : 9600 6-7 : 4800
D3
data bits
0 : 7bits 1 : 8bits
D4
Parity enable
0 : disable 1 : enable
D5
even / odd
0 : odd 1 : even
D6
flow control
0 : disabe 1 : enable
D7
flow control method
0 : CTS/RTS 1 : Reserved
Returns: 0 : Open fail
1 : Open success
Remark: When flow control set up disable and flow control method set up CTS/RTS.
When you use IR port, the baud rate only can be setted 115200, flow control
disable.
Purpose: Read 1 byte from the RS232 receive buffer
Syntax: int read_com(int port, char *c);
Example call: char c;
int i;