Moxa Technologies NE-4100 Network Card User Manual


 
NE-4100 Series User’s Manual DIO Commands
D-5
Byte # Descriptor Value Description
10 Data 0, 1
3rd requested DIO channel, optional
0: channel status is low
1: channel status is high
11 Data 0, 1
4th requested DIO channel, optional
0: channel is in input mode
1: channel is in output mode
12 Data 0, 1
4th requested DIO channel, optional
0: channel status is low
1: channel status is high
For example, the 10-byte response 5-2-0-6-0-0-1-1-0-1 indicates that DIO 0 is in input mode and
“low” status, DIO 1 is in output mode and “high” status, and DIO 2 is in input mode and “high”
status.
C Code Example:
BOOL ReadMultipleDIO(int start, int end, int *mode, int *status)
{
DIOPacketStruct packet;
packet.header.command = 5; // Read Multiple DIO Commands
packet.header.version = 2; // DIO protocol command version
packet.header.length = 2; // data length
packet.data[0] = start; // start of the DIO number
packet.data[1] = end; // end of the DIO number
send(SocketFd, (char *)&packet, sizeof(DIOHeaderStruct)+2, 0);
//Send TCP packet
//Process the returned data here
return TRUE;
}
Write Multiple DIO
Command
Byte # Descriptor Value Description
1 Header 6 command number, fixed
2 Header 2 version, fixed
3 Header (any) this byte is only used in the module’s response
4 Header 6, 8, 10
data length, depends on the number of channels
being written (6 bytes for 2 channels, 8 bytes for 3
channels, 10 bytes for 4 channels)
5 Data 0,1,2 starting DIO channel number
6 Data 1,2,3 ending DIO channel number
7 Data 0,1
1st DIO channel to be written
0: set to input mode
1: set to output mode
8 Data 0,1
1st DIO channel to be written
0: set to low
1: set to high