mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-11-29 07:24:13 +01:00
Small host app for testing HID connectivity
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1184 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
7a10a77d4b
commit
e1f2f0264b
43
ground/src/experimental/HIDTest/HIDTest.pro
Normal file
43
ground/src/experimental/HIDTest/HIDTest.pro
Normal file
@ -0,0 +1,43 @@
|
||||
#-------------------------------------------------
|
||||
#
|
||||
# Project created by QtCreator 2010-07-24T11:26:38
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT += core
|
||||
|
||||
QT -= gui
|
||||
|
||||
TARGET = HIDTest
|
||||
CONFIG += console
|
||||
CONFIG -= app_bundle
|
||||
|
||||
TEMPLATE = app
|
||||
|
||||
SOURCES += main.cpp
|
||||
HEADERS += ../../plugins/rawhid/pjrc_rawhid.h
|
||||
|
||||
win32 {
|
||||
SOURCES += ../../plugins/rawhid/pjrc_rawhid_win.cpp
|
||||
LIBS += -lhid \
|
||||
-lsetupapi
|
||||
}
|
||||
macx {
|
||||
SOURCES += ../../plugins/rawhid/pjrc_rawhid_mac.cpp
|
||||
SDK = /Developer/SDKs/MacOSX10.5.sdk
|
||||
ARCH = -mmacosx-version-min=10.5 \
|
||||
-arch \
|
||||
ppc \
|
||||
-arch \
|
||||
i386
|
||||
LIBS += $(ARCH) \
|
||||
-Wl,-syslibroot,$(SDK) \
|
||||
-framework \
|
||||
IOKit \
|
||||
-framework \
|
||||
CoreFoundation
|
||||
}
|
||||
linux-g++ {
|
||||
SOURCES += ../../plugins/rawhid/pjrc_rawhid_unix.cpp
|
||||
LIBS += -lusb
|
||||
}
|
45
ground/src/experimental/HIDTest/main.cpp
Normal file
45
ground/src/experimental/HIDTest/main.cpp
Normal file
@ -0,0 +1,45 @@
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QThread>
|
||||
#include <../../plugins/rawhid/pjrc_rawhid.h>
|
||||
|
||||
#define BUF_LEN 64
|
||||
|
||||
class MyThread : public QThread {
|
||||
|
||||
public:
|
||||
|
||||
void run()
|
||||
{
|
||||
qDebug() << "Hello";
|
||||
pjrc_rawhid hidHandle;
|
||||
int numDevices = hidHandle.open(1,0x20a0,0x4117,0,0); //0xff9c,0x0001);
|
||||
if( numDevices == 0 )
|
||||
numDevices = hidHandle.open(1,0x0483,0,0,0);
|
||||
|
||||
qDebug() << numDevices << " device(s) opened";
|
||||
|
||||
//hidHandle.mytest(0);
|
||||
|
||||
char buf[BUF_LEN];
|
||||
buf[0] = 2;
|
||||
buf[1] = 0;
|
||||
int result = hidHandle.send(0,buf, BUF_LEN, 500);
|
||||
|
||||
qDebug() << result << " bytes sent";
|
||||
|
||||
int received = hidHandle.receive(0, buf, BUF_LEN, 3500);
|
||||
|
||||
qDebug() << received << " bytes received \"" << QString().toNum(buf[0]) << buf[1] << "\"";
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QCoreApplication a(argc, argv);
|
||||
MyThread b;
|
||||
b.start();
|
||||
|
||||
return a.exec();
|
||||
}
|
Loading…
Reference in New Issue
Block a user