Added functionality to calculate target location.

Added functionality to capture camera frame from RTSP stream.
Refactored code.
Fixed some minor issues.
This commit is contained in:
Nffj84
2024-06-18 17:29:40 +03:00
parent 05722c0e09
commit db2652d979
15 changed files with 689 additions and 264 deletions
+15 -7
View File
@@ -1,7 +1,10 @@
#include "serialPort.h"
#include <QDebug>
#include "defines.h"
SerialPort::SerialPort(const QString &portName) : mSerialPort(portName) {
SerialPort::SerialPort(const QString &portName)
: mSerialPort(portName)
{
mSerialPort.setPortName(portName);
mSerialPort.setBaudRate(QSerialPort::Baud115200);
mSerialPort.setDataBits(QSerialPort::Data8);
@@ -9,11 +12,13 @@ SerialPort::SerialPort(const QString &portName) : mSerialPort(portName) {
mSerialPort.setFlowControl(QSerialPort::NoFlowControl);
}
SerialPort::~SerialPort() {
SerialPort::~SerialPort()
{
closePort(); // Close port if open on destruction
}
bool SerialPort::openPort() {
bool SerialPort::openPort()
{
if (mSerialPort.isOpen()) {
qDebug() << "Port already open";
return true;
@@ -22,13 +27,15 @@ bool SerialPort::openPort() {
return mSerialPort.open(QIODevice::ReadWrite);
}
void SerialPort::closePort() {
void SerialPort::closePort()
{
if (mSerialPort.isOpen()) {
mSerialPort.close();
}
}
void SerialPort::sendCommand(const QByteArray &command) {
void SerialPort::sendCommand(const QByteArray &command)
{
if (!mSerialPort.isOpen()) {
qDebug() << "Error: Port not open";
return;
@@ -37,7 +44,8 @@ void SerialPort::sendCommand(const QByteArray &command) {
mSerialPort.write(command);
}
QByteArray SerialPort::readResponse() {
QByteArray SerialPort::readResponse()
{
if (!mSerialPort.isOpen()) {
qDebug() << "Error: Port not open";
return QByteArray();
@@ -45,7 +53,7 @@ QByteArray SerialPort::readResponse() {
// Read data from serial port until timeout or specific criteria met
QByteArray response;
while (mSerialPort.waitForReadyRead(5000)) { // Adjust timeout as needed
while (mSerialPort.waitForReadyRead(SERIAL_RESPONSE_WAIT_TIME)) { // Adjust timeout as needed
response.append(mSerialPort.readAll());
}