SoftPLC
 
Font size:      

Debugging Tips

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

Enabling Debug Prints

In the configuration file there is the top most element SmartTLM and its attribute debug . The first several bits of this integer value enable various categories of print statements in the TLM. Remember a debug value of "0" means no debugging, and a debug value of -1 turns on all bits.

Bit Mapped Debug Categories
Bit NumberDebug Print Category
0Configuration File Parsing.
1TLI Parameters. This feature will print any detected problems with the parameters that you are passing to the ladder instructions.
2This will print out anything related to the I/O modules which are detected in the racks.

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 awhile, say 5-60 seconds, then press control-C. Now you have the output captured in file /tmp/out.txt, each debug print statment will be captured in that file.
  6. You can look at the file using the program named "less".
    # less /tmp/out.txt
    Press ESC when done. You can also FTP this file up to your developement computer and look at it with a text editor.
  7. You can make configuration file changes and Send them down to SoftPLC. Then merely repeat the part of this process starting at step 4 above.
  8. 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