Mbed_os6 - unbufferedSerial issue

Hi mbed team,

I looking for advice how to implement UnbufferedSerial in my program.

main.cpp:

#include “mbed.h”
#include “other_module.h”
int main()
{
pc.attach(&read_serial, UnbufferedSerial::RxIrq);
pc.write(“Write to console\r\n”,18);


}

and
other_module.h

extern UnbufferedSerial pc;

and in
other_module.cpp

#include “mbed.h”
UnbufferedSerial pc(USBTX, USBRX, 9600);
.

and I still get compilation error :
.\main.cpp:31:45: error: ‘mbed::SerialBase::IrqType mbed::SerialBase::RxIrq’ is inaccessible within this context

Its looks like to me, that it would like to use Serial class but not UnbufferedSerial.
How I can fix it ?

Thank you for any advice

It looks like UnbufferedSerial::attach() is a private function and you can’t call it in user code. To get similar behavior to what you have (call a function when serial port is readable), it looks like you want sigio().

Also note that if you are receiving input over the serial port, you probably want to be using BufferedSerial since UnbufferedSerial can only store at most a few bytes at a time for reading.

EDIT: Actually attach() is a public function, never mind. I think all you need to do is change UnbufferedSerial::RxIrq to SerialBase::RxIrq.

Instead of UnbufferedSerial use RawSerial class. I have not checked your library header file (try to check access specifier)
Use any circular buffer method to store data.

Here is one example , method is almost same as you used.

Click here ::

UART_SERIAL_EXAMPLE_IMPORT_LINK

RawSerial class is deprecated, and It shall not be use in mbed-os 6, therefor I try use Unbuffered, as was recommended.

No, In mbedOS-6 attach() - private