Unbuffered Serial Mbed 6 usage

In the past I have used Rawserial to read and write serial packets while doing other stuff but it has depreciated in mbed 6. I read to switch to Unbuffered serial but I am unsure how to use it.

I want to receive a packet from a pilot radio like

sbus.attach(&onSbusRx, Serial::RxIrq);

void onSbusRx(void)
{
if(sbusRxLen < PACKET_SIZE2) {
sbusRxBuf[sbusRxLen++] = sbus.getc();
rx2Timer.reset();
}
else
sbus.getc();
}

And then send commands to a flight controller with something like
for (uint8_t i = 0; i < 25; i++) {
sbus.putc(sbus_out[i]);
}

Hi,
what exactly is not clear for you?
The example of the unbufferedserial documentation looks good.

Instead of:

sbusRxBuf[sbusRxLen++] = sbus.getc();
sbus.putc(sbus_out[i]);

you will use:

sbus.read(&sbusRxBuf[sbusRxLen],  sizeof(sbusRxBuf[sbusRxLen]));
sbusRxLen++;

sbus.write(&sbus_out[i], sizeof(sbus_out[i]));

BR, Jan

Thank you that builds without error, I did not understand incrementing inside of the reference. I’m just really green at c in general.