Serial had been deprecated - looking for replacment

Hi, its me again. Looks like most of my errors are all solved. I recreated the progam using a blinky template but

Serial pc(USBTX, USBRX);

is not longer valid. Can some one point me to the correct replacement. I just want t spit some serial data out to a terminal.

(NB I’m using MBED studio and LPC1114 - so its bare metal)

Thanks

Andrew

Hello,

The old Serial were splitted into two new APIs and do not contains printf any more without external help (library)

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

BR, Jan

Hello Syed, Thanks for your help. I’ve made the chnges to the code, like this

BufferedSerial pc(USBTX, USBRX, 9600); //this is the first statement in main()
.
.
.
.
pc.write(“\n vendor_id = %d pair_command = %d address = %d command = %d stop_bit = %d \r”, vendor_id, pair_command, address, command, stop_bit);

but I’m now getting this error

The compiler is spitting out ‘use of undeclared identifier’. Any ideas why this is happening?

Thanks
Andrew

Ahh,

looks like the BufferedSerial statement must come at the top of the program. Let me keep digging.

Andrew

Not out of the woods yet.

I’m getting ‘too many arguments’ error now. Just for reference, all I’m doing here is spitting out to Teleterm the codes and data from the remote control for debugging/dev purposes. Under normal operation, this is disabled (I am using mbed LPC1114).

Any pointers greatly appreciated.

Rgds

Andrew

Be so kind and open links to documentation what I posted above and look how it the write method looks like.

write (const void *buffer, size_t length)

There are just two parametr - a buffer of chars and its size. So there is not possible to do something similar like with printf function. So you need something like this - cplusplus.com/reference/cstdio/sprintf/

And code will look like this

 char buffer [50];
 int n, a=5, b=3;
 n=sprintf (buffer, "%d plus %d is %d", a, b, a+b);
 pc.write(&buffer, n);

But I believe the guy with the chatGPT will explain it better again :slight_smile:

BR, Jan

I think I’m starting to smell success. Thanks for everyones help!