This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nrf52840 DK usbhid generic received message divided to multi packet

Hi,

I'm using nrf52840 DK to connect and receive usbhid message with the message size > 64 bytes (examples 343 bytes), so the message is divided to multi packages. I modified usb_hid_generic example, but I just received 2 packages. That is some change in my code:

#define REPORT_IN_QUEUE_SIZE    63
#define REPORT_OUT_MAXSIZE  63
#define REPORT_FEATURE_MAXSIZE  31

#define ENDPOINT_LIST()                                      \
(                                                            \
        HID_GENERIC_EPIN,                                     \
        HID_GENERIC_EPOUT                                    \
)

static void hid_user_ev_handler(app_usbd_class_inst_t const * p_inst,
                                app_usbd_hid_user_event_t event);

#define USBD_GENERIC_REPORT_DESCRIPTOR { \
  0x06, 0xD0, 0xF1 , /*USAGE_PAGE (FIDO Alliance) */ \
  0x09, 0x01 , /* USAGE (U2F HID Authenticator Device) */ \
  0xa1, 0x01 , /* COLLECTION (Application) */ \
  0x09, 0x20 , /*   USAGE (Input Report Data) */ \
  0x15, 0x00 , /*   LOGICAL_MINIMUM (0) */ \
  0x26, 0xff, 0x00 , /*   LOGICAL_MAXIMUM (255) */ \
  0x75, 0x08 , /*   REPORT_SIZE (8) */ \
  0x95, 0x40 , /*   REPORT_COUNT (64) */ \
  0x81, 0x02 , /*   INPUT (Data,Var,Abs) */ \
  0x09, 0x21 , /*   USAGE(Output Report Data) */ \
  0x15, 0x00 , /*   LOGICAL_MINIMUM (0) */ \
  0x26, 0xff, 0x00 , /*   LOGICAL_MAXIMUM (255) */ \
  0x75, 0x08 , /*   REPORT_SIZE (8) */ \
  0x95, 0x40 , /*   REPORT_COUNT (64) */ \
  0x91, 0x02 , /*   OUTPUT (Data,Var,Abs) */ \
  0xc0 , /* END_COLLECTION */ \
}
APP_USBD_HID_GENERIC_SUBCLASS_REPORT_DESC(mouse_desc,USBD_GENERIC_REPORT_DESCRIPTOR);
static const app_usbd_hid_subclass_desc_t * reps[] = {&mouse_desc};
APP_USBD_HID_GENERIC_GLOBAL_DEF(m_app_hid_generic,
                                HID_GENERIC_INTERFACE,
                                hid_user_ev_handler,
                                ENDPOINT_LIST(),
                                reps,
                                REPORT_IN_QUEUE_SIZE,
                                REPORT_OUT_MAXSIZE,
                                REPORT_FEATURE_MAXSIZE,
                                APP_USBD_HID_SUBCLASS_NONE,
                                APP_USBD_HID_PROTO_GENERIC);
static void hid_user_ev_handler(app_usbd_class_inst_t const * p_inst,
                                app_usbd_hid_user_event_t event)
{
    NRF_LOG_INFO("hid_user_ev_handler %d", event);
    switch (event)
    {
        case APP_USBD_HID_USER_EVT_OUT_REPORT_READY:
        {
            NRF_LOG_INFO("APP_USBD_HID_USER_EVT_OUT_REPORT_READY");
            size_t recv_size;
            uint8_t* recv_buf;
            recv_buf = (uint8_t *)app_usbd_hid_generic_out_report_get(&m_app_hid_generic,&recv_size);
            NRF_LOG_INFO("received data length:%d", recv_size);
            NRF_LOG_HEXDUMP_INFO(recv_buf, recv_size);
            break;
        }
        case APP_USBD_HID_USER_EVT_IN_REPORT_DONE:
        {
            NRF_LOG_INFO("APP_USBD_HID_USER_EVT_IN_REPORT_DONE");
            bsp_board_led_invert(LED_HID_REP_IN);
            break;
        }
        case APP_USBD_HID_USER_EVT_SET_BOOT_PROTO:
        {
            UNUSED_RETURN_VALUE(hid_generic_clear_buffer(p_inst));
            NRF_LOG_INFO("SET_BOOT_PROTO");
            break;
        }
        case APP_USBD_HID_USER_EVT_SET_REPORT_PROTO:
        {
            UNUSED_RETURN_VALUE(hid_generic_clear_buffer(p_inst));
            NRF_LOG_INFO("SET_REPORT_PROTO");
            break;
        }
        default:
            NRF_LOG_INFO("UNDEFINDED_EVENT %d", event);
            break;
    }
}
What is problem in here?
Thanks!
  • Hi Albert

    Thanks for the added information. 

    Just a quick update to let you know you're not forgotten. The developers will try to reproduce the issue this week, so I hope to have some news for you soon. 

    Best regards
    Torbjørn

  • Hi again

    They tried to reproduce the issue, but they were not able to get your web service to work. Instead they used the modified code to run the test:

    The code feeds 512 Bytes into the USB stack EP1 through app_usbd_hid_generic_in_report_set(xxx, 512) in function send_pkt().

    What they see on the receiving side is that the buffer gets subdivided into 8 packets and they all get transferred.

    They end up with the following conclusion:

    They cannot reproduce the issue with their setup, but in general USB stack seems to be capable of transferring big reports.

    They need some input from you to investigate this further: 

    • can you isolate the issue so that the Chrome is not needed?;
    • can you check and let us know how many IN frames you provide between OUT frames to convey the report (you need at least 6 IN packets to convey the message)?

    Best regards
    Torbjørn

Related