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

app_usbd_hid_trans_required problem?

To the kind attention of Nordic support team,

I'm using sdk 15.2, I'm working on usb hid composite example, and I modified it to have it scanning a big input keyboard matrix. Everything is going well; I noticed that when pushing buttons in a disorderly and aggressively perpetuate way, I sometime get code stucked in here:

app_usbd_hid_trans_required(&p_kbd_ctx->hid_ctx),

as it is something going on, and either usb transmission stops, or latest character (group of characters) is continuously printed on opened windows text editor. I removed that app_usbd_hid_trans_required(&p_kbd_ctx->hid_ctx) instruction, and in my case everything is going well, even when in high stress condition. May I ask if it is dangerous to bypass app_usbd_hid_trans_required(&p_kbd_ctx->hid_ctx) check?

And what theoretically cause those USB problems?

Thank you for your great work and your attention.

Best regards

Parents
  • Hello,

    I am not sure how dangerous it is to skip the call to app_usbd_hid_trans_required(). From the header file: @brief Checks whether HID endpoint transfer required.

    What do you mean by that it "get code stuck in here"?

    Is it the return value that is wrong? I can't find any while loops in app_usbd_hid_trans_required(). Are you sure it is stuck inside this function?

    Best regards,

    Edvin

  • Hi Edvin, thank you. Sorry, my meaning was that it, at some point, keeps returning wrong value. It returns that there is something on going (APP_USBD_HID_STATE_FLAG_TRANS_IN_PROGRESS), so to skip next routine hid_kbd_transfer_set.

    This cause USB transmission not to work anymore, otherwise ti can happen that last character get continuously printed in a text editor. As I said, I noticed that when generating heavy traffic, and maybe I try to transmit without respecting a right timing. Nevertheless, removing app_usbd_hid_trans_required it seems that everything is going fine. So that situation seems to be always ok with USB channel

  • astella said:
    otherwise ti can happen that last character get continuously printed in a text editor.

     This is probably because the last keyboard message was that a key was being pressed. If you are not able to tell the computer that the key was released, then it will interpret it as you are holding the key down. So "not work anymore" and "last character get continuously printed" is probably two effects of the same issue.

    What function is app_usbd_hid_trans_required() called from? app_usbd_hid_kbd_key_control(), or app_usbd_hid_kbd_modifier_state_set()?

    So in your case, it enters:

    app_usbd_hid_trans_required() -> 

    if (app_usbd_hid_state_flag_test(p_hid_ctx, APP_USBD_HID_STATE_FLAG_SUSPENDED) != 0) returns false

    return app_usbd_hid_state_flag_test(p_hid_ctx, APP_USBD_HID_STATE_FLAG_TRANS_IN_PROGRESS) == 0; returns true, meaning that the TRANS_IN_PROGRESS flag is already set?

    Do you use the softdevice in your application? Can you check that the CRITICAL_REGION_ENTER/EXIT() is mapping correctly based on whether you use the softdevice or not?

    For debugging purposes, can you try to debug to see whether app_usbd_hid_kbd_key_control() is being called several times before the previous call to it was finished? (This can happen if you call it from several interrupts with different priorities).

    However, the CRITICAL_REGION_ENTER/EXIT() guards should prevent this from being an issue, but it looks like in your case, this flag is somehow set between app_usbd_hid_state_flag_clr() and app_usbd_hid_trans_required().

    Can you check if you have multiple interrupts that both use app_usbd_hid_kbd_control()?

  • Hi Edvin, thank you for your suggestions. in my emProject file I have got SOFTDEVICE_PRESENT defined, but it is only used when software reset device in order to run a connectivity firmware.

    So Softdevice it is not used in usb normal mode running application and Softdevice is never activated, but being that macro present CRITICAL_REGION_ENTER/EXIT is mapped to work as if Softdevice has been activated.

    In this case I could correct this, and force CRTICAL to work as it does when Softdevice is not present. But do you think it is sort of a hybrid application? Using Softdevice for connectivity firmware, should I use Softdevice for usb also? Thank you for your suggestion, maybe I have to check that this is not going to mess software behavior elsewhere.

Reply
  • Hi Edvin, thank you for your suggestions. in my emProject file I have got SOFTDEVICE_PRESENT defined, but it is only used when software reset device in order to run a connectivity firmware.

    So Softdevice it is not used in usb normal mode running application and Softdevice is never activated, but being that macro present CRITICAL_REGION_ENTER/EXIT is mapped to work as if Softdevice has been activated.

    In this case I could correct this, and force CRTICAL to work as it does when Softdevice is not present. But do you think it is sort of a hybrid application? Using Softdevice for connectivity firmware, should I use Softdevice for usb also? Thank you for your suggestion, maybe I have to check that this is not going to mess software behavior elsewhere.

Children
No Data
Related