mirror of https://github.com/EspoTek/Labrador.git
Shared Lib can handle basic avrDebug() call over USB.
This commit is contained in:
parent
eaaa4691bd
commit
a846895e53
|
@ -1,5 +1,8 @@
|
|||
#include "genericusbdriver.h"
|
||||
#include "platformspecific.h"
|
||||
|
||||
#ifndef LIBRADOR_LIBRARY
|
||||
#include "platformspecific.h"
|
||||
#endif
|
||||
|
||||
genericUsbDriver::genericUsbDriver(QWidget *parent) : QLabel(parent)
|
||||
{
|
||||
|
@ -194,9 +197,11 @@ void genericUsbDriver::newDig(int digState){
|
|||
usbSendControl(0x40, 0xa6, digState, 0, 0, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
void genericUsbDriver::setBufferPtr(bufferControl *newPtr){
|
||||
bufferPtr = newPtr;
|
||||
}
|
||||
*/
|
||||
|
||||
void genericUsbDriver::setDeviceMode(int mode){
|
||||
int oldMode = deviceMode;
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include "functiongencontrol.h"
|
||||
#include "xmega.h"
|
||||
#include "desktop_settings.h"
|
||||
#include "buffercontrol.h"
|
||||
//#include "buffercontrol.h"
|
||||
#include "unified_debug_structure.h"
|
||||
|
||||
#define EXPECTED_FIRMWARE_VERSION 0x0004
|
||||
|
@ -66,7 +66,7 @@ public:
|
|||
explicit genericUsbDriver(QWidget *parent = 0);
|
||||
~genericUsbDriver();
|
||||
virtual char *isoRead(unsigned int *newLength) = 0;
|
||||
void setBufferPtr(bufferControl *newPtr);
|
||||
//void setBufferPtr(bufferControl *newPtr);
|
||||
void saveState(int *_out_deviceMode, double *_out_scopeGain, double *_out_currentPsuVoltage, int *_out_digitalPinState);
|
||||
virtual void usbSendControl(uint8_t RequestType, uint8_t Request, uint16_t Value, uint16_t Index, uint16_t Length, unsigned char *LDATA) = 0;
|
||||
virtual void manualFirmwareRecovery(void) = 0;
|
||||
|
@ -81,7 +81,7 @@ protected:
|
|||
unsigned char firmver = 0;
|
||||
unsigned char variant = 0;
|
||||
//Generic Vars
|
||||
bufferControl *bufferPtr = NULL;
|
||||
//bufferControl *bufferPtr = NULL;
|
||||
QTimer *psuTimer;
|
||||
unsigned char pipeID[3];
|
||||
QTimer *isoTimer;
|
||||
|
|
|
@ -24,7 +24,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
|
||||
ui->timeBaseSlider->setMaximum(10*log10(MAX_WINDOW_SIZE));
|
||||
|
||||
ui->controller_iso->driver->setBufferPtr(ui->bufferDisplay);
|
||||
//ui->controller_iso->driver->setBufferPtr(ui->bufferDisplay);
|
||||
ui->cursorStatsLabel->hide();
|
||||
initialisePlot();
|
||||
menuSetup();
|
||||
|
@ -1239,7 +1239,7 @@ void MainWindow::reinitUsbStage2(void){
|
|||
ui->controller_iso->driver = new _PLATFORM_DEPENDENT_USB_OBJECT();
|
||||
|
||||
//Reconnect the other objects.
|
||||
ui->controller_iso->driver->setBufferPtr(ui->bufferDisplay);
|
||||
//ui->controller_iso->driver->setBufferPtr(ui->bufferDisplay);
|
||||
connect(ui->debugButton1, SIGNAL(clicked()), ui->controller_iso->driver, SLOT(avrDebug()));
|
||||
connect(ui->debugButton3, SIGNAL(clicked()), ui->controller_iso->driver, SLOT(bootloaderJump()));
|
||||
connect(ui->psuSlider, SIGNAL(voltageChanged(double)), ui->controller_iso->driver, SLOT(setPsu(double)));
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "unixusbdriver.h"
|
||||
#include "platformspecific.h"
|
||||
#ifndef LIBRADOR_LIBRARY
|
||||
#include "platformspecific.h"
|
||||
#endif
|
||||
#include <QApplication>
|
||||
#include <QMessageBox>
|
||||
|
||||
|
|
|
@ -12,10 +12,10 @@ MAKEFILE = Makefile
|
|||
|
||||
CC = gcc
|
||||
CXX = g++
|
||||
DEFINES = -DQT_DEPRECATED_WARNINGS -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB
|
||||
DEFINES = -DQT_DEPRECATED_WARNINGS -DPLATFORM_LINUX -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB
|
||||
CFLAGS = -pipe -O2 -Wall -W -D_REENTRANT -fPIC $(DEFINES)
|
||||
CXXFLAGS = -pipe -O2 -std=gnu++11 -Wall -W -D_REENTRANT -fPIC $(DEFINES)
|
||||
INCPATH = -I. -I../../librador -I/home/esposch/Qt/5.10.0/gcc_64/include -I/home/esposch/Qt/5.10.0/gcc_64/include/QtWidgets -I/home/esposch/Qt/5.10.0/gcc_64/include/QtGui -I/home/esposch/Qt/5.10.0/gcc_64/include/QtCore -I. -isystem /usr/include/libdrm -I. -I/home/esposch/Qt/5.10.0/gcc_64/mkspecs/linux-g++
|
||||
INCPATH = -I. -I../../librador -I../../../Desktop_Interface/build_linux/libusb -I../../../Desktop_Interface/build_linux/libdfuprog/include -I/home/esposch/Qt/5.10.0/gcc_64/include -I/home/esposch/Qt/5.10.0/gcc_64/include/QtWidgets -I/home/esposch/Qt/5.10.0/gcc_64/include/QtGui -I/home/esposch/Qt/5.10.0/gcc_64/include/QtCore -I. -isystem /usr/include/libdrm -I. -I/home/esposch/Qt/5.10.0/gcc_64/mkspecs/linux-g++
|
||||
QMAKE = /home/esposch/Qt/5.10.0/gcc_64/bin/qmake
|
||||
DEL_FILE = rm -f
|
||||
CHK_DIR_EXISTS= test -d
|
||||
|
@ -38,7 +38,7 @@ DISTNAME = librademo1.0.0
|
|||
DISTDIR = /home/esposch/Git/Labrador/Matlab_Octave_API/___librador/demo/librademo/.tmp/librademo1.0.0
|
||||
LINK = g++
|
||||
LFLAGS = -Wl,-O1 -Wl,-rpath,/home/esposch/Qt/5.10.0/gcc_64/lib
|
||||
LIBS = $(SUBLIBS) -L../../librador/ -lrador -L/home/esposch/Qt/5.10.0/gcc_64/lib -lQt5Widgets -lQt5Gui -lQt5Core -lGL -lpthread
|
||||
LIBS = $(SUBLIBS) -L../../librador/ -lrador -L../../../Desktop_Interface/build_linux/libusb -lusb-1.0 -L../../../Desktop_Interface/build_linux/libdfuprog/lib/x64 -ldfuprog-0.9 -L/home/esposch/Qt/5.10.0/gcc_64/lib -lQt5Widgets -lQt5Gui -lQt5Core -lGL -lpthread
|
||||
AR = ar cqs
|
||||
RANLIB =
|
||||
SED = sed
|
||||
|
@ -784,7 +784,7 @@ moc_mainwindow.cpp: /home/esposch/Qt/5.10.0/gcc_64/include/QtWidgets/QMainWindow
|
|||
mainwindow.h \
|
||||
moc_predefs.h \
|
||||
/home/esposch/Qt/5.10.0/gcc_64/bin/moc
|
||||
/home/esposch/Qt/5.10.0/gcc_64/bin/moc $(DEFINES) --include ./moc_predefs.h -I/home/esposch/Qt/5.10.0/gcc_64/mkspecs/linux-g++ -I/home/esposch/Git/Labrador/Matlab_Octave_API/___librador/demo/librademo -I/home/esposch/Git/Labrador/Matlab_Octave_API/___librador/librador -I/home/esposch/Qt/5.10.0/gcc_64/include -I/home/esposch/Qt/5.10.0/gcc_64/include/QtWidgets -I/home/esposch/Qt/5.10.0/gcc_64/include/QtGui -I/home/esposch/Qt/5.10.0/gcc_64/include/QtCore -I/usr/include/c++/5 -I/usr/include/x86_64-linux-gnu/c++/5 -I/usr/include/c++/5/backward -I/usr/lib/gcc/x86_64-linux-gnu/5/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include mainwindow.h -o moc_mainwindow.cpp
|
||||
/home/esposch/Qt/5.10.0/gcc_64/bin/moc $(DEFINES) --include ./moc_predefs.h -I/home/esposch/Qt/5.10.0/gcc_64/mkspecs/linux-g++ -I/home/esposch/Git/Labrador/Matlab_Octave_API/___librador/demo/librademo -I/home/esposch/Git/Labrador/Matlab_Octave_API/___librador/librador -I/home/esposch/Git/Labrador/Matlab_Octave_API/Desktop_Interface/build_linux/libusb -I/home/esposch/Git/Labrador/Matlab_Octave_API/Desktop_Interface/build_linux/libdfuprog/include -I/home/esposch/Qt/5.10.0/gcc_64/include -I/home/esposch/Qt/5.10.0/gcc_64/include/QtWidgets -I/home/esposch/Qt/5.10.0/gcc_64/include/QtGui -I/home/esposch/Qt/5.10.0/gcc_64/include/QtCore -I/usr/include/c++/5 -I/usr/include/x86_64-linux-gnu/c++/5 -I/usr/include/c++/5/backward -I/usr/lib/gcc/x86_64-linux-gnu/5/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include mainwindow.h -o moc_mainwindow.cpp
|
||||
|
||||
compiler_moc_objc_header_make_all:
|
||||
compiler_moc_objc_header_clean:
|
||||
|
@ -1030,7 +1030,10 @@ mainwindow.o: mainwindow.cpp mainwindow.h \
|
|||
/home/esposch/Qt/5.10.0/gcc_64/include/QtGui/qtouchdevice.h \
|
||||
/home/esposch/Qt/5.10.0/gcc_64/include/QtWidgets/qtabwidget.h \
|
||||
/home/esposch/Qt/5.10.0/gcc_64/include/QtGui/qicon.h \
|
||||
ui_mainwindow.h
|
||||
ui_mainwindow.h \
|
||||
../../librador/librador.h \
|
||||
../../librador/librador_global.h \
|
||||
/home/esposch/Qt/5.10.0/gcc_64/include/QtCore/QDebug
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o mainwindow.o mainwindow.cpp
|
||||
|
||||
moc_mainwindow.o: moc_mainwindow.cpp
|
||||
|
|
Binary file not shown.
|
@ -37,3 +37,20 @@ FORMS += \
|
|||
unix:LIBS += -L../../librador/ -lrador
|
||||
unix:INCLUDEPATH += ../../librador
|
||||
unix:DEPENDPATH += ../../librador
|
||||
|
||||
unix:!android:!macx {
|
||||
#libusb include
|
||||
LIBS += -L../../../Desktop_Interface/build_linux/libusb -lusb-1.0 ##I suspect the -L here does nothing!
|
||||
INCLUDEPATH += ../../../Desktop_Interface/build_linux/libusb
|
||||
DEPENDPATH += ../../../Desktop_Interface/build_linux/libusb
|
||||
|
||||
#libdfuprog include
|
||||
LIBS += -L../../../Desktop_Interface/build_linux/libdfuprog/lib/x64 -ldfuprog-0.9
|
||||
INCLUDEPATH += ../../../Desktop_Interface/build_linux/libdfuprog/include
|
||||
DEPENDPATH += ../../../Desktop_Interface/build_linux/libdfuprog/include
|
||||
|
||||
#linux defines
|
||||
DEFINES += \
|
||||
PLATFORM_LINUX \
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,8 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
ui(new Ui::MainWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setbuf(stdout, 0);
|
||||
setbuf(stderr, 0);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
|
@ -24,3 +26,13 @@ void MainWindow::on_pushButton_2_clicked()
|
|||
{
|
||||
qDebug() << librador_exit();
|
||||
}
|
||||
|
||||
void MainWindow::on_pushButton_3_clicked()
|
||||
{
|
||||
qDebug() << librador_setup_usb();
|
||||
}
|
||||
|
||||
void MainWindow::on_pushButton_4_clicked()
|
||||
{
|
||||
qDebug() << librador_avr_debug();
|
||||
}
|
||||
|
|
|
@ -19,6 +19,10 @@ private slots:
|
|||
|
||||
void on_pushButton_2_clicked();
|
||||
|
||||
void on_pushButton_3_clicked();
|
||||
|
||||
void on_pushButton_4_clicked();
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
};
|
||||
|
|
|
@ -29,6 +29,20 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_3">
|
||||
<property name="text">
|
||||
<string>Setup USB</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_4">
|
||||
<property name="text">
|
||||
<string>avrDebug()</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menuBar">
|
||||
|
|
|
@ -21,8 +21,8 @@ QT_BEGIN_MOC_NAMESPACE
|
|||
QT_WARNING_PUSH
|
||||
QT_WARNING_DISABLE_DEPRECATED
|
||||
struct qt_meta_stringdata_MainWindow_t {
|
||||
QByteArrayData data[4];
|
||||
char stringdata0[58];
|
||||
QByteArrayData data[6];
|
||||
char stringdata0[106];
|
||||
};
|
||||
#define QT_MOC_LITERAL(idx, ofs, len) \
|
||||
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
|
||||
|
@ -34,11 +34,14 @@ static const qt_meta_stringdata_MainWindow_t qt_meta_stringdata_MainWindow = {
|
|||
QT_MOC_LITERAL(0, 0, 10), // "MainWindow"
|
||||
QT_MOC_LITERAL(1, 11, 21), // "on_pushButton_clicked"
|
||||
QT_MOC_LITERAL(2, 33, 0), // ""
|
||||
QT_MOC_LITERAL(3, 34, 23) // "on_pushButton_2_clicked"
|
||||
QT_MOC_LITERAL(3, 34, 23), // "on_pushButton_2_clicked"
|
||||
QT_MOC_LITERAL(4, 58, 23), // "on_pushButton_3_clicked"
|
||||
QT_MOC_LITERAL(5, 82, 23) // "on_pushButton_4_clicked"
|
||||
|
||||
},
|
||||
"MainWindow\0on_pushButton_clicked\0\0"
|
||||
"on_pushButton_2_clicked"
|
||||
"on_pushButton_2_clicked\0on_pushButton_3_clicked\0"
|
||||
"on_pushButton_4_clicked"
|
||||
};
|
||||
#undef QT_MOC_LITERAL
|
||||
|
||||
|
@ -48,7 +51,7 @@ static const uint qt_meta_data_MainWindow[] = {
|
|||
7, // revision
|
||||
0, // classname
|
||||
0, 0, // classinfo
|
||||
2, 14, // methods
|
||||
4, 14, // methods
|
||||
0, 0, // properties
|
||||
0, 0, // enums/sets
|
||||
0, 0, // constructors
|
||||
|
@ -56,10 +59,14 @@ static const uint qt_meta_data_MainWindow[] = {
|
|||
0, // signalCount
|
||||
|
||||
// slots: name, argc, parameters, tag, flags
|
||||
1, 0, 24, 2, 0x08 /* Private */,
|
||||
3, 0, 25, 2, 0x08 /* Private */,
|
||||
1, 0, 34, 2, 0x08 /* Private */,
|
||||
3, 0, 35, 2, 0x08 /* Private */,
|
||||
4, 0, 36, 2, 0x08 /* Private */,
|
||||
5, 0, 37, 2, 0x08 /* Private */,
|
||||
|
||||
// slots: parameters
|
||||
QMetaType::Void,
|
||||
QMetaType::Void,
|
||||
QMetaType::Void,
|
||||
QMetaType::Void,
|
||||
|
||||
|
@ -74,6 +81,8 @@ void MainWindow::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id,
|
|||
switch (_id) {
|
||||
case 0: _t->on_pushButton_clicked(); break;
|
||||
case 1: _t->on_pushButton_2_clicked(); break;
|
||||
case 2: _t->on_pushButton_3_clicked(); break;
|
||||
case 3: _t->on_pushButton_4_clicked(); break;
|
||||
default: ;
|
||||
}
|
||||
}
|
||||
|
@ -105,13 +114,13 @@ int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
|
|||
if (_id < 0)
|
||||
return _id;
|
||||
if (_c == QMetaObject::InvokeMetaMethod) {
|
||||
if (_id < 2)
|
||||
if (_id < 4)
|
||||
qt_static_metacall(this, _c, _id, _a);
|
||||
_id -= 2;
|
||||
_id -= 4;
|
||||
} else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
|
||||
if (_id < 2)
|
||||
if (_id < 4)
|
||||
*reinterpret_cast<int*>(_a[0]) = -1;
|
||||
_id -= 2;
|
||||
_id -= 4;
|
||||
}
|
||||
return _id;
|
||||
}
|
||||
|
|
|
@ -31,6 +31,8 @@ public:
|
|||
QVBoxLayout *verticalLayout;
|
||||
QPushButton *pushButton;
|
||||
QPushButton *pushButton_2;
|
||||
QPushButton *pushButton_3;
|
||||
QPushButton *pushButton_4;
|
||||
QMenuBar *menuBar;
|
||||
QToolBar *mainToolBar;
|
||||
QStatusBar *statusBar;
|
||||
|
@ -56,6 +58,16 @@ public:
|
|||
|
||||
verticalLayout->addWidget(pushButton_2);
|
||||
|
||||
pushButton_3 = new QPushButton(centralWidget);
|
||||
pushButton_3->setObjectName(QStringLiteral("pushButton_3"));
|
||||
|
||||
verticalLayout->addWidget(pushButton_3);
|
||||
|
||||
pushButton_4 = new QPushButton(centralWidget);
|
||||
pushButton_4->setObjectName(QStringLiteral("pushButton_4"));
|
||||
|
||||
verticalLayout->addWidget(pushButton_4);
|
||||
|
||||
MainWindow->setCentralWidget(centralWidget);
|
||||
menuBar = new QMenuBar(MainWindow);
|
||||
menuBar->setObjectName(QStringLiteral("menuBar"));
|
||||
|
@ -78,6 +90,8 @@ public:
|
|||
MainWindow->setWindowTitle(QApplication::translate("MainWindow", "MainWindow", nullptr));
|
||||
pushButton->setText(QApplication::translate("MainWindow", "Open API", nullptr));
|
||||
pushButton_2->setText(QApplication::translate("MainWindow", "Close API", nullptr));
|
||||
pushButton_3->setText(QApplication::translate("MainWindow", "Setup USB", nullptr));
|
||||
pushButton_4->setText(QApplication::translate("MainWindow", "avrDebug()", nullptr));
|
||||
} // retranslateUi
|
||||
|
||||
};
|
||||
|
|
|
@ -12,10 +12,10 @@ MAKEFILE = Makefile
|
|||
|
||||
CC = gcc
|
||||
CXX = g++
|
||||
DEFINES = -DLIBRADOR_LIBRARY -DQT_DEPRECATED_WARNINGS -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB
|
||||
DEFINES = -DLIBRADOR_LIBRARY -DQT_DEPRECATED_WARNINGS -DPLATFORM_LINUX -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB
|
||||
CFLAGS = -pipe -O2 -Wall -W -D_REENTRANT -fPIC $(DEFINES)
|
||||
CXXFLAGS = -pipe -O2 -std=gnu++11 -Wall -W -D_REENTRANT -fPIC $(DEFINES)
|
||||
INCPATH = -I. -I/home/esposch/Qt/5.10.0/gcc_64/include -I/home/esposch/Qt/5.10.0/gcc_64/include/QtWidgets -I/home/esposch/Qt/5.10.0/gcc_64/include/QtGui -I/home/esposch/Qt/5.10.0/gcc_64/include/QtCore -I. -isystem /usr/include/libdrm -I/home/esposch/Qt/5.10.0/gcc_64/mkspecs/linux-g++
|
||||
INCPATH = -I. -I../../../Desktop_Interface -I../../../Desktop_Interface/build_linux/libusb -I../../../Desktop_Interface/build_linux/libdfuprog/include -I/home/esposch/Qt/5.10.0/gcc_64/include -I/home/esposch/Qt/5.10.0/gcc_64/include/QtWidgets -I/home/esposch/Qt/5.10.0/gcc_64/include/QtGui -I/home/esposch/Qt/5.10.0/gcc_64/include/QtCore -I. -isystem /usr/include/libdrm -I/home/esposch/Qt/5.10.0/gcc_64/mkspecs/linux-g++
|
||||
QMAKE = /home/esposch/Qt/5.10.0/gcc_64/bin/qmake
|
||||
DEL_FILE = rm -f
|
||||
CHK_DIR_EXISTS= test -d
|
||||
|
@ -38,7 +38,7 @@ DISTNAME = rador1.0.0
|
|||
DISTDIR = /home/esposch/Git/Labrador/Matlab_Octave_API/___librador/librador/.tmp/rador1.0.0
|
||||
LINK = g++
|
||||
LFLAGS = -Wl,-O1 -Wl,-rpath,/home/esposch/Qt/5.10.0/gcc_64/lib -shared -Wl,-soname,librador.so.1
|
||||
LIBS = $(SUBLIBS) -L/home/esposch/Qt/5.10.0/gcc_64/lib -lQt5Widgets -lQt5Gui -lQt5Core -lGL -lpthread
|
||||
LIBS = $(SUBLIBS) -L../../../Desktop_Interface/build_linux/libusb -lusb-1.0 -L../../../Desktop_Interface/build_linux/libdfuprog/lib/x64 -ldfuprog-0.9 -L/home/esposch/Qt/5.10.0/gcc_64/lib -lQt5Widgets -lQt5Gui -lQt5Core -lGL -lpthread
|
||||
AR = ar cqs
|
||||
RANLIB =
|
||||
SED = sed
|
||||
|
@ -50,8 +50,10 @@ OBJECTS_DIR = ./
|
|||
|
||||
####### Files
|
||||
|
||||
SOURCES = librador.cpp
|
||||
OBJECTS = librador.o
|
||||
SOURCES = librador.cpp \
|
||||
usbcallhandler.cpp
|
||||
OBJECTS = librador.o \
|
||||
usbcallhandler.o
|
||||
DIST = /home/esposch/Qt/5.10.0/gcc_64/mkspecs/features/spec_pre.prf \
|
||||
/home/esposch/Qt/5.10.0/gcc_64/mkspecs/common/unix.conf \
|
||||
/home/esposch/Qt/5.10.0/gcc_64/mkspecs/common/linux.conf \
|
||||
|
@ -236,7 +238,9 @@ DIST = /home/esposch/Qt/5.10.0/gcc_64/mkspecs/features/spec_pre.prf \
|
|||
/home/esposch/Qt/5.10.0/gcc_64/mkspecs/features/lex.prf \
|
||||
librador.pro librador.h \
|
||||
librador_global.h \
|
||||
librador_internal.h librador.cpp
|
||||
librador_internal.h \
|
||||
usbcallhandler.h librador.cpp \
|
||||
usbcallhandler.cpp
|
||||
QMAKE_TARGET = rador
|
||||
DESTDIR =
|
||||
TARGET = librador.so.1.0.0
|
||||
|
@ -653,8 +657,8 @@ distdir: FORCE
|
|||
@test -d $(DISTDIR) || mkdir -p $(DISTDIR)
|
||||
$(COPY_FILE) --parents $(DIST) $(DISTDIR)/
|
||||
$(COPY_FILE) --parents /home/esposch/Qt/5.10.0/gcc_64/mkspecs/features/data/dummy.cpp $(DISTDIR)/
|
||||
$(COPY_FILE) --parents librador.h librador_global.h librador_internal.h $(DISTDIR)/
|
||||
$(COPY_FILE) --parents librador.cpp $(DISTDIR)/
|
||||
$(COPY_FILE) --parents librador.h librador_global.h librador_internal.h usbcallhandler.h $(DISTDIR)/
|
||||
$(COPY_FILE) --parents librador.cpp usbcallhandler.cpp $(DISTDIR)/
|
||||
|
||||
|
||||
clean: compiler_clean
|
||||
|
@ -728,9 +732,15 @@ librador.o: librador.cpp librador.h \
|
|||
/home/esposch/Qt/5.10.0/gcc_64/include/QtCore/qmutex.h \
|
||||
/home/esposch/Qt/5.10.0/gcc_64/include/QtCore/qnumeric.h \
|
||||
/home/esposch/Qt/5.10.0/gcc_64/include/QtCore/qversiontagging.h \
|
||||
librador_internal.h
|
||||
librador_internal.h \
|
||||
usbcallhandler.h \
|
||||
../../../Desktop_Interface/build_linux/libusb/libusb.h
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o librador.o librador.cpp
|
||||
|
||||
usbcallhandler.o: usbcallhandler.cpp usbcallhandler.h \
|
||||
../../../Desktop_Interface/build_linux/libusb/libusb.h
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o usbcallhandler.o usbcallhandler.cpp
|
||||
|
||||
####### Install
|
||||
|
||||
install_target: first FORCE
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
#include "librador.h"
|
||||
#include "librador_internal.h"
|
||||
#include "usbcallhandler.h"
|
||||
|
||||
Librador::Librador()
|
||||
{
|
||||
usb_driver = new usbCallHandler(LABRADOR_VID, LABRADOR_PID);
|
||||
}
|
||||
|
||||
int librador_init(){
|
||||
|
@ -22,6 +24,7 @@ int librador_init(){
|
|||
}
|
||||
|
||||
int librador_exit(){
|
||||
CHECK_API_INITIALISED
|
||||
if(internal_librador_object == NULL){
|
||||
//Object not yet initialised
|
||||
return 1;
|
||||
|
@ -32,3 +35,24 @@ int librador_exit(){
|
|||
//Object deleted
|
||||
return 0;
|
||||
}
|
||||
|
||||
int librador_setup_usb(){
|
||||
CHECK_API_INITIALISED
|
||||
int error;
|
||||
//Setup USB for Control (EP0) transfers.
|
||||
error = internal_librador_object->usb_driver->setup_usb_control();
|
||||
if(error < 0){
|
||||
return error;
|
||||
}
|
||||
//Setup USB for Isochronous transfers.
|
||||
error = internal_librador_object->usb_driver->setup_usb_iso();
|
||||
if(error < 0){
|
||||
return error - 1000;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int librador_avr_debug(){
|
||||
CHECK_API_INITIALISED
|
||||
return internal_librador_object->usb_driver->avrDebug();
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
int LIBRADORSHARED_EXPORT librador_init();
|
||||
int LIBRADORSHARED_EXPORT librador_exit();
|
||||
|
||||
int LIBRADORSHARED_EXPORT librador_setup_usb();
|
||||
int LIBRADORSHARED_EXPORT librador_avr_debug();
|
||||
|
||||
#endif // LIBRADOR_H
|
||||
|
|
|
@ -24,15 +24,38 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
|||
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
||||
#Include Labrador Sources
|
||||
INCLUDEPATH += ../../../Desktop_Interface
|
||||
DEPENDPATH += ../../../Desktop_Interface
|
||||
|
||||
SOURCES += \
|
||||
librador.cpp
|
||||
librador.cpp \
|
||||
usbcallhandler.cpp
|
||||
|
||||
HEADERS += \
|
||||
librador.h \
|
||||
librador_global.h \
|
||||
librador_internal.h
|
||||
librador_internal.h \
|
||||
usbcallhandler.h
|
||||
|
||||
unix {
|
||||
target.path = /usr/lib
|
||||
INSTALLS += target
|
||||
}
|
||||
|
||||
unix:!android:!macx {
|
||||
#libusb include
|
||||
LIBS += -L../../../Desktop_Interface/build_linux/libusb -lusb-1.0 ##I suspect the -L here does nothing!
|
||||
INCLUDEPATH += ../../../Desktop_Interface/build_linux/libusb
|
||||
DEPENDPATH += ../../../Desktop_Interface/build_linux/libusb
|
||||
|
||||
#libdfuprog include
|
||||
LIBS += -L../../../Desktop_Interface/build_linux/libdfuprog/lib/x64 -ldfuprog-0.9
|
||||
INCLUDEPATH += ../../../Desktop_Interface/build_linux/libdfuprog/include
|
||||
DEPENDPATH += ../../../Desktop_Interface/build_linux/libdfuprog/include
|
||||
|
||||
#linux defines
|
||||
DEFINES += \
|
||||
PLATFORM_LINUX \
|
||||
}
|
||||
|
||||
|
|
|
@ -3,11 +3,19 @@
|
|||
|
||||
#endif // LIBRADOR_INTERNAL_H
|
||||
|
||||
#define LABRADOR_VID 0x03eb
|
||||
#define LABRADOR_PID 0xba94
|
||||
|
||||
#define CHECK_API_INITIALISED if(internal_librador_object == NULL) return -420;
|
||||
|
||||
class usbCallHandler;
|
||||
|
||||
class Librador
|
||||
{
|
||||
|
||||
public:
|
||||
Librador();
|
||||
usbCallHandler *usb_driver = NULL;
|
||||
};
|
||||
|
||||
Librador *internal_librador_object = NULL;
|
||||
|
|
|
@ -0,0 +1,117 @@
|
|||
#include "usbcallhandler.h"
|
||||
#include <stdio.h>
|
||||
|
||||
usbCallHandler::usbCallHandler(unsigned short VID_in, unsigned short PID_in)
|
||||
{
|
||||
VID = VID_in;
|
||||
PID = PID_in;
|
||||
}
|
||||
|
||||
|
||||
int usbCallHandler::setup_usb_control(){
|
||||
printf("usbCallHandler::setup_usb_control()\n");
|
||||
|
||||
if(ctx != NULL){
|
||||
printf("There is already a libusb context!\n");
|
||||
return 1;
|
||||
} else printf("libusb context is null\n");
|
||||
|
||||
//Initialise the Library
|
||||
int error;
|
||||
error = libusb_init(&ctx);
|
||||
if(error){
|
||||
printf("libusb_init FAILED\n");
|
||||
return -1;
|
||||
} else printf("Libusb context initialised\n");
|
||||
libusb_set_debug(ctx, 3);
|
||||
|
||||
//Get a handle on the Labrador device
|
||||
handle = libusb_open_device_with_vid_pid(ctx, VID, PID);
|
||||
if(handle==NULL){
|
||||
printf("DEVICE NOT FOUND\n");
|
||||
libusb_exit(ctx);
|
||||
ctx = NULL;
|
||||
return -2;
|
||||
}
|
||||
printf("Device found!!\n");
|
||||
|
||||
//Claim the interface
|
||||
error = libusb_claim_interface(handle, 0);
|
||||
if(error){
|
||||
printf("libusb_claim_interface FAILED\n");
|
||||
libusb_close(handle);
|
||||
handle = NULL;
|
||||
return -3;
|
||||
} else printf("Interface claimed!\n");
|
||||
|
||||
connected = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int usbCallHandler::setup_usb_iso(){
|
||||
return 0;
|
||||
}
|
||||
|
||||
int usbCallHandler::send_control_transfer(uint8_t RequestType, uint8_t Request, uint16_t Value, uint16_t Index, uint16_t Length, unsigned char *LDATA){
|
||||
unsigned char *controlBuffer;
|
||||
|
||||
if(!connected){
|
||||
printf("Control packet requested before device has connected!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (LDATA==NULL){
|
||||
controlBuffer = inBuffer;
|
||||
}
|
||||
else controlBuffer = LDATA;
|
||||
|
||||
int error = libusb_control_transfer(handle, RequestType, Request, Value, Index, controlBuffer, Length, 4000);
|
||||
if(error<0){
|
||||
printf("unixUsbDriver::usbSendControl FAILED with error %s", libusb_error_name(error));
|
||||
return error - 100;
|
||||
}
|
||||
/*
|
||||
if((error == LIBUSB_ERROR_NO_DEVICE) && (Request!=0xa7)){ //Bootloader Jump won't return; this is expected behaviour.
|
||||
printf("Device not found. Becoming an hero.");
|
||||
connectedStatus(false);
|
||||
killMe();
|
||||
}
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int usbCallHandler::avrDebug(void){
|
||||
int error;
|
||||
error = send_control_transfer(0xc0, 0xa0, 0, 0, sizeof(unified_debug), NULL);
|
||||
|
||||
if (error < 0){
|
||||
return error;
|
||||
}
|
||||
|
||||
printf("unified debug is of size %d\n", sizeof(unified_debug));
|
||||
|
||||
unified_debug *udsPtr = (unified_debug *) inBuffer;
|
||||
uint16_t trfcnt0 = (udsPtr->trfcntH0 << 8) + udsPtr->trfcntL0;
|
||||
uint16_t trfcnt1 = (udsPtr->trfcntH1 << 8) + udsPtr->trfcntL1;
|
||||
uint16_t medianTrfcnt = (udsPtr->medianTrfcntH << 8) + udsPtr->medianTrfcntL;
|
||||
uint16_t outOfRange = (udsPtr->outOfRangeH << 8) + udsPtr->outOfRangeL;
|
||||
uint16_t counter = (udsPtr->counterH << 8) + udsPtr->counterL;
|
||||
uint16_t dma_ch0_cnt = (udsPtr->dma_ch0_cntH << 8) + udsPtr->dma_ch0_cntL;
|
||||
uint16_t dma_ch1_cnt = (udsPtr->dma_ch1_cntH << 8) + udsPtr->dma_ch1_cntL;
|
||||
|
||||
printf("%s", udsPtr->header);
|
||||
printf("trfcnt0 = %d\n", trfcnt0);
|
||||
printf("trfcnt1 = %d\n", trfcnt1);
|
||||
printf("medianTrfcnt = %d\n", medianTrfcnt);
|
||||
printf("outOfRange = %d\n", outOfRange);
|
||||
printf("counter = %d\n", counter);
|
||||
printf("calValNeg = %d\n", udsPtr->calValNeg);
|
||||
printf("calValPos = %d\n", udsPtr->calValPos);
|
||||
printf("CALA = %d\n", udsPtr->CALA);
|
||||
printf("CALB = %d\n", udsPtr->CALB);
|
||||
printf("dma_ch0_cnt = %d\n", dma_ch0_cnt);
|
||||
printf("dma_ch1_cnt = %d\n", dma_ch1_cnt);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
#ifndef USBCALLHANDLER_H
|
||||
#define USBCALLHANDLER_H
|
||||
|
||||
#include "libusb.h"
|
||||
|
||||
//EVERYTHING MUST BE SENT ONE BYTE AT A TIME, HIGH AND LOW BYTES SEPARATE, IN ORDER TO AVOID ISSUES WITH ENDIANNESS.
|
||||
typedef struct uds{
|
||||
volatile char header[9];
|
||||
volatile uint8_t trfcntL0;
|
||||
volatile uint8_t trfcntH0;
|
||||
volatile uint8_t trfcntL1;
|
||||
volatile uint8_t trfcntH1;
|
||||
volatile uint8_t medianTrfcntL;
|
||||
volatile uint8_t medianTrfcntH;
|
||||
volatile uint8_t calValNeg;
|
||||
volatile uint8_t calValPos;
|
||||
volatile uint8_t CALA;
|
||||
volatile uint8_t CALB;
|
||||
volatile uint8_t outOfRangeL;
|
||||
volatile uint8_t outOfRangeH;
|
||||
volatile uint8_t counterL;
|
||||
volatile uint8_t counterH;
|
||||
volatile uint8_t dma_ch0_cntL;
|
||||
volatile uint8_t dma_ch0_cntH;
|
||||
volatile uint8_t dma_ch1_cntL;
|
||||
volatile uint8_t dma_ch1_cntH;
|
||||
|
||||
} unified_debug;
|
||||
|
||||
class usbCallHandler
|
||||
{
|
||||
public:
|
||||
usbCallHandler(unsigned short VID_in, unsigned short PID_in);
|
||||
int setup_usb_control();
|
||||
int setup_usb_iso();
|
||||
int send_control_transfer(uint8_t RequestType, uint8_t Request, uint16_t Value, uint16_t Index, uint16_t Length, unsigned char *LDATA);
|
||||
int avrDebug(void);
|
||||
bool connected;
|
||||
private:
|
||||
unsigned short VID, PID;
|
||||
libusb_context *ctx = NULL;
|
||||
libusb_device_handle *handle = NULL;
|
||||
unsigned char inBuffer[256];
|
||||
};
|
||||
|
||||
#endif // USBCALLHANDLER_H
|
Loading…
Reference in New Issue