EasyManua.ls Logo

Moxa Technologies MiiNePort E2-H - Response; C Code Example; Read Multiple Dios; Command

Moxa Technologies MiiNePort E2-H
149 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
MiiNePort E2/E3 DIO Commands
D-4
Response
Byte # Descriptor Value Description
1 Header 2 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 3 data length, fixed
5 Data 0, 1, 2, 3 desired DIO channel #
6 Data 0, 1 0: channel has been changed to input mode
1: channel has been changed to output mode
7 Data 0, 1 this byte is ignored for input mode
0: channel status has been changed to low
1: channel status has been changed to high
For example, the seven-byte response sequence 2-2-0-3-0-0-0 indicates that DIO 0 has been changed to input
mode.
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
}
Read Multiple DIOs
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
six-byte command sequence 5-2-0-2-0-2 requests the status of DIO channels 0 through 2.

Table of Contents

Related product manuals