FreeMODBUS
A portable MODBUS ASCII/RTU and TCP implementation
A portable MODBUS ASCII/RTU and TCP implementation
This port was based on the original STR71X port of FreeModbus. It adds PPP support to lwIP and includes an advanced serial driver which uses the FIFOs of the UART. It supports PPP connection up to 115200baud and include a working Modbus/TCP example application. The files for this port can be found in demo/STR71XTCP.
The next figure shows an example of the debug console from the embedded target. First a PPP connection was established with a Linux host system with a Null-Modem cable. The a new Modbus/TCP client connected with IP address 10.0.10.1 and sent two Modbus commands. After that the client has disconnected.
INFO: PPP: new PPP connection established INFO: PPP: our IP address = 10.0.10.2 INFO: PPP: his IP address = 10.0.10.1 INFO: PPP: netmask = 255.255.255.0 DEBUG: MBTCP-ACCEPT: Accepted new client 10.0.10.1 DEBUG: MBTCP-RECV: | TID = 0000 | PID = 0000 | LEN = 0006 | UID = 01|| FUNC = 04 | DATA = 03E70002 | DEBUG: MBTCP-SENT: | TID = 0000 | PID = 0000 | LEN = 0007 | UID = 01|| FUNC = 04 | DATA = 04AC610001 | DEBUG: MBTCP-RECV: | TID = 0000 | PID = 0000 | LEN = 0006 | UID = 01|| FUNC = 04 | DATA = 03E70002 | DEBUG: MBTCP-SENT: | TID = 0000 | PID = 0000 | LEN = 0007 | UID = 01|| FUNC = 04 | DATA = 04B0420001 | DEBUG: MBTCP-CLOSE: Closed connection to 10.0.10.1.
Again we can use the modpoll utility to test the port. An example is shown below. Note the TCP/IP configuration.
[root@pcno-4 STR71XTCP]# ./simple.sh modpoll - FieldTalk(tm) Modbus(R) Polling Utility Copyright (c) 2002-2004 FOCUS Software Engineering Pty Ltd Protocol configuration: MODBUS/TCP Slave configuration: Address = 1, start reference = 1000, count = 1 TCP/IP configuration: Host = 10.0.10.2, port = 502 Data type: 32-bit integer, input register table Protocol opened successfully. Polling slave (Ctrl-C to stop) ... [1000]: 87913 Polling slave (Ctrl-C to stop) ... [1000]: 88914 Polling slave (Ctrl-C to stop) ... [1000]: 89914 Polling slave (Ctrl-C to stop) ...