User`s manual

WE-2100T Series User’s Manual DIO Commands
C-3
Return:
Command Status: Check the Command Status code on the previous page.
Length of data: 3(hex). Must be 3 bytes of return code in this mode.
data[0]: The number of the DIO you wish to access.
data[1]: DIO mode(hex), 0 for IN, 1 for OUT
data[2]: DIO status(hex), 0 for LOW, 1 for HIGH
C code example:
void WriteSingleDIO(int port, int mode, int status)
{
DIOPacketStruct packet;
packet.header.command = 2; // write single DIO command
packet.header.version = 2; // DIO protocol version
packet.header.length = 3; // data length
packet.data[0] = (char)port; // number of the DIO
packet.data[1] = (char)mode; // DIO mode
packet.data[2] = (char)status; // DIO status;
send(SocketFd, (char *)&packet, sizeof(DIOHeaderStruct)+3, 0); //Send TCP packet
//Process the returned data here
}
3. Reading Multiple DIOs
Parameter:
Command code: 5(hex)
Version: 2(hex)
Command status: doesn’t matter
Length of data: 2(hex); represents two bytes.
data[0]: Number of the DIO you wish to access first.
data[1]: The last number of the DIO you wish to access.
Return:
Command Status : Check the Command Status code on the previous page.
Length of data: (end-start+1)*2
data[0]: mode of start DIO
data[1]: status of start DIO
data[2]: mode of (start+1) DIO
data[3]: status of (start+1) DIO
.
data[(end-start)*2]: mode of end DIO
data[(end-start)*2+1]: status of end DIO
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