First of all, sorry for my limited knowledge. I'm quite new to C++ and I'm having trouble connecting the Raspberry Pi to the Koala car using RS232.
The problem I'm facing is that I know everytime I send the command to the car, there will be a random signal sent from the Pi and it will affect my commands. For every first command I send I always get the "Command not found" response from the car.
I'm trying to use the Flush() function to clear off that random signal but it seems to not working :(. Here is my code, please help me :(
bool res;
std::string data;
std::string temp;
_serial = new ClsSerialCom(COM.c_str());
_serial->Flush();
res = _serial->Write("B\r", 2);
//usleep(2000);
if (res == true)
// Read the Acknowledge
//usleep(2000);
res = _serial->Read(data);
//usleep(2000);
//std::cout << data << std::endl;
if (res != true || data[0] != 'b')
{
_serial->Flush();
returnfalse;
}
cout << data;
// return 1 means successful in opening the serial port
returntrue;