June 27th, 2014, 08:32 AM
Libserial, read serial port
I am using libserial library to interact with a modem using c++. The C++ code sends an AT command:
The modem responds with a response, either ERROR or OK,
my_serial_stream << "AT+CSQ" << '\r' ;
The c++ code to read the response:
i would like to handle the response such that if the response is OK, the modem sends another command and if the response is ERROR, the modem resends the first command.
while( serial_port.rdbuf()->in_avail() > 0 )
std::cerr << std::hex << (int)next_byte << " ";
std::cerr << std::endl;
June 30th, 2014, 06:05 AM
Re: Libserial, read serial port
Use std::string variable to accumulate the text received from modem and see if it contains "OK" or "ERROR"...
Tags for this Thread
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!