1

hid_get_feature_reportAndroid USB 库中的类比是什么?

我需要从 Android 上的 USB 中继设备获取中继状态。

我在 C 上找到了示例(适用于 Linux/Windows):https ://github.com/darrylb123/usbrelay/blob/master/libusbrelay.c

static int get_board_features(relay_board *board, hid_device *handle)
{
   unsigned char buf[9];
   //Get the features of the device
   buf[0] = 0x01;
   int ret = hid_get_feature_report(handle, buf, sizeof(buf));
   if (ret == -1)
   {
      perror("hid_get_feature_report\n");
   }

   //Set the serial number (0x0 for termination)
   memset(board->serial, 0x0, sizeof(board->serial));
   memcpy(board->serial, buf, Serial_Length);

   //Byte 7 in the response contains the target_state of the relays
   board->state = buf[7];

   return ret;
}

在 Android 上它只返回一个端点Log.i(TAG, "endpointCount ${usbInterface.endpointCount}

4

0 回答 0