How to send break signal via BufferedSerial

Hi,
I am using a LoRa-E5. I have to send a break signal through the serial. set_break and clear_break can’t be used because of private member of SerialBase.

How do I generate a break signal on mbed 6.15 ?

This was my idea:

    sdi12.set_break();
    ThisThread::sleep_for(12ms);
    sdi12.clear_break();
    ThisThread::sleep_for(100ms);
    sdi12.write( "?!\r\n", 4);

Thomas

Hello Thomas,

It seems to be just an error in the documentation. According to the source code mbed-os/drivers/include/drivers/SerialBase.h the methods set_break() and clear_break() are public:

class SerialBase : private NonCopyable<SerialBase> {

public:

...

    /** Generate a break condition on the serial line
     *  NOTE: Clear break needs to run at least one frame after set_break is called
     */
    void set_break();

    /** Clear a break condition on the serial line
     *  NOTE: Should be run at least one frame after set_break is called
     */
    void clear_break();

...

It’s not just documentation. Compiler tells me that error:

Compile [  1.0%]: main.cpp
[Error] main.cpp@114,11: 'set_break' is a private member of 'mbed::SerialBase'
[Error] main.cpp@116,11: 'clear_break' is a private member of 'mbed::SerialBase'
[Warning] main.cpp@236,26: 'call_in' is deprecated: Pass a chrono duration, not an integer millisecond count. For example use `5s` rather than `5000`. [since mbed-os-6.0.0] [-Wdeprecated-declarations]
[Wa

I just “hacked” a new method into to BufferedSerial. When calling set_break() and monitoring on my Osci it does not realy react how I expected it. It seams that set_break itself returns to clear_break. So I couldn’t control the duration of the break signal.

The error message is not exact. The problem is that the SerialBase is a private ancestor of the BufferedSerial.

Try to create a new class, e.g. LoRaBufferedSerial, by copy&paste the BufferedSerial and modify it as below:

class LoRaBufferedSerial:
    public SerialBase,  // replace private with public
    public FileHandle,
    private NonCopyable<LoRaBufferedSerial> { // replace BufferedSerial with LoRaBufferedSerial

public:
...

And use that in your application:

LoRaBufferedSerial sdi12

This does not really make sense to me. Ok its a workarround for me, but I am loosing every bugfix on BufferedSerial in the future.
Sending a break signal is essential for handling serial interfaces (DMX512, SDI-12, …), so for what reason is SerialBase made private and therefore blocked for further usage?

Where do I place feature requests for mbed os ? In Github?

I see your point and agree. Hope you receive an answer from arm-mbed staff soon.