While trying to debug my nRF24 wireless boards I saw that there was a radio.printDetails() call that sent lots of useful information to stdout.
To get hold of this, I added some calls to my code to redirect stdout to the USBSerial device.
Monitoring this output (on a Windows 7 box) was a bit difficult, as the USB COM port disappeared as the program was uploaded, then came back (usually), but nothing was then attached to read it.
To get around this, I wrote a program (In C#, as a bit of a learning exercise), which watches for the insertion of the Digispark USB serial device, then connects to it and displays the data received. It automatically closes/opens as the device is removed/added, and will follow it around if it changes COM port names due to attaching to different USB ports.
It isn't perfect and doesn't always attach, which seems to be due to windows getting confused with multiple USB device insertion/removal events, but it is getting there!
Required .Net 4, no installer or source as yet but I can add depending on interest.
See SerialDebug.exe inthe attached zip archive.
I've also put my wireless test program into the archive file.
The basic stdout redirect looks like this:
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
#include <DigisparkOLED.h>
#include <DigiCDC.h>
#include <Wire.h>
#include <stdio.h>
// This function writes a character to the USB Serial device.
// We can use it to provide a stdout stream to that device
int usbser_putchar(char c, FILE *stream) {
if (c == '\n') {
usbser_putchar('\r', stream);
}
SerialUSB.write(c);
return c;
}
// We will use this to replace stdout
static FILE *usbser_output;
void setup() {
// put your setup code here, to run once:
// Here we start the USB serial device
// Then we replace stdout with a stream to that device
SerialUSB.begin();
usbser_output = fdevopen(usbser_putchar,NULL);
stdout = usbser_output;
}
void loop() {
// Print to stdout, appears on PC monitor program
printf("=== Debug Test! ===\n");
delay(1000);
}