BufferedSerial doesn't compile with Online Compiler

I was trying to compile:


using Online Compiler for LPC1768.
I am getting:
Error: Unknown type name ‘BufferedSerial’ in “main.cpp”, Line: 15, Col: 8

I was trying to use mbed OS6. Why won’t it compile?

I can agree that (Online compiler with Nucleo-F767ZI)

  • revision 9a8c9e2 - same error
  • revision 8b095603a - same error
  • revision 165be79392 - no issue
  • revision 5daad96eb7 - same error
  • revision 1b2a68ae20 - same error

I have the same problem, using target NRF52840-DK

HI all,

looks like you need to add
#include “BufferedSerial.h”

underneath the mbed.h include. I’ll get our docs team to udpate the example .


Interestingly this compiles fine without changes using the offline mbed cli tool! I’m going to have a chat with our online compiler team. But including the header as stated above will work in the interim.

Hi Anna,

Also with both versions (online and desktop) of MbedStudio it is compiled fine and without including the header- MbedOS 6.1 Commit: a6207cadad0acd1876f436dc6baeddf46c42af06
The issue occur only with the Online compiler and it doesn’t matter what commit I use, from latests.

I have no luck with the solution (include the header) what you mentioned.
BTW same is for both new Serial APIs (UnbufferedSerial / BufferedSerial).

Thank you for your time.
BR, Jan

Hi Johnny

I’m investigating with the tools / online compiler team to try and get to the bottom of the issue. I’ll provide an update once we work out what the problem is.


1 Like

Hi all,

I’ve further investigated and had discussions with the tools team.
The online IDE was primarily designed for pre-6.0 versions of mbed-os. This means that additional steps may be required in order to get some of the 6.x based examples to work.

Please try the following steps:

  1. Import example
  2. When the pop up window appears, check the ‘update all libraries to latest versions’ and import
  3. Once the example has loaded , click on the project name, then select ‘revisions’ from the toolbar
  4. When the revision list comes up, highlight the version you wish to use (latest being v6.1 branch) and then click ‘switch’ from the toolbar

It should now compile.


Thank you Anna, it now works.

How do I set “SERIAL_RESERVED_CHAR_MATCH” in BufferedSerial.

int read (uint8_t *buffer, int length, const event_callback_t &callback, int event=SERIAL_EVENT_RX_COMPLETE, unsigned char char_match=SERIAL_RESERVED_CHAR_MATCH)

1 Like

I’m not sure I understand the question. What exactly are you trying to do ?

I was wondering if " SERIAL_RESERVED_CHAR_MATCH" would give me the same functionality of MODSERIAL as in serialport.autoDetectChar(’\r’);

I used circular serial to store and compare string received from UART port.
I have compiled and tested on my board NUCLEO ,with online MBED platform

Here is the link :


Hopefully this example help you

1 Like

Hi @radhey04ec,

Thank you, you share your example. But the RawSerial is deprecated in the MbedOS 6 and was removed. So if you want to use latest MbedOS, the RawSerial is not recommanded.
You can found that at end of APIs list or in the release note for the MbedOS 6.

This topic is about the issue around the new APIs (UnbufferedSerial/BufferedSerial) what are not usable in some revisions. How was wrote above, that was caused because MbedOS6 was released but Mbed tools were not 100% ready for it or something like that.
BR, Jan


It seems to compile OK with the latest Mbed OS 6.2.0.
But be aware that there is an issue with the online compiler when updating the mbed-os library.
So update manually! For those who never done it before:

  • Right-click on the mbed-os library in your project and select Revisions...
  • Click on the last revision (‘tag: mbed-os-6.2.0’) and click on the Switch button (on the toolbar).

Best regards, Zoltan

1 Like

Hello Jaydeep,
Thanks for responding, but my issue was whether BufferedSerial in OS6.x supports SERIAL_RESERVED_CHAR_MATCH, this feature is available in MODSERIAL.
MODSERIAL does not comile in OS6.x hence my issue.
Thanks all the same

Also trying to compile


using the Online Compiler for the FRDM-KL25Z.
The line
static BufferedSerial serial_port(USBTX, USBRX);
Error: Unknown type name ‘BufferedSerial’ in “main.cpp”, Line: 15, Col: 8

I have updated mbed-os to 6.3.0

What is the problem? It seems odd that a basic, frequently used API is broken. Hopefully, someone can help.

Hello Peter,

please see this topic and try to verify it with add followed code


You probably will see MbedOS 5 .15

I solved that with downgrade to the MbedOS 6.2.1, until it will be solved.

BR, Jan

1 Like

Thanks Jan,

Downgrade to MbedOS 6.2.1 worked and the example code compiled.