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

Page 83

NE-4100 Series User’s ManualDIO Commands

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

}

3. Reading Multiple DIOs

Parameter:

Command code: 5(hex)

Version: 2(hex)

Command status: doesn’t matter

Length of data: 2(hex); represents two bytes.

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

data[1]: The last number of the DIO you wish to access. 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:

 

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;

}

C-3

Image 83
Contents Sixth Edition, April NE-4100 Series User’s ManualCopyright Notice Table of Contents Chapter Configuring Windows Administrator Introduction Overview Package ChecklistProduct Features Product Specifications NE-4120 Series/NE-4120-ST Panel Layout and Pin AssignmentsNE-4100-ST NE-4100T/NE-4100-STPanel Layouts NE-4100TRXD1 Pin AssignmentsLED Name LED Color LED Function Block DiagramNE-4100-ST LED Indicators NE-4110-ST evaluation board for NE-4110 Series NE-4110 Series/NE-4110-STNE-4110S NE-4110ADIO and LED Header Pinouts J2 for NE-4110S/A Serial Header Pinouts J1 for NE-4110SSerial Header Pinouts J1 for NE-4110A Ethernet Port Pinouts for NE-4110S/ANE-4110A Block Diagram Block DiagramsNE-4110S Block Diagram NE-4110-ST LED Indicators NE-4120-ST evaluation board for NE-4120 Series NE-4120 Series/NE-4120-STTop Panel of NE-4120S Top Panel of NE-4120ASerial Header Pinouts J1 for NE-4120A Serial Header Pinouts J1 for NE-4120SNE-4120A Block Diagram NE-4120S Block DiagramNE-4120-ST LED Indicators Getting Started Attaching NE-4100T to the Evaluation Board Wiring RequirementsAttaching NE-4120 Series to the Evaluation Board Attaching NE-4110 Series to the Evaluation BoardCircuit Pad for External Connection DI/O Settings Connecting the PowerConnecting to the Network Connecting to a Serial DeviceDigital Output LED Circuit Design JP2 Selecting the InterfaceChoosing the Proper Operation Mode TCP Server Mode UDP Mode TCP Client ModeReal COM Mode ARP Initial IP Address ConfigurationInitializing NE-4100 Series Module’s IP Address Factory Default IP AddressNE-4100 Series Administration Suite Default IP addressTelnet Console Page Serial Console 19200, n, 8 Web Console Configuration Opening Your Browser Time zone Basic SettingsServer name Time server Setting Factory Default NecessityIP Address Network SettingsMethod Function Definition Gateway Setting Factory Default Necessity 255.255.255.0 RequiredSetting Factory Default Necessity None Optional IP configurationAuto report to IP Community nameContact LocationSerial Settings TCP Server Mode Operating SettingsDelimiter Max connectionMax. connection Max connection 2 toSetting Factory Default Necessity 966 Optional Real COM ModeSetting Factory Default Necessity 4001 Required Command portNE-4100 Series User’s Manual Web Console Configuration TCP Client Mode Destination IP address 1/2/3/4 TCP connection on UDP ModeLocal Listen port Allowable Hosts Input format Accessible IP Settings# Hosts on a given subnet can access the NE-4100 # Any host can access the NE-4100Mail and Snmp Trap Auto Warning SettingsEvent Type DIO Monitor Digital IOSave/Restart Change PasswordLoad Factory Defaults Monitor Port Monitor COM Mapping Configuring Windows AdministratorInstalling Network Enabler Administrator NE-4100 Series User’s Manual Web Console Configuration Broadcast Search Starting the ConfigurationNE-4100 Series User’s Manual Web Console Configuration Unlock Password Protection Fixed LockUnlock BlankConfiguring NE-4100 Upgrading the Firmware Export/Import Monitor Select Add Target NE-4100 Series User’s Manual Web Console Configuration NE-4100 Series User’s Manual Web Console Configuration Port Monitor On-line COM Mapping COM MappingSelect COM Setting to modify COM No., default setting, etc NE-4100 Series User’s Manual Web Console Configuration Off-line COM Mapping SW Reset Function NE-4100 Series User’s Manual SW Reset Function Well Known Port Numbers TCP Socket Application ServiceNE-4100 Series User’s Manual Well Known Port Numbers UDP Socket Application ServiceNeci Library Data Structure Definition DIO CommandsCommand Packet Format Length Bytes Header Data ACK Packet Format Length Bytes Header DataWriting a Single DIO Parameters Command Code Usage Reading Single DIO ParametersReading Multiple DIOs NE-4100 Series User’s ManualDIO CommandsWriting Multiple DIOs Snmp Agent with MIB II & RS-232 Like Group Address Translation MIB System MIB Interfaces MIBService Information Following services are provided Moxa Internet ServicesSerial Number Problem Report FormMoxa Product & NE-4100T Product Return Procedure