mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-03-15 07:29:15 +01:00
Another windows trick
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1183 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
054e662882
commit
7a10a77d4b
@ -226,15 +226,14 @@ int pjrc_rawhid::send(int num, void *buf, int len, int timeout)
|
||||
OVERLAPPED ov;
|
||||
DWORD n, r;
|
||||
|
||||
if (sizeof(tmpbuf) < (len + 1)) return -1;
|
||||
if (sizeof(tmpbuf) < len) return -1;
|
||||
hid = get_hid(num);
|
||||
if (!hid || !hid->open) return -1;
|
||||
EnterCriticalSection(&tx_mutex);
|
||||
ResetEvent(&tx_event);
|
||||
memset(&ov, 0, sizeof(ov));
|
||||
ov.hEvent = tx_event;
|
||||
tmpbuf[0] = 0;
|
||||
memcpy(tmpbuf + 1, buf, len);
|
||||
memcpy(tmpbuf, buf, len);
|
||||
if (!WriteFile(hid->handle, tmpbuf, 64, NULL, &ov)) {
|
||||
if (GetLastError() != ERROR_IO_PENDING) goto return_error;
|
||||
r = WaitForSingleObject(tx_event, timeout);
|
||||
|
Loading…
x
Reference in New Issue
Block a user