Dev OtarcikCan
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
#include "OtarcikCan.h"
|
||||
|
||||
COtarcikCan::COtarcikCan(QObject *parent) : QObject(parent)
|
||||
{
|
||||
mPCANInterface = new CPCANInterface;
|
||||
}
|
||||
|
||||
COtarcikCan::~COtarcikCan()
|
||||
{
|
||||
delete mPCANInterface;
|
||||
}
|
||||
|
||||
int COtarcikCan::Start()
|
||||
{
|
||||
mPCANInterface->Init();
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
#ifndef OTARCIKCAN_H
|
||||
#define OTARCIKCAN_H
|
||||
|
||||
#include <QObject>
|
||||
#include "PCANInterface.h"
|
||||
|
||||
class COtarcikCan : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit COtarcikCan(QObject *parent = 0);
|
||||
~COtarcikCan();
|
||||
|
||||
int Start();
|
||||
|
||||
private:
|
||||
CPCANInterface *mPCANInterface;
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
};
|
||||
|
||||
#endif // OTARCIKCAN_H
|
||||
@@ -0,0 +1,23 @@
|
||||
#include "PCANInterface.h"
|
||||
|
||||
CPCANInterface::CPCANInterface(QObject *parent) : QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
int CPCANInterface::Init()
|
||||
{
|
||||
TPCANStatus Result;
|
||||
Result = CAN_Initialize(PCAN_USBBUS1, PCAN_BAUD_500K);
|
||||
|
||||
if(Result != PCAN_ERROR_OK)
|
||||
{
|
||||
// An error occurred, get a text describing the error and show it
|
||||
//
|
||||
char strMsg[256];
|
||||
CAN_GetErrorText(Result, 0, strMsg);
|
||||
qDebug("%s",strMsg);
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
#ifndef PCANINTERFACE_H
|
||||
#define PCANINTERFACE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <windows.h>
|
||||
#include "PCANBasic.h"
|
||||
|
||||
class CPCANInterface : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CPCANInterface(QObject *parent = 0);
|
||||
int Init();
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
};
|
||||
|
||||
#endif // PCANINTERFACE_H
|
||||
@@ -1,17 +1,18 @@
|
||||
#include "MainWindow.h"
|
||||
#include <QApplication>
|
||||
#include <windows.h>
|
||||
#include "PCANBasic.h"
|
||||
#include "OtarcikCan.h"
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
CMainWindow w;
|
||||
w.show();
|
||||
COtarcikCan OtarcikCanProgram; //Instanciate the program
|
||||
|
||||
|
||||
w.show();
|
||||
OtarcikCanProgram.Start();
|
||||
|
||||
TPCANStatus stsResult;
|
||||
// Initialization of the selected channel
|
||||
stsResult = CAN_Initialize(PCAN_USBBUS1, PCAN_BAUD_500K);
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user