1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-29 07:24:13 +01:00

Some telemetry and HID work, few very ugly test hacks

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@471 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
sambas 2010-04-10 16:14:29 +00:00 committed by sambas
parent c15aba6b84
commit 5d1229311d
4 changed files with 32 additions and 10 deletions

View File

@ -10,8 +10,8 @@ SOURCES += main.cpp
include(../rpath.pri)
win32 {
CONFIG(debug, debug|release):LIBS *= -lExtensionSystemd -lAggregationd
else:LIBS *= -lExtensionSystem -lAggregation
CONFIG(debug, debug|release):LIBS *= -lExtensionSystemd -lAggregationd -lQExtSerialPortd
else:LIBS *= -lExtensionSystem -lAggregation -lQExtSerialPort
RC_FILE = openpilotgcs.rc
target.path = /bin

View File

@ -37,6 +37,8 @@
#include "fancytabwidget.h"
#include "fancyactionbar.h"
#include "mainwindow.h"
#include "qextserialport/src/qextserialenumerator.h"
#include "qextserialport/src/qextserialport.h"
#include <QDebug>
#include <QLabel>
@ -137,7 +139,23 @@ void ConnectionManager::onConnectPressed()
if(m_connectionDevice.connection)
{
QIODevice *ioDev = m_connectionDevice.connection->openDevice(m_connectionDevice.devName);
/*QextSerialPort *ioDev = new QextSerialPort("COM5");
ioDev->setBaudRate(BAUD57600);
ioDev->setFlowControl(FLOW_OFF);*/
ioDev->open(QIODevice::ReadWrite);
/*if(ioDev->isOpen())
ioDev->putChar('M');*/
QList<QextPortInfo> ports = QextSerialEnumerator::getPorts();
qDebug() << "List of ports:";
for (int i = 0; i < ports.size(); i++) {
qDebug() << "port name:" << ports.at(i).portName;
qDebug() << "friendly name:" << ports.at(i).friendName;
qDebug() << "physical name:" << ports.at(i).physName;
qDebug() << "enumerator name:" << ports.at(i).enumName;
qDebug() << "vendor ID:" << QString::number(ports.at(i).vendorID, 16);
qDebug() << "product ID:" << QString::number(ports.at(i).productID, 16);
qDebug() << "===================================";
}
if(ioDev)
{
emit deviceConnected(ioDev);

View File

@ -1,2 +1,3 @@
include(../../libs/extensionsystem/extensionsystem.pri)
include(../../libs/utils/utils.pri)
include(../../libs/qextserialport/qextserialport.pri)

View File

@ -36,7 +36,7 @@
#include <ddk/hidsdi.h>
#include <ddk/hidclass.h>
#define printf //qDebug
#define printf qDebug
typedef struct hid_struct hid_t;
struct hid_struct {
@ -167,7 +167,7 @@ int pjrc_rawhid::open(int max, int vid, int pid, int usage_page, int usage)
int pjrc_rawhid::receive(int num, void *buf, int len, int timeout)
{
hid_t *hid;
unsigned char tmpbuf[516];
unsigned char tmpbuf[516]={0};
OVERLAPPED ov;
DWORD n, r;
@ -213,11 +213,11 @@ return_error:
int pjrc_rawhid::send(int num, void *buf, int len, int timeout)
{
hid_t *hid;
unsigned char tmpbuf[516];
unsigned char tmpbuf[64]={0};
OVERLAPPED ov;
DWORD n, r;
if (sizeof(tmpbuf) < len + 1) return -1;
if (sizeof(tmpbuf) < (len + 1)) return -1;
hid = get_hid(num);
if (!hid || !hid->open) return -1;
EnterCriticalSection(&tx_mutex);
@ -226,7 +226,7 @@ int pjrc_rawhid::send(int num, void *buf, int len, int timeout)
ov.hEvent = tx_event;
tmpbuf[0] = 0;
memcpy(tmpbuf + 1, buf, len);
if (!WriteFile(hid->handle, tmpbuf, len + 1, NULL, &ov)) {
if (!WriteFile(hid->handle, tmpbuf, 64, NULL, &ov)) {
if (GetLastError() != ERROR_IO_PENDING) goto return_error;
r = WaitForSingleObject(tx_event, timeout);
if (r == WAIT_TIMEOUT) goto return_timeout;
@ -343,9 +343,12 @@ static void hid_close(hid_t *hid)
static void print_win32_err(void)
{
char buf[256];
char temp[256];
DWORD err;
err = GetLastError();
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, 0, (WCHAR*)buf, sizeof(buf), NULL);
printf("err %ld: %s\n", err, buf);
//FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, 0, (WCHAR*)buf, sizeof(buf), NULL);
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT), (WCHAR*)buf, sizeof(buf), NULL);
WideCharToMultiByte( CP_ACP, 0, (WCHAR*)buf, sizeof(buf), temp, sizeof(temp), NULL, NULL );
printf("err %ld: %s\n", err, temp);
}