Open ColtB45 opened 5 years ago
I am looking for an example of how to leverage writeReport. Specifically, I'm trying to send a query string which should illicit a response with the requested information. It doesn't appear to send the query string out though;
d->writeReport(uint16_t(sizeof(upsquery1))-1, uint8_t(upsquery1));
I assume I'm doing something wrong and seeking a functional example(s) of writeReport.
The sketch I'm working with is below.
// Load the USB Host System core #define LOAD_USB_HOST_SYSTEM // Load USB Host Shield //#define LOAD_USB_HOST_SHIELD // Use USB hub, you might want this for multiple devices. //#define LOAD_UHS_HUB // Patch printf so we can use it. #define LOAD_UHS_PRINTF_HELPER #define DEBUG_PRINTF_EXTRA_HUGE 0 #define DEBUG_PRINTF_EXTRA_HUGE_USB_HID 1 #define LOAD_UHS_HID #include <Arduino.h> #ifdef true #undef true #endif #ifdef false #undef false #endif #define LOAD_UHS_KINETIS_FS_HOST #define USB_HOST_SERIAL Serial2 #define ENABLE_UHS_DEBUGGING 1 #define DEBUG_PRINTF_EXTRA_HUGE 1 #define DEBUG_PRINTF_EXTRA_HUGE_UHS_HOST 1 #define DEBUG_PRINTF_EXTRA_HUGE_USB_HOST_KINETIS 1 #include <UHS_host.h> const uint8_t upsquery1[] = {0x00, 0x01, 0x02, 0x03}; int ii = 0; class myHID_processor : public UHS_HID_PROCESSOR { public: myHID_processor(void) {} void onRelease(UHS_HID_base *d) { printf_P(PSTR("HID driver type %d no longer available.\r\n"), d->driver); } void onStart(UHS_HID_base *d) { printf_P(PSTR("HID driver type %d started, Subclass %02x, Protocol %02x\r\n"), d->driver, d->parent->bSubClass, d->parent->bProtocol); } void onPoll(UHS_HID_base *d, uint8_t *data, uint16_t length) { switch(d->driver) { case UHS_HID_raw: printf_P(PSTR("\r\n")); printf_P(PSTR("RAW input %d bytes Data:"), length); for(int i=0; i < length; i++) { printf_P(PSTR(" %02x"), data[i]); } printf_P(PSTR("\r\n")); ii++; if (ii>2){ d->writeReport(uint16_t(sizeof(upsquery1))-1, uint8_t(upsquery1)); printf_P(PSTR("RAW output %d bytes Data:"), sizeof(sendsend)); for(int i=0; i < sizeof(sendsend); i++) { printf_P(PSTR(" %02x"), sendsend[i]); } printf_P(PSTR("\r\n")); ii=0; } break; default: break; } } }; myHID_processor HID_processor1; UHS_KINETIS_FS_HOST UHS_Usb; UHS_HID hid1(&UHS_Usb, &HID_processor1); void setup() { USB_HOST_SERIAL.begin(115200); while(UHS_Usb.Init(1000) != 0); printf_P(PSTR("\r\nHID RAW demo Begin.\r\n")); } void loop() { delay(1); }
I am looking for an example of how to leverage writeReport. Specifically, I'm trying to send a query string which should illicit a response with the requested information. It doesn't appear to send the query string out though;
d->writeReport(uint16_t(sizeof(upsquery1))-1, uint8_t(upsquery1));
I assume I'm doing something wrong and seeking a functional example(s) of writeReport.
The sketch I'm working with is below.