Explorar o código

输出读取错误值

wugren %!s(int64=3) %!d(string=hai) anos
pai
achega
06a98f8fbf
Modificáronse 1 ficheiros con 4 adicións e 1 borrados
  1. 4 1
      src/HID.cc

+ 4 - 1
src/HID.cc

@@ -210,7 +210,10 @@ HID::recvAsync(uv_work_t* req)
   unsigned char buf[READ_BUFF_MAXSIZE];
   int len = hid_read(hid->_hidHandle, buf, sizeof buf);
   if (len < 0) {
-    iocb->_error = new JSException("could not read from HID device");
+	char buf[1024];
+	memset(buf, 0, sizeof(buf));
+	sprintf(buf, "could not read from HID device. error:%d", GetLastError());
+    iocb->_error = new JSException(buf);
   } else {
     iocb->_data = vector<unsigned char>(buf, buf + len);
   }