CAN interface

add next mid function
This commit is contained in:
2026-02-01 18:40:29 +01:00
parent bd72cda97e
commit 29c00d1ffc
2 changed files with 9 additions and 1 deletions
+7 -1
View File
@@ -1,7 +1,7 @@
#include "CAN_interface.hpp" #include "CAN_interface.hpp"
CAN_Interface::CAN_Interface(QString dev, QObject *parent) CAN_Interface::CAN_Interface(QString dev, QObject *parent)
: QObject(parent) : QObject(parent), m_mid(0)
{ {
if (!QCanBus::instance()->plugins().contains(QStringLiteral("socketcan"))) { if (!QCanBus::instance()->plugins().contains(QStringLiteral("socketcan"))) {
throw std::runtime_error("CAN Interface: socketcan plugin not found"); throw std::runtime_error("CAN Interface: socketcan plugin not found");
@@ -33,3 +33,9 @@ void CAN_Interface::send_frame(const QCanBusFrame &frame)
{ {
m_canDevice->writeFrame(frame); m_canDevice->writeFrame(frame);
} }
uint8_t CAN_Interface::next_mid()
{
return m_mid++;
}
+2
View File
@@ -14,9 +14,11 @@ class CAN_Interface : public QObject
~CAN_Interface(); ~CAN_Interface();
void send_frame(const QCanBusFrame &frame); void send_frame(const QCanBusFrame &frame);
uint8_t next_mid();
signals: signals:
void frame_received(const QCanBusFrame frame); void frame_received(const QCanBusFrame frame);
private: private:
QCanBusDevice *m_canDevice; QCanBusDevice *m_canDevice;
uint8_t m_mid;
}; };