2 years, 4 months ago.

serial communication in c++

C ++ program that sends a string LPC1768. How can I do ?

Comment on this question

1 Answer

2 years, 4 months ago.

Using printf will send a string over serial so that it can be read in a console. The default baud rate is 9600. It is as easy as this:

#include "mbed.h"

int main() {
    printf("Hello World\n");
}

Mmm, I want to do it from a C ++ IDE.

posted by Thomas Villacci 04 Aug 2017

The above can be compiled as a .cpp file.

posted by Brandon Boesch 04 Aug 2017

How do you do it?

I would like to send a string through serial communication from an IDE c ++ to LPC1768

posted by Thomas Villacci 04 Aug 2017

Here is an example on how to create a program on mbed's online compiler. The example also happens to be using a LPC1768 as well!

https://docs.mbed.com/docs/mbed-os-handbook/en/latest/getting_started/blinky_compiler/

posted by Brandon Boesch 04 Aug 2017

I know this. I would like to send the string from DEV c ++ to the mbed LPC1768, and not using the mbed compiler.

posted by Thomas Villacci 04 Aug 2017

I would like the program written in c ++ to send a string via serial communication, so then i need it for linux

posted by Thomas Villacci 04 Aug 2017

Here is a list of the IDEs that are mbed supported: https://docs.mbed.com/docs/mbed-os-handbook/en/latest/dev_tools/third_party/

posted by Brandon Boesch 04 Aug 2017

ok this. I need the serial communication program to be written in c ++

posted by Thomas Villacci 04 Aug 2017

I may be misunderstanding what it is you exactly wanted to do. Are you trying to send strings via UART to your LPC1768, from a c++ program that is running on your computer?

posted by Brandon Boesch 04 Aug 2017

Yes,Only that I can not do it.

posted by Thomas Villacci 04 Aug 2017

What kind of things are you having problems with? Here is a blog about how to read and write from a serial port in C. Should be similar for C++.

https://stackoverflow.com/questions/6947413/how-to-open-read-and-write-from-serial-port-in-c

posted by Brandon Boesch 04 Aug 2017

You need to log in to post a question