How to solve the error " unknown type name 'Serial' "


usually is necessary to add more context. However this case could be caused by MbedOS version. The MbedOS lower than 6 used Serial, RawSerial or UARTSerial but all of them are obsolete and were replaced with BufferedSerial and UnbufferedSerial in MbedOS 6+. So you probably use old code with newer MbedOS library.

More info about Un/BufferedSerial in MbedOS API list (Deprecated APIs are at end of page)- Full API list - API references and tutorials | Mbed OS 6 Documentation.

Another helpful content - Hitchhiker’s Guide to Printf in Mbed 6 - Mbed OS - Arm Mbed OS support forum

BR, Jan

Use this :
BufferedSerial pc(USBTX, USBRX,115200); // tx, rx, speed

pc.write(“Data to be printed”,20) ; //20 = length of the data