mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
Ground/HID: A few tweaks to the HID code, especially for mac, and make sure it
never tries to transmit too much data git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1995 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
2a47f4baca
commit
f618e6fffc
@ -245,6 +245,16 @@ int pjrc_rawhid::send(int num, void *buf, int len, int timeout)
|
|||||||
// Note: packet processing done in OS indepdent code
|
// Note: packet processing done in OS indepdent code
|
||||||
IOReturn ret = IOHIDDeviceSetReport(hid->ref, kIOHIDReportTypeOutput, 2, (uint8_t *)report_buf, len);
|
IOReturn ret = IOHIDDeviceSetReport(hid->ref, kIOHIDReportTypeOutput, 2, (uint8_t *)report_buf, len);
|
||||||
result = (ret == kIOReturnSuccess) ? len : -1;
|
result = (ret == kIOReturnSuccess) ? len : -1;
|
||||||
|
if (err_get_system(ret) == err_get_system(sys_iokit))
|
||||||
|
{
|
||||||
|
|
||||||
|
// The error was in the I/O Kit system
|
||||||
|
UInt32 codeValue = err_get_code(ret);
|
||||||
|
qDebug("Returned: %x", codeValue);
|
||||||
|
// Can now perform test on error code, display it to user, or whatever.
|
||||||
|
usleep(1000000);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#if 0
|
#if 0
|
||||||
// No matter what I tried this never actually sends an output
|
// No matter what I tried this never actually sends an output
|
||||||
|
@ -133,6 +133,7 @@ RawHIDReadThread::~RawHIDReadThread()
|
|||||||
|
|
||||||
void RawHIDReadThread::run()
|
void RawHIDReadThread::run()
|
||||||
{
|
{
|
||||||
|
qDebug() << "Read thread started";
|
||||||
while(m_running)
|
while(m_running)
|
||||||
{
|
{
|
||||||
//here we use a temporary buffer so we don't need to lock
|
//here we use a temporary buffer so we don't need to lock
|
||||||
@ -206,7 +207,7 @@ void RawHIDWriteThread::run()
|
|||||||
char buffer[WRITE_SIZE] = {0};
|
char buffer[WRITE_SIZE] = {0};
|
||||||
|
|
||||||
m_writeBufMtx.lock();
|
m_writeBufMtx.lock();
|
||||||
int size = qMin(WRITE_SIZE, m_writeBuffer.size());
|
int size = qMin(WRITE_SIZE-2, m_writeBuffer.size());
|
||||||
while(size <= 0)
|
while(size <= 0)
|
||||||
{
|
{
|
||||||
//wait on new data to write condition, the timeout
|
//wait on new data to write condition, the timeout
|
||||||
@ -327,12 +328,14 @@ void RawHID::close()
|
|||||||
{
|
{
|
||||||
if(m_readThread)
|
if(m_readThread)
|
||||||
{
|
{
|
||||||
|
m_readThread->terminate();
|
||||||
delete m_readThread;
|
delete m_readThread;
|
||||||
m_readThread = NULL;
|
m_readThread = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_writeThread)
|
if(m_writeThread)
|
||||||
{
|
{
|
||||||
|
m_writeThread->terminate();
|
||||||
delete m_writeThread;
|
delete m_writeThread;
|
||||||
m_writeThread = NULL;
|
m_writeThread = NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user