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?
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.