mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-03-02 19:29:15 +01:00
Merge remote branch 'origin/next' into next
This commit is contained in:
commit
99fcf9274f
@ -1,5 +1,12 @@
|
|||||||
Short summary of changes. For a complete list see the git log.
|
Short summary of changes. For a complete list see the git log.
|
||||||
|
|
||||||
|
2011-10-11
|
||||||
|
Fix for the Mac telemetry rates and specifically how long enumeration took.
|
||||||
|
|
||||||
|
2011-10-08
|
||||||
|
Make the flash chip need to be have bad magic for a full second before erasing
|
||||||
|
settings. Should avoid random lost settings.
|
||||||
|
|
||||||
2011-09-12
|
2011-09-12
|
||||||
Max rate now ONLY applies to attitude and axis lock mode. Manual rate is the
|
Max rate now ONLY applies to attitude and axis lock mode. Manual rate is the
|
||||||
only term that limits the rate mode now (and in axis lock when you push stick
|
only term that limits the rate mode now (and in axis lock when you push stick
|
||||||
|
@ -37,7 +37,6 @@
|
|||||||
|
|
||||||
#if defined( Q_OS_MAC)
|
#if defined( Q_OS_MAC)
|
||||||
|
|
||||||
// todo:
|
|
||||||
|
|
||||||
#elif defined(Q_OS_UNIX)
|
#elif defined(Q_OS_UNIX)
|
||||||
//#elif defined(Q_OS_LINUX)
|
//#elif defined(Q_OS_LINUX)
|
||||||
@ -104,10 +103,12 @@ public:
|
|||||||
void mytest(int num);
|
void mytest(int num);
|
||||||
signals:
|
signals:
|
||||||
void deviceUnplugged(int);//just to make pips changes compile
|
void deviceUnplugged(int);//just to make pips changes compile
|
||||||
private:
|
|
||||||
#if defined( Q_OS_MAC)
|
#if defined( Q_OS_MAC)
|
||||||
|
|
||||||
// todo:
|
#endif
|
||||||
|
|
||||||
|
private:
|
||||||
|
#if defined( Q_OS_MAC)
|
||||||
|
|
||||||
#elif defined(Q_OS_UNIX)
|
#elif defined(Q_OS_UNIX)
|
||||||
//#elif defined(Q_OS_LINUX)
|
//#elif defined(Q_OS_LINUX)
|
||||||
|
@ -44,6 +44,18 @@
|
|||||||
#include <IOKit/hid/IOHIDLib.h>
|
#include <IOKit/hid/IOHIDLib.h>
|
||||||
#include <CoreFoundation/CFString.h>
|
#include <CoreFoundation/CFString.h>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QThread>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QCoreApplication>
|
||||||
|
|
||||||
|
class delay : public QThread
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void msleep(unsigned long msecs)
|
||||||
|
{
|
||||||
|
QThread::msleep(msecs);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
#define BUFFER_SIZE 64
|
#define BUFFER_SIZE 64
|
||||||
|
|
||||||
@ -54,6 +66,8 @@ typedef struct hid_struct hid_t;
|
|||||||
typedef struct buffer_struct buffer_t;
|
typedef struct buffer_struct buffer_t;
|
||||||
static hid_t *first_hid = NULL;
|
static hid_t *first_hid = NULL;
|
||||||
static hid_t *last_hid = NULL;
|
static hid_t *last_hid = NULL;
|
||||||
|
// Make sure we use the correct runloop
|
||||||
|
CFRunLoopRef the_correct_runloop = NULL;
|
||||||
struct hid_struct {
|
struct hid_struct {
|
||||||
IOHIDDeviceRef ref;
|
IOHIDDeviceRef ref;
|
||||||
int open;
|
int open;
|
||||||
@ -75,9 +89,10 @@ static void free_all_hid(void);
|
|||||||
static void hid_close(hid_t *);
|
static void hid_close(hid_t *);
|
||||||
static void attach_callback(void *, IOReturn, void *, IOHIDDeviceRef);
|
static void attach_callback(void *, IOReturn, void *, IOHIDDeviceRef);
|
||||||
static void detach_callback(void *, IOReturn, void *hid_mgr, IOHIDDeviceRef dev);
|
static void detach_callback(void *, IOReturn, void *hid_mgr, IOHIDDeviceRef dev);
|
||||||
static void timeout_callback(CFRunLoopTimerRef, void *);
|
|
||||||
static void input_callback(void *, IOReturn, void *, IOHIDReportType, uint32_t, uint8_t *, CFIndex);
|
static void input_callback(void *, IOReturn, void *, IOHIDReportType, uint32_t, uint8_t *, CFIndex);
|
||||||
static void output_callback(hid_t *context, IOReturn ret, void *sender, IOHIDReportType type, uint32_t id, uint8_t *data, CFIndex len);
|
static void output_callback(hid_t *context, IOReturn ret, void *sender, IOHIDReportType type, uint32_t id, uint8_t *data, CFIndex len);
|
||||||
|
static void timeout_callback(CFRunLoopTimerRef, void *);
|
||||||
|
|
||||||
|
|
||||||
pjrc_rawhid::pjrc_rawhid()
|
pjrc_rawhid::pjrc_rawhid()
|
||||||
{
|
{
|
||||||
@ -164,6 +179,8 @@ int pjrc_rawhid::open(int max, int vid, int pid, int usage_page, int usage)
|
|||||||
CFRelease(hid_manager);
|
CFRelease(hid_manager);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
// Set the run loop reference:
|
||||||
|
the_correct_runloop = CFRunLoopGetCurrent();
|
||||||
printf("run loop\n");
|
printf("run loop\n");
|
||||||
// let it do the callback for all devices
|
// let it do the callback for all devices
|
||||||
while (CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, true) == kCFRunLoopRunHandledSource) ;
|
while (CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, true) == kCFRunLoopRunHandledSource) ;
|
||||||
@ -204,14 +221,22 @@ int pjrc_rawhid::receive(int num, void *buf, int len, int timeout)
|
|||||||
timer = CFRunLoopTimerCreate(NULL, CFAbsoluteTimeGetCurrent() +
|
timer = CFRunLoopTimerCreate(NULL, CFAbsoluteTimeGetCurrent() +
|
||||||
(double)timeout / 1000.0, 0, 0, 0, timeout_callback, &context);
|
(double)timeout / 1000.0, 0, 0, 0, timeout_callback, &context);
|
||||||
CFRunLoopAddTimer(CFRunLoopGetCurrent(), timer, kCFRunLoopDefaultMode);
|
CFRunLoopAddTimer(CFRunLoopGetCurrent(), timer, kCFRunLoopDefaultMode);
|
||||||
|
the_correct_runloop = CFRunLoopGetCurrent();
|
||||||
|
//qDebug("--");
|
||||||
while (1) {
|
while (1) {
|
||||||
CFRunLoopRun();
|
//qDebug(".");
|
||||||
|
CFRunLoopRun(); // Found the problem: somehow the input_callback does not
|
||||||
|
// stop this CFRunLoopRun because it is hooked to a different run loop !!!
|
||||||
|
// Hence the use of the "correct_runloop" variable above.
|
||||||
|
//qDebug(" ..");
|
||||||
|
|
||||||
if ((b = hid->first_buffer) != NULL) {
|
if ((b = hid->first_buffer) != NULL) {
|
||||||
if (len > b->len) len = b->len;
|
if (len > b->len) len = b->len;
|
||||||
memcpy(buf, b->buf, len);
|
memcpy(buf, b->buf, len);
|
||||||
hid->first_buffer = b->next;
|
hid->first_buffer = b->next;
|
||||||
free(b);
|
free(b);
|
||||||
ret = len;
|
ret = len;
|
||||||
|
//qDebug("*************");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!hid->open) {
|
if (!hid->open) {
|
||||||
@ -219,7 +244,8 @@ int pjrc_rawhid::receive(int num, void *buf, int len, int timeout)
|
|||||||
ret = -1;
|
ret = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (timeout_occurred) break;
|
if (timeout_occurred)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
CFRunLoopTimerInvalidate(timer);
|
CFRunLoopTimerInvalidate(timer);
|
||||||
CFRelease(timer);
|
CFRelease(timer);
|
||||||
@ -335,10 +361,11 @@ static void input_callback(void *context, IOReturn ret, void *sender, IOHIDRepor
|
|||||||
buffer_t *n;
|
buffer_t *n;
|
||||||
hid_t *hid;
|
hid_t *hid;
|
||||||
|
|
||||||
printf("input_callback, report id: %i buf: %x %x, len: %d\n", id, data[0], data[1], len);
|
//qDebug("input_callback, ret: %i - report id: %i buf: %x %x, len: %d\n", ret, id, data[0], data[1], len);
|
||||||
if (ret != kIOReturnSuccess || len < 1) return;
|
if (ret != kIOReturnSuccess || len < 1) return;
|
||||||
hid = (hid_t*)context;
|
hid = (hid_t*)context;
|
||||||
if (!hid || hid->ref != sender) return;
|
if (!hid || hid->ref != sender) return;
|
||||||
|
printf("Processing packet");
|
||||||
n = (buffer_t *)malloc(sizeof(buffer_t));
|
n = (buffer_t *)malloc(sizeof(buffer_t));
|
||||||
if (!n) return;
|
if (!n) return;
|
||||||
if (len > BUFFER_SIZE) len = BUFFER_SIZE;
|
if (len > BUFFER_SIZE) len = BUFFER_SIZE;
|
||||||
@ -352,13 +379,15 @@ static void input_callback(void *context, IOReturn ret, void *sender, IOHIDRepor
|
|||||||
hid->last_buffer->next = n;
|
hid->last_buffer->next = n;
|
||||||
hid->last_buffer = n;
|
hid->last_buffer = n;
|
||||||
}
|
}
|
||||||
CFRunLoopStop(CFRunLoopGetCurrent());
|
//qDebug() << "Stop CFRunLoop from input_callback" << CFRunLoopGetCurrent();
|
||||||
|
CFRunLoopStop(the_correct_runloop);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void timeout_callback(CFRunLoopTimerRef timer, void *info)
|
static void timeout_callback(CFRunLoopTimerRef timer, void *info)
|
||||||
{
|
{
|
||||||
printf("timeout_callback\n");
|
//qDebug("timeout_callback\n");
|
||||||
*(int *)info = 1;
|
*(int *)info = 1;
|
||||||
|
//qDebug() << "Stop CFRunLoop from timeout_callback" << CFRunLoopGetCurrent();
|
||||||
CFRunLoopStop(CFRunLoopGetCurrent());
|
CFRunLoopStop(CFRunLoopGetCurrent());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user