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!
Parents
  • Hi

    I am a bit confused by your report descriptor. It seems to set up 64 bytes of IN data and 64 bytes of OUT data, not more than that. 

    Are you using a different descriptor when trying to send more than 64 bytes in one go?

    When you receive two packets, how much data is there in each packet?

    Best regards
    Torbjørn

  • report

    Hi

    I want to setup a full-speed usb device with two 64-bits endpoints (1 IN and 1 OUT).

    I just changed report descriptor (USBD_GENERIC_REPORT_DESCRIPTOR) in examples/peripheral/usbd_hid_generic.

    I want to received a message (>300 bytes) but I just received 2 packets:

    In Packet 1: Len = 0x0157 = 343 bytes is length of message, Data has length = 64 - 4 (CID bytes) -1 (CMD) - 2 (Len) = 57 bytes

    In Packet 2: index is index of continue packet, Data has length = 64 - 4 - 1 = 59 bytes

    Packet 3 has 59 bytes data with index = 01, but I don't receive it and following packets

    And one more infomation, I tested on macOS 10.14.6

    Please help me, thanks!

Reply
  • report

    Hi

    I want to setup a full-speed usb device with two 64-bits endpoints (1 IN and 1 OUT).

    I just changed report descriptor (USBD_GENERIC_REPORT_DESCRIPTOR) in examples/peripheral/usbd_hid_generic.

    I want to received a message (>300 bytes) but I just received 2 packets:

    In Packet 1: Len = 0x0157 = 343 bytes is length of message, Data has length = 64 - 4 (CID bytes) -1 (CMD) - 2 (Len) = 57 bytes

    In Packet 2: index is index of continue packet, Data has length = 64 - 4 - 1 = 59 bytes

    Packet 3 has 59 bytes data with index = 01, but I don't receive it and following packets

    And one more infomation, I tested on macOS 10.14.6

    Please help me, thanks!

Children
No Data
Related