void hw_monitor::send_hw_monitor_command(hwmon_cmd_details& details) const { unsigned char outputBuffer[HW_MONITOR_BUFFER_SIZE]; uint32_t op{}; size_t receivedCmdLen = HW_MONITOR_BUFFER_SIZE; execute_usb_command(details.sendCommandData.data(), details.sizeOfSendCommandData, op, outputBuffer, receivedCmdLen); update_cmd_details(details, receivedCmdLen, outputBuffer); }
void send_hw_monitor_command(uvc::device & device, std::timed_mutex & mutex, unsigned char handle_id, HWMonCommandDetails & details) { unsigned char outputBuffer[HW_MONITOR_BUFFER_SIZE]; uint32_t op; size_t receivedCmdLen = HW_MONITOR_BUFFER_SIZE; execute_usb_command(device, mutex, handle_id, (uint8_t*)details.sendCommandData, (size_t)details.sizeOfSendCommandData, op, outputBuffer, receivedCmdLen); details.receivedCommandDataLength = receivedCmdLen; if (details.oneDirection) return; if (details.receivedCommandDataLength < 4) throw std::runtime_error("received incomplete response to usb command"); details.receivedCommandDataLength -= 4; memcpy(details.receivedOpcode, outputBuffer, 4); if (details.receivedCommandDataLength > 0) memcpy(details.receivedCommandData, outputBuffer + 4, details.receivedCommandDataLength); }