Moxa Technologies user manual NE-4100 Series User’s ManualDIO Commands, Writing Multiple DIOs

Models: NE-4100

1 90
Download 90 pages 17.34 Kb
Page 84
Image 84
4. Writing Multiple DIOs

NE-4100 Series User’s ManualDIO Commands

4. Writing Multiple DIOs

Parameters:

Command code: 6(hex)

Version: 2(hex)

Command status: doesn’t matter

Length of data: (end-start+1)*2 + 2

data[0]: Number of the DIO you wish to access first.

data[1]: The last number of the DIO you wish to access

data[2]: mode of start DIO

data[3]: status of start DIO

data[4]: mode of (start+1) DIO

data[5]: status of (start+1) DIO ….

data[(end-start)*2+2]: mode of end DIO

data[(end-start)*2+3]: status of end DIO 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:

 

 

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

}

Note: A utility that can be used to test the DIO access commands can be found on the CD-ROM.

C-4

Page 84
Image 84
Moxa Technologies user manual NE-4100 Series User’s ManualDIO Commands, Writing Multiple DIOs