25 _device->setBaudRate(QSerialPort::Baud115200);
26 _device->setFlowControl(QSerialPort::NoFlowControl);
27 _device->setStopBits(QSerialPort::OneStop);
28 _device->setDataBits(QSerialPort::Data8);
29 _device->setParity(QSerialPort::NoParity);
30 _device->setPortName(serialPort);
32 if(
_device->open(QSerialPort::ReadOnly))
39 qDebug() <<
"Serial port not open";
63 statusBar->setText(
"Połączono z portem szeregowym | Nazwa portu: " +
_device->portName());
67 statusBar->setText(
"Rozłączono z portem szeregowym");
75 while(
_device->waitForReadyRead())
79 QByteArray line =
_device->readLine();
80 if(line[line.length() - 1] ==
'\n')
82 line[line.length() - 1] = 0;
84 if(line[line.length() - 2] ==
'\r')
86 line[line.length() - 2] = 0;
void receiveData()
Receive line one by one in loop until end of communication.
bool closeSerialPort()
Close serial port.
~Communication()
Destruct Communication object.
QSerialPort * _device
Serial device handle.
bool _continue
Identifier whether to continue communicating with the serial.
Communication()
Construct new Communication object.
bool openSerialPort()
Wraper function for opening serial port.
void setStatus(QLabel *statusBar)
Set status of port openning on status bar.
void endCommunication()
End communicaiton with serial device.
bool isOpen()
Check wether serial poet is open.
FrameBuffer _frame
Frames buffer.
bool _opened
Identifier whether serial device is open.
void addFrame(const std::string &frame)
Add one frame to the end of the list.
Header file for Communication class.