Moxa Technologies NE-4100 Network Card User Manual


 
NE-4100 Series User’s Manual DIO Commands
D-4
packet.data[2] = (char)status; // DIO status;
send(SocketFd, (char *)&packet, sizeof(DIOHeaderStruct)+3, 0);
//Send TCP packet
//Process the returned data here
}
Read Multiple DIO
Command
Byte # Descriptor Value Description
1 Header 5 command number, fixed
2 Header 2 version, fixed
3 Header (any) this byte is only used in the module’s response
4 Header 2 data length, fixed
5 Data 0,1,2 starting DIO channel number
6 Data 1,2,3 ending DIO channel number
This command requests the status of a range of DIO channels, specified in bytes 5 and 6. For
example, the 6-byte command sequence 5-2-0-2-0-2 requests the status of DIO channels 0 through
2.
Response
Byte # Descriptor Value Description
1 Header 5 command number, fixed
2 Header 2 version, fixed
3 Header
0, 1, 2, 3,
4, 5, 6,
0xFF
command status/error code (0 = okay)
4 Header 4, 6, 8
data length, depends on the number of DIO channels
requested
5 Data
0, 1
1st requested DIO channel
0: channel is in input mode
1: channel is in output mode
6 Data
0, 1
1st requested DIO channel
0: channel status is low
1: channel status is high
7 Data
0, 1
2nd requested DIO channel
0: channel is in input mode
1: channel is in output mode
8 Data
0, 1
2nd requested DIO channel
0: channel status is low
1: channel status is high
9 Data 0, 1
3rd requested DIO channel, optional
0: channel is in input mode
1: channel is in output mode