11 #include <QtSerialPort/QSerialPort>
12 #include <QtSerialPort/QSerialPortInfo>
46 _sp.setBaudRate(QSerialPort::Baud38400);
48 _sp.setStopBits(QSerialPort::OneStop);
49 _sp.setParity(QSerialPort::NoParity);
50 _sp.setDataBits(QSerialPort::Data8);
52 QSerialPortInfo qi(port);
56 if(!
_sp.open(QIODevice::ReadWrite))
64 if(idstring.size() != 3 || idstring[0] !=
'B' || idstring[1] !=
'e' || idstring[2] !=
'n')
67 ThrowException(QString(
"Invalid initial connection response: ").append(idstring));
95 if(
_sp.write((
const char *)command, len) != len)
100 while((
unsigned int)res.size() < (4+expectedreslen))
103 if(!(
_sp.waitForReadyRead(timeout)))
106 res.push_back(
_sp.readAll());
116 if((
unsigned int)res[0] != (3+expectedreslen))
117 ThrowException(QString(
"Unexpected response size: %1 instead of %2").arg((
int)res[0]).arg(3+expectedreslen));
119 return res.mid(4, res.size()-4);
129 uint8_t infocmd[2] = {
'\\',
COM_INFO};