4set_com, 5send_com, 6send_io – CREATOR CR-PGMIII User Manual

Page 31: 7read_io, 24 pgmⅢ programmable ethernet control system

Advertising
background image

CREATOR CHINA 2011-03

WWW.CREATOR1997.COM

24

PGMⅢ Programmable Ethernet Control System

7.6.2.4 SET_COM

void SET_COM(String dev,

int channel,
long sband,
int databit,
int jo,
int stopbit,
int dataStream,
int comType)

Function: Setup the COM interface

Parameters:
dev - :device name
channel - : Device channel number
sband - :Baud Rate
databit - :data bit 1~8
jo - :Parity 0:none,1:Odd number,2:even
number,3:Mark,4:space
stopbit-:Stop bit 10,15,20, corresponding to
10=1,15=1.5,20=2
dataStream - :Data flow:0:无,1:xon/xoff,2:
hardware

comType - :COM interface communication type
232,485,422; default value is 232

Sample
Com_m = M:1000:COM; //define the COM
interface with the motherboard number of 1000
// setup the COM interface’s first channel (i.e.
define the first COM interface with the
motherboard number of 1000)
// Baud rate is 9600,Data bit is 8,no parity, Stop
bit is 1,No data flow, communication type is 232

SET_COM(Com_m,1,9600,8,0,10,0,232);

7.6.2.5 SEND_COM

void SEND_COM(String dev,int channel,
String str)
Function: Com interface data sending

Parameters:

dev - :Com interface device
channel - :Device channel number
str - :Com interface data, support two formats:
1:Direct transmit string data ( send the string as it
is to the Com interface)
2:Conversion into Hex string (when it encounters
string starting with 0x or 0X, the string will be
converted into Hex format and be sent. For
example: if 0x3132 is sent, the COM interface will
receiver the string of “12”).
Example
Com_m = M:1000:COM; // define the COM
interface with the motherboard number of 1000
SEND_COM(Com_m,1,”1234”); // send the string
“1234” to the first channel of the mother board
SEND_COM(Com_m,1,”0x31323334”); // send
the string “1234” to the first channel of the
motherboard

7.6.2.6 SEND_IO

void SEND_IO(String dev,int channel,int val)
Function:Control I/O interface
Parameters:
dev - :io device
channel - :Device channel number
val - :data 0 | 1

Example
Io_m = M:1000:IO; // define the I/O interface with
the mother board number of 1000
SEND_IO(Io_m,1,0); // output low electrical level
to the first channel of Io_m

7.6.2.7 READ_IO

int READ_IO(String dev,int channel)
Function:Control I/O interface
Parameters:
dev - :io device
channel - :Device channel number

Return:return the electrical level status of the
“channel” in the I/O interface: it is 0 or 1. Other
value is viewed as false.

Advertising