UART object used by mbed_debug

Hi there,

I’ve posted on GitHub to no avail, so I thought I’d try my luck here.

I am using the debug() function (from mbed_debug.h) to print a bunch of info/error messages when using the debug build profile. Under specific circumstances I instantiate a UARTSerial object in the following way, where the TX/RX pins are the same as used for the mbed_debug UART:

UARTSerial *_serial;
_serial = new UARTSerial(TX, RX, BAUD);

The creation of this UARTSerial object breaks the debug() output. My question is a simple one; is there an explicit function call I can make to re-instantiate the UART used by mbed_debug after deleting my _serial object?

If not, I am using the UARTSerial object with an ATCmdParser:

_parser = new ATCmdParser(_serial);

Is there a way to access the object used by mbed_debug in a way that’s compatible with the ATCmdParser? This would save having to instantiate a new UARTSerial object in the first place. This would be the preferred solution.

Thanks,
Adam

Ahoj,
the mbed_debug probably use default setting for STDIO and that can be changed, check this.

Br, Jan

Hey Jan,

mbed_debug does indeed use the default STDIO. I don’t wish to change it, I just need to reinstantiate whichever object it uses after I delete my UARTSerial object. Any suggestions?

Cheers,
Adam

Hello Adam,

Is there a way to access the object used by mbed_debug in a way that’s compatible with the ATCmdParser ?

The debug() function prints to the stderr. So you can try to pass the stderr's FileHandle pointer to the ATCmdParser constructor:

ATCmdParser* _parser = new ATCmdParser(mbed_file_handle(STDERR_FILENO));

Hi Zoltan,

Thanks for this, it seems like exactly what I’m looking for.

Best regards,

Adam