24 _device->setBaudRate(QSerialPort::Baud115200);
25 _device->setFlowControl(QSerialPort::NoFlowControl);
26 _device->setStopBits(QSerialPort::OneStop);
27 _device->setDataBits(QSerialPort::Data8);
28 _device->setParity(QSerialPort::NoParity);
29 _device->setPortName(serialPort);
31 if(
_device->open(QSerialPort::ReadOnly))
60 while(
_device->waitForReadyRead())
65 QByteArray line =
_device->readLine();
66 if(line[line.length() - 1] ==
'\n')
68 line[line.length() - 1] = 0;
70 if(line[line.length() - 2] ==
'\r')
72 line[line.length() - 2] = 0;
void receiveData()
Receive line one by one from the serial device in loop until end of communication.
bool closeSerialPort()
Close the serial port.
QSerialPort * _device
Serial device handle.
bool _continue
Identifier whether to continue communication with serial device.
bool openSerialPort()
Wrapper function for opening a serial port.
bool isOpen() const
Check if the serial port is open.
FrameBuffer _frame
Circular buffer for frames.
bool _opened
Identifier whether serial device is open.
void addFrame(const std::string &frame)
Add one frame at the end of list.
Communication class declaration.