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
Byte #
Descriptor
4
Header
5
Data
6
Data
7
Data
8
Data
9
Data
10
Data
11
Data
12
Data
For example, the eight-byte response 6-2-0-4-0-0-1-1 indicates that DIO 0 has been changed to input mode
and "low" status and DIO 1 has been changed to output mode and "high" status.

C Code Example

void WriteMultipleDIO(int start, int end, int* mode, int* status)
{
DIOPacketStruct packet;
packet.header.command = 6; // Write Multiple DIO Command Codes
packet.header.version = 2; // DIO protocol version
packet.header.length = (end-start+1)*2+2; // data length
packet.data[0] = start; // start DIO number
packet.data[1] = end; // end DIO number
int i, len;
for ( i=0; i<(end-start+1);i++ ) {
packet.data[i+2] = mode[i];
packet.data[i+3] = status[i];
}
send(SocketFd, )(char*)&packet,(end-start+1)*2+2+sizeof(DIOHeaderStruct), 0);
//Send TCP packet
//Process the returned data here
}
Value
Description
4, 6, 8
data length, depends on the number of DIO channels
requested
0, 1
1st requested DIO channel, 0: channel has been
changed to input mode, 1: channel has been changed
to output mode
0, 1
1st requested DIO channel, 0: channel status has been
changed to low, 1: channel status has been changed to
high
0, 1
2nd requested DIO channel, 0: channel has been
changed to input mode, 1: channel has been changed
to output mode
0, 1
2nd requested DIO channel, 0: channel status has
been changed to low, 1: channel status has been
changed to high
0, 1
3rd requested DIO channel, optional, 0: channel has
been changed to input mode, 1: channel has been
changed to output mode
0, 1
3rd requested DIO channel, optional, 0: channel status
has been changed to low, 1: channel status has been
changed to high
0, 1
4th requested DIO channel, optional, 0: channel has
been changed to input mode, 1: channel has been
changed to output mode
0, 1
4th requested DIO channel, optional, 0: channel status
has been changed to low, 1: channel status has been
changed to high
D-7
DIO Commands

Advertisement

Table of Contents
loading

Table of Contents