1
0
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:
peabody124 2010-07-29 20:02:40 +00:00 committed by peabody124
parent 054e662882
commit 7a10a77d4b

View File

@ -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);