mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-31 16:52:10 +01:00
OP GCS - sorry made a mess dealing with conflicts
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2916 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
0c2a563c34
commit
b8a5249246
@ -162,6 +162,7 @@ public:
|
|||||||
QString getserial(int num);
|
QString getserial(int num);
|
||||||
void mytest(int num);
|
void mytest(int num);
|
||||||
signals:
|
signals:
|
||||||
|
void deviceUnplugged(int);//just to make pips changes compile
|
||||||
/*!
|
/*!
|
||||||
A new device has been connected to the system.
|
A new device has been connected to the system.
|
||||||
|
|
||||||
@ -208,7 +209,7 @@ private:
|
|||||||
hid_t * get_hid(int num);
|
hid_t * get_hid(int num);
|
||||||
void free_all_hid(void);
|
void free_all_hid(void);
|
||||||
void hid_close(hid_t *hid);
|
void hid_close(hid_t *hid);
|
||||||
void print_win32_err(void);
|
void print_win32_err(DWORD err);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
@ -127,18 +127,6 @@ int pjrc_rawhid::open(int max, int vid, int pid, int usage_page, int usage)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
<<<<<<< .mine
|
|
||||||
h = CreateFile(details->DevicePath, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
|
|
||||||
if (h == INVALID_HANDLE_VALUE)
|
|
||||||
{
|
|
||||||
// I get ERROR_ACCESS_DENIED with most/all my input devices (mice/trackballs/tablet).
|
|
||||||
// Let's not log it :)
|
|
||||||
if (GetLastError() == ERROR_ACCESS_DENIED)
|
|
||||||
{
|
|
||||||
free(details);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
=======
|
|
||||||
h = CreateFile(details->DevicePath, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
|
h = CreateFile(details->DevicePath, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
|
||||||
if (h == INVALID_HANDLE_VALUE)
|
if (h == INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
@ -151,17 +139,10 @@ int pjrc_rawhid::open(int max, int vid, int pid, int usage_page, int usage)
|
|||||||
free(details);
|
free(details);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
>>>>>>> .r2914
|
|
||||||
|
|
||||||
<<<<<<< .mine
|
|
||||||
// qDebug wipes the GetLastError() it seems, so do that after print_win32_err().
|
|
||||||
print_win32_err();
|
|
||||||
qDebug() << "Problem opening handle, path: " << QString().fromWCharArray(details->DevicePath);
|
|
||||||
=======
|
|
||||||
// qDebug wipes the GetLastError() it seems, so do that after print_win32_err().
|
// qDebug wipes the GetLastError() it seems, so do that after print_win32_err().
|
||||||
print_win32_err(err);
|
print_win32_err(err);
|
||||||
qDebug() << "Problem opening handle, path: " << QString().fromWCharArray(details->DevicePath);
|
qDebug() << "Problem opening handle, path: " << QString().fromWCharArray(details->DevicePath);
|
||||||
>>>>>>> .r2914
|
|
||||||
|
|
||||||
free(details);
|
free(details);
|
||||||
continue;
|
continue;
|
||||||
@ -198,9 +179,6 @@ int pjrc_rawhid::open(int max, int vid, int pid, int usage_page, int usage)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
<<<<<<< .mine
|
|
||||||
qDebug("Open: Handle address: %li for num: %i", (long int) h, count);
|
|
||||||
=======
|
|
||||||
// COMMTIMEOUTS CommTimeouts;
|
// COMMTIMEOUTS CommTimeouts;
|
||||||
// CommTimeouts.ReadIntervalTimeout = 100; // 100ms
|
// CommTimeouts.ReadIntervalTimeout = 100; // 100ms
|
||||||
// CommTimeouts.ReadTotalTimeoutConstant = 5; // ms
|
// CommTimeouts.ReadTotalTimeoutConstant = 5; // ms
|
||||||
@ -214,16 +192,9 @@ int pjrc_rawhid::open(int max, int vid, int pid, int usage_page, int usage)
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
qDebug("Open: Handle address: %li for num: %i", (long int) h, count);
|
qDebug("Open: Handle address: %li for num: %i", (long int) h, count);
|
||||||
>>>>>>> .r2914
|
|
||||||
|
|
||||||
<<<<<<< .mine
|
|
||||||
hid->handle = h;
|
|
||||||
hid->open = 1;
|
|
||||||
add_hid(hid);
|
|
||||||
=======
|
|
||||||
hid->handle = h;
|
hid->handle = h;
|
||||||
add_hid(hid);
|
add_hid(hid);
|
||||||
>>>>>>> .r2914
|
|
||||||
|
|
||||||
count++;
|
count++;
|
||||||
if (count >= max) return count;
|
if (count >= max) return count;
|
||||||
@ -246,16 +217,11 @@ int pjrc_rawhid::receive(int num, void *buf, int len, int timeout)
|
|||||||
OVERLAPPED ov;
|
OVERLAPPED ov;
|
||||||
DWORD n;
|
DWORD n;
|
||||||
|
|
||||||
<<<<<<< .mine
|
|
||||||
hid_t *hid = get_hid(num);
|
|
||||||
if (!hid || !hid->open) return -1;
|
|
||||||
=======
|
|
||||||
hid_t *hid = get_hid(num);
|
hid_t *hid = get_hid(num);
|
||||||
if (!hid)
|
if (!hid)
|
||||||
return -1;
|
return -1;
|
||||||
if (!hid->handle)
|
if (!hid->handle)
|
||||||
return -1;
|
return -1;
|
||||||
>>>>>>> .r2914
|
|
||||||
|
|
||||||
EnterCriticalSection(&rx_mutex);
|
EnterCriticalSection(&rx_mutex);
|
||||||
|
|
||||||
@ -264,16 +230,6 @@ int pjrc_rawhid::receive(int num, void *buf, int len, int timeout)
|
|||||||
memset(&ov, 0, sizeof(ov));
|
memset(&ov, 0, sizeof(ov));
|
||||||
ov.hEvent = rx_event;
|
ov.hEvent = rx_event;
|
||||||
|
|
||||||
<<<<<<< .mine
|
|
||||||
if (!ReadFile(hid->handle, buf, len, NULL, &ov))
|
|
||||||
{
|
|
||||||
if (GetLastError() != ERROR_IO_PENDING)
|
|
||||||
{
|
|
||||||
print_win32_err();
|
|
||||||
LeaveCriticalSection(&rx_mutex);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
=======
|
|
||||||
if (!ReadFile(hid->handle, buf, len, NULL, &ov))
|
if (!ReadFile(hid->handle, buf, len, NULL, &ov))
|
||||||
{
|
{
|
||||||
DWORD err = GetLastError();
|
DWORD err = GetLastError();
|
||||||
@ -293,24 +249,7 @@ int pjrc_rawhid::receive(int num, void *buf, int len, int timeout)
|
|||||||
LeaveCriticalSection(&rx_mutex);
|
LeaveCriticalSection(&rx_mutex);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
>>>>>>> .r2914
|
|
||||||
|
|
||||||
<<<<<<< .mine
|
|
||||||
DWORD r = WaitForSingleObject(rx_event, timeout);
|
|
||||||
if (r == WAIT_TIMEOUT)
|
|
||||||
{
|
|
||||||
CancelIo(hid->handle);
|
|
||||||
LeaveCriticalSection(&rx_mutex);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (r != WAIT_OBJECT_0)
|
|
||||||
{
|
|
||||||
print_win32_err();
|
|
||||||
LeaveCriticalSection(&rx_mutex);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
=======
|
|
||||||
DWORD r = WaitForSingleObject(rx_event, timeout);
|
DWORD r = WaitForSingleObject(rx_event, timeout);
|
||||||
if (r == WAIT_TIMEOUT)
|
if (r == WAIT_TIMEOUT)
|
||||||
{
|
{
|
||||||
@ -326,16 +265,7 @@ int pjrc_rawhid::receive(int num, void *buf, int len, int timeout)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
>>>>>>> .r2914
|
|
||||||
|
|
||||||
<<<<<<< .mine
|
|
||||||
if (!GetOverlappedResult(hid->handle, &ov, &n, FALSE))
|
|
||||||
{
|
|
||||||
print_win32_err();
|
|
||||||
LeaveCriticalSection(&rx_mutex);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
=======
|
|
||||||
if (!GetOverlappedResult(hid->handle, &ov, &n, FALSE))
|
if (!GetOverlappedResult(hid->handle, &ov, &n, FALSE))
|
||||||
{
|
{
|
||||||
DWORD err = GetLastError();
|
DWORD err = GetLastError();
|
||||||
@ -352,13 +282,12 @@ int pjrc_rawhid::receive(int num, void *buf, int len, int timeout)
|
|||||||
LeaveCriticalSection(&rx_mutex);
|
LeaveCriticalSection(&rx_mutex);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
>>>>>>> .r2914
|
|
||||||
|
|
||||||
LeaveCriticalSection(&rx_mutex);
|
LeaveCriticalSection(&rx_mutex);
|
||||||
|
|
||||||
if (n <= 0) return -1;
|
if (n <= 0) return -1;
|
||||||
|
|
||||||
// qDebug("Received %i bytes, first %x, second %x", len, *((char *) buf),*((char *)buf + 1));
|
// qDebug("Received %i bytes, first %x, second %x", len, *((char *) buf),*((char *)buf + 1));
|
||||||
|
|
||||||
if ((int)n > len) n = len;
|
if ((int)n > len) n = len;
|
||||||
return n;
|
return n;
|
||||||
@ -378,18 +307,13 @@ int pjrc_rawhid::send(int num, void *buf, int len, int timeout)
|
|||||||
OVERLAPPED ov;
|
OVERLAPPED ov;
|
||||||
DWORD n, r;
|
DWORD n, r;
|
||||||
|
|
||||||
<<<<<<< .mine
|
|
||||||
hid_t *hid = get_hid(num);
|
|
||||||
if (!hid || !hid->open) return -1;
|
|
||||||
=======
|
|
||||||
hid_t *hid = get_hid(num);
|
hid_t *hid = get_hid(num);
|
||||||
if (!hid)
|
if (!hid)
|
||||||
return -1;
|
return -1;
|
||||||
if (!hid->handle)
|
if (!hid->handle)
|
||||||
return -1;
|
return -1;
|
||||||
>>>>>>> .r2914
|
|
||||||
|
|
||||||
// qDebug("Send: Handle address: %li for num: %i", (long int) hid->handle, num);
|
// qDebug("Send: Handle address: %li for num: %i", (long int) hid->handle, num);
|
||||||
|
|
||||||
EnterCriticalSection(&tx_mutex);
|
EnterCriticalSection(&tx_mutex);
|
||||||
|
|
||||||
@ -398,38 +322,8 @@ int pjrc_rawhid::send(int num, void *buf, int len, int timeout)
|
|||||||
memset(&ov, 0, sizeof(ov));
|
memset(&ov, 0, sizeof(ov));
|
||||||
ov.hEvent = tx_event;
|
ov.hEvent = tx_event;
|
||||||
|
|
||||||
// qDebug("Trying to write %u bytes. First %x second %x",len, *((char *) buf), *((char *)buf + 1));
|
// qDebug("Trying to write %u bytes. First %x second %x",len, *((char *) buf), *((char *)buf + 1));
|
||||||
|
|
||||||
<<<<<<< .mine
|
|
||||||
if (!WriteFile(hid->handle, buf, len, NULL, &ov))
|
|
||||||
{
|
|
||||||
DWORD err = GetLastError();
|
|
||||||
if ( err == ERROR_SUCCESS || err == ERROR_IO_PENDING )
|
|
||||||
{
|
|
||||||
// qDebug("Waiting for write to finish");
|
|
||||||
r = WaitForSingleObject(tx_event, timeout);
|
|
||||||
if (r == WAIT_TIMEOUT)
|
|
||||||
{
|
|
||||||
CancelIo(hid->handle);
|
|
||||||
LeaveCriticalSection(&tx_mutex);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (r != WAIT_OBJECT_0)
|
|
||||||
{
|
|
||||||
print_win32_err();
|
|
||||||
LeaveCriticalSection(&tx_mutex);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// qDebug("Error writing to file");
|
|
||||||
print_win32_err();
|
|
||||||
LeaveCriticalSection(&tx_mutex);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
=======
|
|
||||||
if (!WriteFile(hid->handle, buf, len, NULL, &ov))
|
if (!WriteFile(hid->handle, buf, len, NULL, &ov))
|
||||||
{
|
{
|
||||||
DWORD err = GetLastError();
|
DWORD err = GetLastError();
|
||||||
@ -468,15 +362,7 @@ int pjrc_rawhid::send(int num, void *buf, int len, int timeout)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
>>>>>>> .r2914
|
|
||||||
|
|
||||||
<<<<<<< .mine
|
|
||||||
if (!GetOverlappedResult(hid->handle, &ov, &n, FALSE))
|
|
||||||
{
|
|
||||||
qDebug("Problem getting overlapped result");
|
|
||||||
print_win32_err();
|
|
||||||
}
|
|
||||||
=======
|
|
||||||
if (!GetOverlappedResult(hid->handle, &ov, &n, FALSE))
|
if (!GetOverlappedResult(hid->handle, &ov, &n, FALSE))
|
||||||
{
|
{
|
||||||
DWORD err = GetLastError();
|
DWORD err = GetLastError();
|
||||||
@ -492,7 +378,6 @@ int pjrc_rawhid::send(int num, void *buf, int len, int timeout)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
>>>>>>> .r2914
|
|
||||||
|
|
||||||
LeaveCriticalSection(&tx_mutex);
|
LeaveCriticalSection(&tx_mutex);
|
||||||
|
|
||||||
@ -502,27 +387,12 @@ int pjrc_rawhid::send(int num, void *buf, int len, int timeout)
|
|||||||
|
|
||||||
QString pjrc_rawhid::getserial(int num)
|
QString pjrc_rawhid::getserial(int num)
|
||||||
{
|
{
|
||||||
<<<<<<< .mine
|
|
||||||
hid_t *hid = get_hid(num);
|
|
||||||
if (!hid || !hid->open)
|
|
||||||
return "";
|
|
||||||
=======
|
|
||||||
hid_t *hid = get_hid(num);
|
hid_t *hid = get_hid(num);
|
||||||
if (!hid)
|
if (!hid)
|
||||||
return "";
|
return "";
|
||||||
>>>>>>> .r2914
|
|
||||||
if (!hid->handle)
|
if (!hid->handle)
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
<<<<<<< .mine
|
|
||||||
// Should we do some "critical section" stuff here??
|
|
||||||
char temp[126];
|
|
||||||
if (!HidD_GetSerialNumberString(hid->handle, temp, sizeof(temp)))
|
|
||||||
{
|
|
||||||
print_win32_err();
|
|
||||||
return QString("Error");
|
|
||||||
}
|
|
||||||
=======
|
|
||||||
// Should we do some "critical section" stuff here??
|
// Should we do some "critical section" stuff here??
|
||||||
char temp[126];
|
char temp[126];
|
||||||
if (!HidD_GetSerialNumberString(hid->handle, temp, sizeof(temp)))
|
if (!HidD_GetSerialNumberString(hid->handle, temp, sizeof(temp)))
|
||||||
@ -539,7 +409,6 @@ QString pjrc_rawhid::getserial(int num)
|
|||||||
|
|
||||||
return QString("Error");
|
return QString("Error");
|
||||||
}
|
}
|
||||||
>>>>>>> .r2914
|
|
||||||
|
|
||||||
return QString().fromUtf16((ushort*)temp,-1);
|
return QString().fromUtf16((ushort*)temp,-1);
|
||||||
}
|
}
|
||||||
@ -553,31 +422,13 @@ QString pjrc_rawhid::getserial(int num)
|
|||||||
//
|
//
|
||||||
void pjrc_rawhid::close(int num)
|
void pjrc_rawhid::close(int num)
|
||||||
{
|
{
|
||||||
<<<<<<< .mine
|
|
||||||
hid_t *hid = get_hid(num);
|
|
||||||
if (hid && hid->open)
|
|
||||||
hid_close(hid);
|
|
||||||
=======
|
|
||||||
hid_close(get_hid(num));
|
hid_close(get_hid(num));
|
||||||
>>>>>>> .r2914
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void pjrc_rawhid::add_hid(hid_t *h)
|
void pjrc_rawhid::add_hid(hid_t *h)
|
||||||
{
|
{
|
||||||
if (!h) return;
|
if (!h) return;
|
||||||
|
|
||||||
<<<<<<< .mine
|
|
||||||
if (!first_hid || !last_hid)
|
|
||||||
{
|
|
||||||
first_hid = last_hid = h;
|
|
||||||
h->next = h->prev = NULL;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
last_hid->next = h;
|
|
||||||
h->prev = last_hid;
|
|
||||||
h->next = NULL;
|
|
||||||
last_hid = h;
|
|
||||||
=======
|
|
||||||
if (!first_hid || !last_hid)
|
if (!first_hid || !last_hid)
|
||||||
{
|
{
|
||||||
first_hid = last_hid = h;
|
first_hid = last_hid = h;
|
||||||
@ -589,7 +440,6 @@ void pjrc_rawhid::add_hid(hid_t *h)
|
|||||||
h->prev = last_hid;
|
h->prev = last_hid;
|
||||||
h->next = NULL;
|
h->next = NULL;
|
||||||
last_hid = h;
|
last_hid = h;
|
||||||
>>>>>>> .r2914
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hid_t * pjrc_rawhid::get_hid(int num)
|
hid_t * pjrc_rawhid::get_hid(int num)
|
||||||
@ -620,39 +470,21 @@ void pjrc_rawhid::hid_close(hid_t *hid)
|
|||||||
if (!hid) return;
|
if (!hid) return;
|
||||||
if (!hid->handle) return;
|
if (!hid->handle) return;
|
||||||
|
|
||||||
<<<<<<< .mine
|
|
||||||
if (hid->handle)
|
|
||||||
{
|
|
||||||
CloseHandle(hid->handle);
|
CloseHandle(hid->handle);
|
||||||
hid->handle = NULL;
|
hid->handle = NULL;
|
||||||
}
|
|
||||||
=======
|
|
||||||
CloseHandle(hid->handle);
|
|
||||||
hid->handle = NULL;
|
|
||||||
>>>>>>> .r2914
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void pjrc_rawhid::print_win32_err(DWORD err)
|
void pjrc_rawhid::print_win32_err(DWORD err)
|
||||||
{
|
{
|
||||||
<<<<<<< .mine
|
|
||||||
char buf[256];
|
char buf[256];
|
||||||
char temp[256];
|
char temp[256];
|
||||||
DWORD err;
|
|
||||||
=======
|
|
||||||
char buf[256];
|
|
||||||
char temp[256];
|
|
||||||
>>>>>>> .r2914
|
|
||||||
|
|
||||||
<<<<<<< .mine
|
|
||||||
err = GetLastError();
|
|
||||||
|
|
||||||
=======
|
|
||||||
>>>>>>> .r2914
|
|
||||||
//FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, 0, (WCHAR*)buf, sizeof(buf), NULL);
|
//FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, 0, (WCHAR*)buf, sizeof(buf), NULL);
|
||||||
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT), (WCHAR*)buf, sizeof(buf), NULL);
|
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT), (WCHAR*)buf, sizeof(buf), NULL);
|
||||||
WideCharToMultiByte( CP_ACP, 0, (WCHAR*)buf, sizeof(buf), temp, sizeof(temp), NULL, NULL );
|
WideCharToMultiByte( CP_ACP, 0, (WCHAR*)buf, sizeof(buf), temp, sizeof(temp), NULL, NULL );
|
||||||
printf("err %ld: %s\n", err, temp);
|
printf("err %ld: %s\n", err, temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
// see http://msdn.microsoft.com/en-us/library/ms791134.aspx for list of GUID classes
|
// see http://msdn.microsoft.com/en-us/library/ms791134.aspx for list of GUID classes
|
||||||
#ifndef GUID_DEVCLASS_PORTS
|
#ifndef GUID_DEVCLASS_PORTS
|
||||||
DEFINE_GUID(GUID_DEVCLASS_PORTS, 0x4d1e55b2, 0xf16f, 0x11cf, 0x88, 0xcb, 0x00, 0x11, 0x11, 0x00, 0x00, 0x30);
|
DEFINE_GUID(GUID_DEVCLASS_PORTS, 0x4d1e55b2, 0xf16f, 0x11cf, 0x88, 0xcb, 0x00, 0x11, 0x11, 0x00, 0x00, 0x30);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user