Hitchhiker's Guide to Printf in Mbed 6

As explained by @ boraozgen :

#include "mbed.h"
#include "USBSerial.h"

FileHandle* mbed::mbed_override_console(int)
{
    static USBSerial   myConsole(false, 0x1f00, 0x2012, 0x0001);
    return &myConsole;
}

Edit: To make this work

  • either create the myConsole as myConsole(true, 0x1f00, 0x2012, 0x0001);
  • or call myConsole.connect(); before returning from the function.

See below @ boraozgen’s tip.