Skip to content

TroubleShootSouliss

Dario Di Maio edited this page Oct 23, 2016 · 8 revisions

Troubleshooting Souliss

In some cases, you are not able to get in communication with nodes within your Souliss network and needs some tools to find out the problem or gives details to the support team. For this reason the layers that empower the Souliss communication has a _debug mode that logs on a console how incoming frames are processed.

Serial Console

Using the serial connection between the board(s) and your PC you can retrieve the log and follow the frames that are processed by your node. By default is used the hardware USART of your microcontroller that in most of the boards is available as Virtual COM to your USB connector.

You can use the Serial Monitor of the Arduino IDE or other equivalent software. We strongly suggest the use of PuTty that allows you to flush the content into a file. By default the log is printed trough Serial object, you can define a different object inSketch using the following statements:

#define SERIALPORT_INSKETCH
#define LOG          Serial

Any object that support the same API as the Arduino Serial is allowed, so that you can print logs on any interface (example over a TCP/IP channel). Is required to setup manually the object used to print, using the default Serial object you need to add into the setup the following code:

Serial.begin(9600);

Most of the debug messages are loaded into the FLASH, some are instead in the RAM. Please consider this when using debugs, because it can crash the nodes. Is mandatory to remove the debug mode for normal operation.

Please note that microcontroller that use a simulated virtual COM (like ATMega32U4 on Arduino Leonardo) can be affected in case of large use of RAM. This can prevent the microcontroller to simulate the virtual COM and this will brick your board and require to reload the boot-loader through ICSP. Compile your sketch without downloading it to the board, check the RAM and load it only if you are not hitting the 80% threshold of used RAM.

Example of debug over TCP/IP for ESP8266

If you are using the USART of the ESP8266 as RS485 interface, then using the following code will allow to print the debug messages on a Telnet (TCP port 23) session.

Note, the WiFiServer and WiFiClient libraries are part of the ESP8266 core, this code can be no longer applicable in the future if the core maintainers will change the relevant API.*

Before setup()

// Define a Telnet server
WiFiServer telnetServer(23);
WiFiClient serverClient;

// Redirect LOG traffic from the USART (default) to the serverClient
#define SERIALPORT_INSKETCH
#define LOG    serverClient

In setup()

// Start the Telnet server
telnetServer.begin();
telnetServer.setNoDelay(true);

In loop()

// Flush incoming traffic, debug has only outgoing traffic
if (telnetServer.hasClient()) {
    if (!serverClient || !serverClient.connected()) {
      serverClient = telnetServer.available();
      serverClient.flush();  // clear input buffer, else you get strange characters 
    }
}

Enable the Debug Mode

Some components of Souliss has a Debug / Logging mode that can be activated from the user configuration files located into the souliss/conf folder. Below the list of such components:

Component or Layer Debug Option Configuration File
vNet VNET_DEBUG vNetCfg.h
MaCaco MaCaco_DEBUG MaCacoCfg.h
uIP UIP_LOGGING uIPopt.h
Modbus MODBUS_DEBUG SoulissCfg.h
XML Interface XMLSERVER_DEBUG SoulissCfg.h
Souliss SOULISS_DEBUG SoulissCfg.h

A sample Log

Once activated the debug mode, open the serial monitor to the COM port where your board is attached (if you are using a bootloader, is the same COM port used for downloading the sketch on the node) and you will see a log for each frame processed.

Before compile you need to activate the USART at a given baudrate, if you are using the Arduino IDE just type Serial.begin() in your setup().

(vNet)<OUT><DADDR><|0x6512><|0xB|0x17|0x6512|0x6511>
(vNet)<IN><|0x13|0x17|0x6511|0x6512|0x11|0x9|0x3|0x7B|0x8|0x0|0x0|0x11|0xFF|0x0|0x0|0x0|0x0>
(vNet)<OUT><DADDR><|0x6512><|0xB|0x17|0x6512|0x6511>
(vNet)<IN><|0x13|0x17|0x6511|0x6512|0x15|0x59|0x3|0xCB|0x8|0x0|0x0|0x0|0x0|0x0|0x0|0x0|0x0>
(vNet)<OUT><DADDR><|0x6512><|0xB|0x17|0x6512|0x6511>
(vNet)<IN><|0x13|0x17|0x6511|0x6512|0x11|0x9|0x3|0x7B|0x8|0x0|0x0|0x11|0xFF|0x0|0x0|0x0|0x0>
(vNet)<OUT><DADDR><|0x6512><|0xB|0x17|0x6512|0x6511>
(vNet)<IN><|0x13|0x17|0x6511|0x6512|0x15|0x59|0x3|0xCB|0x8|0x0|0x0|0x0|0x0|0x0|0x0|0x0|0x0> 

Setup PuTty

In order to keep all the required information, setup PuTty to copy all the logging output to a file. As firt step you need to specify the serial port where you Arduino board is connected to

And then select in the Logging tab the following options, ensure to use a different name for each logging session.

If you have to troubleshoot a communication problem, log all involved nodes at same time, this will give you as output a set of files that can be compared to understand the communication flow.

Clone this wiki locally