Last active
July 7, 2016 07:10
-
-
Save modjo756/37fe8b3ec20a11146f0dce6e9c0e626b to your computer and use it in GitHub Desktop.
class for use can on neo boards
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef QCAN_H | |
#define QCAN_H | |
#include <QObject> | |
#include <QtSerialBus> | |
typedef struct //CAN message struct | |
{ | |
quint16 i_length; // --> size of packet | |
QTime neoTime; //time of comming frame | |
quint64 i_timesStamp; //timestamp of the CAN trame in us | |
quint8 i_channel; //can channel | |
quint8 i_dlc; //data lenght max 8 bytes | |
quint32 i_id; //bit 0-28 ID - bit 29 0 - bit 30 RTR - bit 31 1 for Extended trame 0 for std | |
char data[8]; //8x8 bytes | |
}structCan; | |
class QCan : public QObject | |
{ | |
Q_OBJECT | |
public: | |
explicit QCan(QObject *parent = 0); | |
~QCan(); | |
signals: | |
void data(structCan frame); | |
public slots: | |
void connectDevice(QString device, int bitrates, bool loopBack, bool listenMode); | |
void disconnectDevice(QString device); | |
private slots: | |
void checkMessages(); | |
void receiveError(QCanBusDevice::CanBusError error) const; | |
private: | |
//methods | |
void interpretError(const QCanBusFrame &); | |
bool canShellOpen(QString &device, int rates); | |
bool canShellClose(QString &device); | |
//members | |
QCanBusDevice *m_canDevice; | |
structCan m_sCan; | |
}; | |
#endif // QCAN_H |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment