C
DIO Commands
In this appendix, we give the reference DIO commands used to access the Digital I/O status of the Network Enabler from an Ethernet network. The Digital I/O status can be accessed by a specific TCP port (default 5001) on the Network Enabler.
Command Packet Format:
Length (Bytes) | 4  | 1 – 255  | 
Format  | *Header | Data | 
Send the Command packet to the Network Enabler. “Data” field is command specific.
ACK Packet Format:
Length (Bytes) | 4  | 1   | 
Format  | *Header | Data | 
The Network Enabler returns by ACK packet. You can get the Digital I/O status and input/output operation mode by checking the “Data” field of the packet.
*Header Format:
Length (Bytes)  | 1  | 1  | 1  | 1  | 
Format  | Command  | Version  | Command Status  | Length (for data)  | 
  | 
  | (must be 2)  | 
  | 
  | 
Check the “Command Status” to get the result after sending the Command packet.
Command: This field defines the command code. For example, 1(hex) represents “read single D I/O.” For more information, please refer to following content.
Command Status: This field returns the status of the command. 0 – OK
1 – Command error; may be unknown
2 – Version error; not supported by this version
3 – Length error; the length member does not match the attached data
4 – Operation error; you cannot set the DIO mode to input mode, and set the DO status at the same time
5 – “Packet too short” error
6 – DIO number error; might not support request DIO number 0xFF – other unknown error
Data Structure Definition:
C code example:
//define DIO Header format
typedef struct _DIO_Header_Struct {
char  | command;  | 
char  | version; /* This specification is version 2 */  | 
char  | status;  | 
char  | length;  | 
} DIOHeaderStruct, *pDIOHeaderStruct;