How do you serial print and debug at the same time?

Hello, I’m new to the world of micro-controller, and have started using the Arduino board and the Telit GM862. I would like to know how people debug their programs. I’ve been using software serial and use the hardware serial for debugging purposes, e.g.

// use pins 7 and 8 for RX and TX

SoftwareSerial modem = SoftwareSerial(7,8);

modem.print(“AT\r\n”);

Serial.println(“Run the AT command”);

Clearly I cannot do both debugging and serial communication unless the other party is instructed to ignore. Not sure how this can be done in my case.

So my question is how do people debug? Is it possible to redirect software serial to STDOUT/STDERR, e.g., so that I could use statements like this:

modem.println(STDERR, “debugging state…”);

and see this printed on the Serial Monitor window of Arduino instead of this print going to the modem?

Thank you.

I forgot to add that I prefer to use hardware serial for the actual communication with the modem and use software serial for debugging.

I’m doing the samething right now with a GE865, I tried using NewSoftSerial and what not but finally just used pins 0,1 on the Arduino (same ones for USB). As long as you just print out AT commands you shouldn’t have any problems. This way you get to monitor the communications between the two units directly. The only thing you have to be aware of is when you upload a sketch to the Arduino you will need to power off the GSM module first or you’ll get an error uploading.

Wayne

The most common debugging technique is monitoring, which in applications programming is done by calling printf at suitable points. When you are debugging kernel code, you can accomplish the same goal with printk. Well, I am using printk Function, I used the printk function in earlier chapters with the simplifying assumption that it works like printf. Now it’s time to introduce some of the differences. One of the differences is that printk lets me classify messages according to their severity by associating different loglevels, or priorities, with the messages. I usually indicate the loglevel with a macro.