Serial with C++ (Windows)


I need to have a library to read and write to the serial port to the arduino over C++ in windows. I want to write strings to the arduino, read chars from the arduino, check if the connection is working and if possible see if there is anything available from the arduino (and of course setting up a connection with baudrate, port etc.).

I have looked at the "Arduino and C++ (for Windows)" topic in the playground, it looks good, but how to I use the ReadData and WriteData and how do I set the Baudrate?

Please help!

I have an Uno.


P.S. It can be in Qt.

P.S. It can be in Qt.

How about in C#? C# makes it trivially easy to configure, write to, and read from the serial port.

I like C++ better. Qt are just some librarys for C++ for easy crossplattform programming and some more things. Here's a link:

It's enough if you tell me how to use the ReadData and WriteData in the library Arduino and C++ for Windows.

When you drop the SerialPort object on the form, you can select it, and look at its properties. One of the properties is Baud Rate. Should be easy enough to figure how to set it.

The source code for ReadData and WriteData is given.

ReadData requires that you pass it an array, that it can put data that it reads into, and the size of that array.

char someStuff[100];
int cc = ReadData(someStuff, 100);

After this call, cc will contain the number of characters actually read from the serial port, and someStuff will contain the characters actually read.

WriteData is similar, except that you need to store the data IN someStuff, first.

Ok, I think I understand now, thanks.