Sometimes, we want to trace our program after the program has been deployed into a WSN mote. In another scenario, we may want to investigate our Contiki program before deploying it to a WSN mote. Debugging is one solution.
Hardware Debugger
Most WSN motes do not provide built-in hardware debuggers, so if we want to debug a Contiki-NG program through the hardware approach, we need additional hardware. Regarding what WSN mote model we want to perform debugging on, we should check your MCU model.
For Atmel MCU on MICAz, Mica2, and Iris platforms, you need JTAG Atmel. Otherwise, for MCU-based MSP430, you use MSP430 USB Debugging Interface from Texas Instruments (TI).
For our cases, Dr. Huan could provide us TelosB (still, I have not received them yet.) whose debugger can be obtained in MSP-FET site, but for OpenMote Rev B, CC2538 is used, they all comes from TI company, however, they cannot use the same debugger, which means that we may need to have at least two kinds of Hardware Debugger, this is definitely not efficient.
LED Indicators
In general, a WSN mote is equipped with several LED. We can use these LED to indicate a specific task; for instance, we turn on a specific LED to inform us that the WSN mote performs sensing. We can find an LED library in the <contiki>/core/dev/leds.h
header file. In the next chapter, we will try to develop a Contiki application utilizing GPIO (General Purpose Input/Output).
Based on experiences in PCN, this approach is easy to implement. However, the downside of this method is having no more information; for instance, we might want to get a certain value from a specific task on our program.
Debugging Using Contiki Simulator
With the third approach, we can use the Contiki simulator, COOJA. We can compile and attach a Contiki program to the Contiki simulator. We can see messages that are generated using the printf()
method. For instance, the hello-world application prints messages using printf()
(actually, this method is not as useful as it mentioned in literature) or LOG_INFO()
(I love method).
The Contiki printf( ) Function
The last method that I like is using the printf()
function. The idea is that our program writes messages using printf()
, and then the messages will pass through to the serial port.
To listen to incoming messages from the serial port, we can use the login command on Terminal. This approach is easy and low cost for debugging our Contiki application. Just place a printf()
function on the code we are investigating.