new socketcan connection
This commit is contained in:
+41
-21
@@ -3,21 +3,11 @@
|
||||
|
||||
#include <QObject>
|
||||
#include <QCanBus>
|
||||
#include <QTimer>
|
||||
#include <qthread.h>
|
||||
|
||||
#include "canframemodel.h"
|
||||
#include "canconnection_old.h"
|
||||
|
||||
class BUSConfig {
|
||||
public:
|
||||
BUSConfig();
|
||||
void reset();
|
||||
bool operator ==(CANBus&);
|
||||
void operator =(CANBus&);
|
||||
bool isConfigured;
|
||||
int speed;
|
||||
bool listenOnly;
|
||||
bool active;
|
||||
};
|
||||
#include "canconnection.h"
|
||||
|
||||
|
||||
class SocketCanConnection : public CANConnection
|
||||
@@ -25,20 +15,50 @@ class SocketCanConnection : public CANConnection
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SocketCanConnection(CANFrameModel *, int);
|
||||
virtual ~SocketCanConnection() override;
|
||||
SocketCanConnection(QString portName);
|
||||
virtual ~SocketCanConnection();
|
||||
|
||||
virtual void start();
|
||||
virtual void stop();
|
||||
|
||||
|
||||
signals:
|
||||
void error(const QString &);
|
||||
|
||||
void status(CANCon::status);
|
||||
void deviceInfo(int, int); //First param = driver version (or version of whatever you want), second param a status byte
|
||||
|
||||
//bus number, bus speed, status (bit 0 = enabled, 1 = single wire, 2 = listen only)
|
||||
//3 = Use value stored for enabled, 4 = use value passed for single wire, 5 = use value passed for listen only
|
||||
//6 = use value passed for speed. This allows bus status to be updated but set that some things aren't really
|
||||
//being passed. Just set for things that really are being updated.
|
||||
void busStatus(int, int, int);
|
||||
|
||||
|
||||
public slots:
|
||||
virtual void updateBusSettings(CANBus) override;
|
||||
|
||||
private:
|
||||
void errorReceived(QCanBusDevice::CanBusError error) const;
|
||||
virtual void sendFrame(const CANFrame *);
|
||||
virtual void sendFrameBatch(const QList<CANFrame> *);
|
||||
|
||||
virtual void setBusSettings(int, CANBus);
|
||||
virtual bool getBusSettings(int pBusIdx, CANBus& pBus);
|
||||
|
||||
virtual void suspend(bool);
|
||||
|
||||
protected:
|
||||
void disconnectDevice();
|
||||
|
||||
private slots:
|
||||
void errorReceived(QCanBusDevice::CanBusError) const;
|
||||
void framesWritten(qint64 count);
|
||||
void framesReceived();
|
||||
void disconnect();
|
||||
void testConnection();
|
||||
|
||||
QCanBusDevice* mDev_p;
|
||||
BUSConfig mConf;
|
||||
protected:
|
||||
QCanBusDevice* mDev_p;
|
||||
QTimer mTimer;
|
||||
QThread mThread;
|
||||
};
|
||||
|
||||
|
||||
#endif // SOCKETCANCONNECTION_H
|
||||
|
||||
Reference in New Issue
Block a user