Modbus Slave TLM
  SoftPLC    Font size:      

Debugging Tips

This section gives tips on debugging problems on the Modbus network.

Enabling Debug Prints

In the configuration file there is the DEBUG setting. It may be set to 0, 1, or 2 to indicate that you want no, some, or most debugging respectively. Remember a DEBUG value of "0" means no debugging. On version 4.x SoftPLC, all process output from the SoftPLC runtime engine is normally directed to the syslog, because SoftPLC runs as a daemon normally. The syslog can be configured in a number of different ways, but the default uses a small RAM resident FIFO and eventually will run out of space and wrap back around on itself. Rather than reconfiguring the syslog, there is an easier way.

Following is a procedure to get the debugging output into a text file.

  1. Log into SoftPLC using either a) PUTTY from Windows or b) using ssh from Linux or c) at the command prompt of the SoftPLC system.
  2. Run this command:
    # /etc/init.d/softplc.sh stop
  3. Change into the /SoftPLC/run directory:
    # cd /SoftPLC/run
  4. You can run SoftPLC from the command prompt now and redirect its output to an arbitrary file (named out.txt here). We put that file into the RAM disk which is anchored in the /tmp directory.
    # ./runsplc > /tmp/out.txt
  5. Let this run for 5-60 seconds, then press control-C. Now you have the output captured in file /tmp/out.txt, each request-response transaction will be captured in that file.
  6. You can look at the file using the program named "less".
    # less /tmp/out.txt
    You can look at this output with the Modbus Specification, and the manual for your Modbus master software in hand. Press ESC when done.
  7. When done, remember to set debug back to "0", then you can start SoftPLC as a daemon either by a) power cycling the box or b) doing the following:
    # /etc/init.d/softplc.sh start