I am using this library, http://arduino.cc/playground/Interfacing/CPPWindows
, for controlling USB port (virtual COM3).
I can send data from my c++ application towards arduino, but I can not read what arduino is sending to PC. Using the serial monitor from arduino software, everything works fine, but not in my c++ app. My application is a Visual C++ 6.0 MFC Application.
arduino is using this code:
temp = Serial.read();
my c++ app is using the exact code from the library in the link above. this is how I use the library in my c++ application:
I made a class Serial, use an instance of this class,
// if a button on my application is clicked, it should send a char to arduino, and monitor what arduino is sending back (first it sends the same character back, as in the code above, later it will send results from some sensors on arduino).
char a = 'W';
mySerial.WriteData(&a,1); // WriteData works, arduino starts doing what it should if char W received
char *temp = new char();
int x = mySerial.ReadData(temp,1);
if(x > 0)
m_ListBox2.AddString("data not read");
m_ListBox2.AddString("not connected"); // this never executes
PROBLEM is that it sends only giberish char...
SO, I think that I have a problem of understanding how this library works, probably I don't use the functions how I should... or my C code is wrong. Or both