Dev OtarcikCan
This commit is contained in:
parent
4cfabfb2ad
commit
f1da647f35
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -28,9 +28,13 @@ INCLUDEPATH += $$PWD/ \
|
|||||||
$$PWD/Sources/PCAN \
|
$$PWD/Sources/PCAN \
|
||||||
|
|
||||||
SOURCES += Sources/main.cpp \
|
SOURCES += Sources/main.cpp \
|
||||||
Sources/MainWindow.cpp
|
Sources/MainWindow.cpp \
|
||||||
|
Sources/PCANInterface.cpp \
|
||||||
|
Sources/OtarcikCan.cpp
|
||||||
|
|
||||||
HEADERS += Sources/MainWindow.h
|
HEADERS += Sources/MainWindow.h \
|
||||||
|
Sources/PCANInterface.h \
|
||||||
|
Sources/OtarcikCan.h
|
||||||
|
|
||||||
FORMS += Sources/Gui/MainWindow.ui
|
FORMS += Sources/Gui/MainWindow.ui
|
||||||
|
|
||||||
|
|||||||
17
Otarcik_CAN/Sources/OtarcikCan.cpp
Normal file
17
Otarcik_CAN/Sources/OtarcikCan.cpp
Normal file
@ -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;
|
||||||
|
}
|
||||||
24
Otarcik_CAN/Sources/OtarcikCan.h
Normal file
24
Otarcik_CAN/Sources/OtarcikCan.h
Normal file
@ -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
|
||||||
23
Otarcik_CAN/Sources/PCANInterface.cpp
Normal file
23
Otarcik_CAN/Sources/PCANInterface.cpp
Normal file
@ -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;
|
||||||
|
}
|
||||||
20
Otarcik_CAN/Sources/PCANInterface.h
Normal file
20
Otarcik_CAN/Sources/PCANInterface.h
Normal file
@ -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 "MainWindow.h"
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <windows.h>
|
#include "OtarcikCan.h"
|
||||||
#include "PCANBasic.h"
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
CMainWindow w;
|
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();
|
return a.exec();
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
95
Otarcik_CAN/debug/moc_OtarcikCan.cpp
Normal file
95
Otarcik_CAN/debug/moc_OtarcikCan.cpp
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
** Meta object code from reading C++ file 'OtarcikCan.h'
|
||||||
|
**
|
||||||
|
** Created by: The Qt Meta Object Compiler version 67 (Qt 5.14.2)
|
||||||
|
**
|
||||||
|
** WARNING! All changes made in this file will be lost!
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include "../OtarcikCan.h"
|
||||||
|
#include <QtCore/qbytearray.h>
|
||||||
|
#include <QtCore/qmetatype.h>
|
||||||
|
#if !defined(Q_MOC_OUTPUT_REVISION)
|
||||||
|
#error "The header file 'OtarcikCan.h' doesn't include <QObject>."
|
||||||
|
#elif Q_MOC_OUTPUT_REVISION != 67
|
||||||
|
#error "This file was generated using the moc from 5.14.2. It"
|
||||||
|
#error "cannot be used with the include files from this version of Qt."
|
||||||
|
#error "(The moc has changed too much.)"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
QT_BEGIN_MOC_NAMESPACE
|
||||||
|
QT_WARNING_PUSH
|
||||||
|
QT_WARNING_DISABLE_DEPRECATED
|
||||||
|
struct qt_meta_stringdata_COtarcikCan_t {
|
||||||
|
QByteArrayData data[1];
|
||||||
|
char stringdata0[12];
|
||||||
|
};
|
||||||
|
#define QT_MOC_LITERAL(idx, ofs, len) \
|
||||||
|
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
|
||||||
|
qptrdiff(offsetof(qt_meta_stringdata_COtarcikCan_t, stringdata0) + ofs \
|
||||||
|
- idx * sizeof(QByteArrayData)) \
|
||||||
|
)
|
||||||
|
static const qt_meta_stringdata_COtarcikCan_t qt_meta_stringdata_COtarcikCan = {
|
||||||
|
{
|
||||||
|
QT_MOC_LITERAL(0, 0, 11) // "COtarcikCan"
|
||||||
|
|
||||||
|
},
|
||||||
|
"COtarcikCan"
|
||||||
|
};
|
||||||
|
#undef QT_MOC_LITERAL
|
||||||
|
|
||||||
|
static const uint qt_meta_data_COtarcikCan[] = {
|
||||||
|
|
||||||
|
// content:
|
||||||
|
8, // revision
|
||||||
|
0, // classname
|
||||||
|
0, 0, // classinfo
|
||||||
|
0, 0, // methods
|
||||||
|
0, 0, // properties
|
||||||
|
0, 0, // enums/sets
|
||||||
|
0, 0, // constructors
|
||||||
|
0, // flags
|
||||||
|
0, // signalCount
|
||||||
|
|
||||||
|
0 // eod
|
||||||
|
};
|
||||||
|
|
||||||
|
void COtarcikCan::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
|
||||||
|
{
|
||||||
|
Q_UNUSED(_o);
|
||||||
|
Q_UNUSED(_id);
|
||||||
|
Q_UNUSED(_c);
|
||||||
|
Q_UNUSED(_a);
|
||||||
|
}
|
||||||
|
|
||||||
|
QT_INIT_METAOBJECT const QMetaObject COtarcikCan::staticMetaObject = { {
|
||||||
|
QMetaObject::SuperData::link<QObject::staticMetaObject>(),
|
||||||
|
qt_meta_stringdata_COtarcikCan.data,
|
||||||
|
qt_meta_data_COtarcikCan,
|
||||||
|
qt_static_metacall,
|
||||||
|
nullptr,
|
||||||
|
nullptr
|
||||||
|
} };
|
||||||
|
|
||||||
|
|
||||||
|
const QMetaObject *COtarcikCan::metaObject() const
|
||||||
|
{
|
||||||
|
return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *COtarcikCan::qt_metacast(const char *_clname)
|
||||||
|
{
|
||||||
|
if (!_clname) return nullptr;
|
||||||
|
if (!strcmp(_clname, qt_meta_stringdata_COtarcikCan.stringdata0))
|
||||||
|
return static_cast<void*>(this);
|
||||||
|
return QObject::qt_metacast(_clname);
|
||||||
|
}
|
||||||
|
|
||||||
|
int COtarcikCan::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
|
||||||
|
{
|
||||||
|
_id = QObject::qt_metacall(_c, _id, _a);
|
||||||
|
return _id;
|
||||||
|
}
|
||||||
|
QT_WARNING_POP
|
||||||
|
QT_END_MOC_NAMESPACE
|
||||||
95
Otarcik_CAN/debug/moc_PCANInterface.cpp
Normal file
95
Otarcik_CAN/debug/moc_PCANInterface.cpp
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
** Meta object code from reading C++ file 'PCANInterface.h'
|
||||||
|
**
|
||||||
|
** Created by: The Qt Meta Object Compiler version 67 (Qt 5.14.2)
|
||||||
|
**
|
||||||
|
** WARNING! All changes made in this file will be lost!
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include "../Sources/PCANInterface.h"
|
||||||
|
#include <QtCore/qbytearray.h>
|
||||||
|
#include <QtCore/qmetatype.h>
|
||||||
|
#if !defined(Q_MOC_OUTPUT_REVISION)
|
||||||
|
#error "The header file 'PCANInterface.h' doesn't include <QObject>."
|
||||||
|
#elif Q_MOC_OUTPUT_REVISION != 67
|
||||||
|
#error "This file was generated using the moc from 5.14.2. It"
|
||||||
|
#error "cannot be used with the include files from this version of Qt."
|
||||||
|
#error "(The moc has changed too much.)"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
QT_BEGIN_MOC_NAMESPACE
|
||||||
|
QT_WARNING_PUSH
|
||||||
|
QT_WARNING_DISABLE_DEPRECATED
|
||||||
|
struct qt_meta_stringdata_CPCANInterface_t {
|
||||||
|
QByteArrayData data[1];
|
||||||
|
char stringdata0[15];
|
||||||
|
};
|
||||||
|
#define QT_MOC_LITERAL(idx, ofs, len) \
|
||||||
|
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
|
||||||
|
qptrdiff(offsetof(qt_meta_stringdata_CPCANInterface_t, stringdata0) + ofs \
|
||||||
|
- idx * sizeof(QByteArrayData)) \
|
||||||
|
)
|
||||||
|
static const qt_meta_stringdata_CPCANInterface_t qt_meta_stringdata_CPCANInterface = {
|
||||||
|
{
|
||||||
|
QT_MOC_LITERAL(0, 0, 14) // "CPCANInterface"
|
||||||
|
|
||||||
|
},
|
||||||
|
"CPCANInterface"
|
||||||
|
};
|
||||||
|
#undef QT_MOC_LITERAL
|
||||||
|
|
||||||
|
static const uint qt_meta_data_CPCANInterface[] = {
|
||||||
|
|
||||||
|
// content:
|
||||||
|
8, // revision
|
||||||
|
0, // classname
|
||||||
|
0, 0, // classinfo
|
||||||
|
0, 0, // methods
|
||||||
|
0, 0, // properties
|
||||||
|
0, 0, // enums/sets
|
||||||
|
0, 0, // constructors
|
||||||
|
0, // flags
|
||||||
|
0, // signalCount
|
||||||
|
|
||||||
|
0 // eod
|
||||||
|
};
|
||||||
|
|
||||||
|
void CPCANInterface::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
|
||||||
|
{
|
||||||
|
Q_UNUSED(_o);
|
||||||
|
Q_UNUSED(_id);
|
||||||
|
Q_UNUSED(_c);
|
||||||
|
Q_UNUSED(_a);
|
||||||
|
}
|
||||||
|
|
||||||
|
QT_INIT_METAOBJECT const QMetaObject CPCANInterface::staticMetaObject = { {
|
||||||
|
QMetaObject::SuperData::link<QObject::staticMetaObject>(),
|
||||||
|
qt_meta_stringdata_CPCANInterface.data,
|
||||||
|
qt_meta_data_CPCANInterface,
|
||||||
|
qt_static_metacall,
|
||||||
|
nullptr,
|
||||||
|
nullptr
|
||||||
|
} };
|
||||||
|
|
||||||
|
|
||||||
|
const QMetaObject *CPCANInterface::metaObject() const
|
||||||
|
{
|
||||||
|
return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *CPCANInterface::qt_metacast(const char *_clname)
|
||||||
|
{
|
||||||
|
if (!_clname) return nullptr;
|
||||||
|
if (!strcmp(_clname, qt_meta_stringdata_CPCANInterface.stringdata0))
|
||||||
|
return static_cast<void*>(this);
|
||||||
|
return QObject::qt_metacast(_clname);
|
||||||
|
}
|
||||||
|
|
||||||
|
int CPCANInterface::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
|
||||||
|
{
|
||||||
|
_id = QObject::qt_metacall(_c, _id, _a);
|
||||||
|
return _id;
|
||||||
|
}
|
||||||
|
QT_WARNING_POP
|
||||||
|
QT_END_MOC_NAMESPACE
|
||||||
Loading…
x
Reference in New Issue
Block a user