cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
UNIX/Linux Programming
libserial, handle serial port data
libserial, handle serial port data
Jun 27, 2014 at 12:06pm UTC
farai
(7)
I am using libserial library to interact with a modem using c++. The C++ code sends an AT command:
my_serial_stream << "AT+CSQ" << '\r' ;
The modem responds with a response, either ERROR or OK,
The c++ code to read the response:
while( serial_port.rdbuf()->in_avail() > 0 )
{
char next_byte;
serial_port.get(next_byte);
std::cerr << std::hex << (int)next_byte << " ";
}
std::cerr << std::endl;
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.
Topic archived. No new replies allowed.