1
0
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:
peabody124 2010-10-20 05:21:23 +00:00 committed by peabody124
parent 2a47f4baca
commit f618e6fffc
2 changed files with 14 additions and 1 deletions

View File

@ -245,6 +245,16 @@ int pjrc_rawhid::send(int num, void *buf, int len, int timeout)
// Note: packet processing done in OS indepdent code
IOReturn ret = IOHIDDeviceSetReport(hid->ref, kIOHIDReportTypeOutput, 2, (uint8_t *)report_buf, len);
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
#if 0
// No matter what I tried this never actually sends an output

View File

@ -133,6 +133,7 @@ RawHIDReadThread::~RawHIDReadThread()
void RawHIDReadThread::run()
{
qDebug() << "Read thread started";
while(m_running)
{
//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};
m_writeBufMtx.lock();
int size = qMin(WRITE_SIZE, m_writeBuffer.size());
int size = qMin(WRITE_SIZE-2, m_writeBuffer.size());
while(size <= 0)
{
//wait on new data to write condition, the timeout
@ -327,12 +328,14 @@ void RawHID::close()
{
if(m_readThread)
{
m_readThread->terminate();
delete m_readThread;
m_readThread = NULL;
}
if(m_writeThread)
{
m_writeThread->terminate();
delete m_writeThread;
m_writeThread = NULL;
}