Response; C Code Example - Moxa Technologies MiiNePort E2-H User Manual

Miineport e2/e3
Hide thumbs Also See for MiiNePort E2-H:
Table of Contents

Advertisement

MiiNePort E2/E3

Response

Byte #
Descriptor
1
Header
2
Header
3
Header
4
Header
5
Data
6
Data
7
Data
8
Data
9
Data
10
Data
11
Data
12
Data
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;
}
Value
Description
5
command number, fixed
2
version, fixed
0, 1, 2, 3,
command status/error code (0 = okay)
4, 5, 6,
0xFF
4, 6, 8
data length, depends on the number of DIO channels
requested
0, 1
1st requested DIO channel
0: channel is in input mode
1: channel is in output mode
0, 1
1st requested DIO channel
0: channel status is low
1: channel status is high
0, 1
2nd requested DIO channel
0: channel is in input mode
1: channel is in output mode
0, 1
2nd requested DIO channel
0: channel status is low
1: channel status is high
0, 1
3rd requested DIO channel, optional
0: channel is in input mode
1: channel is in output mode
0, 1
3rd requested DIO channel, optional
0: channel status is low
1: channel status is high
0, 1
4th requested DIO channel, optional
0: channel is in input mode
1: channel is in output mode
0, 1
4th requested DIO channel, optional
0: channel status is low
1: channel status is high
D-5
DIO Commands

Advertisement

Table of Contents
loading

Table of Contents