<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>data dose not received through USB in some cases</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/50174/data-dose-not-received-through-usb-in-some-cases</link><description>Hi to all, 
 
 i am developing an product based on the nrf5240 soc and i want to implement an hid device. after receiving some commands from HID i need to gather user presence, like below: 
 
 as you can see i stuck the program in a loop to gather user</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 26 Jul 2019 12:52:46 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/50174/data-dose-not-received-through-usb-in-some-cases" /><item><title>RE: data dose not received through USB in some cases</title><link>https://devzone.nordicsemi.com/thread/200774?ContentTypeID=1</link><pubDate>Fri, 26 Jul 2019 12:52:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4ba92018-778b-4c29-9246-fae7655ebdd5</guid><dc:creator>alireza sadeghpour</dc:creator><description>&lt;p&gt;thanks, problem solved by calling&amp;nbsp;&lt;span&gt;app_usbd_event_queue_process in the while loop.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: data dose not received through USB in some cases</title><link>https://devzone.nordicsemi.com/thread/200421?ContentTypeID=1</link><pubDate>Thu, 25 Jul 2019 08:10:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c6202e8e-2e2a-4239-bcd9-b913b303d1a6</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;The HID example uses&amp;nbsp;a scheduler from the USB library by default (APP_USBD_CONFIG_EVENT_QUEUE_ENABLE 1) which means the user callback will not be called from an interrupt context, and the app needs to periodically call&amp;nbsp;app_usbd_event_queue_process() to process queued tasks. Also, the app scheduler&amp;nbsp;is not preemptive. I.e., if you have placed your loop in a scheduled task, subsequent tasks will not be processed until&amp;nbsp;your program exits the loop.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: data dose not received through USB in some cases</title><link>https://devzone.nordicsemi.com/thread/200269?ContentTypeID=1</link><pubDate>Wed, 24 Jul 2019 11:40:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9e8211a5-9089-4581-a347-5b3566f69da4</guid><dc:creator>alireza sadeghpour</dc:creator><description>&lt;p&gt;Thanks for your answer, actually i have a always loop in main function and as you implied usb packets successfully &amp;nbsp;delivered in that case.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;but in my case, i had defined &amp;quot;hid_user_ev_handler&amp;quot; function to receive HID packets like below:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;APP_USBD_HID_GENERIC_GLOBAL_DEF(ctap_hid_generic,
                                FIDO_HID_GENERIC_INTERFACE,
                                hid_user_ev_handler,
                                ENDPOINT_LIST(),
                                fido_reps,
                                REPORT_IN_QUEUE_SIZE,
                                REPORT_OUT_MAXSIZE,
                                APP_USBD_HID_SUBCLASS_NONE,
                                APP_USBD_HID_PROTO_GENERIC);
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;and in function &amp;quot;&lt;span&gt;hid_user_ev_handler&amp;quot; after receiving a usb packet i call&amp;nbsp;function &amp;quot;Usb_Proccess_Command&amp;quot;&amp;nbsp; in below manner to handle the command:&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;app_sched_event_put(NULL, 0, Usb_Proccess_Command);&lt;/pre&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;and in function&amp;nbsp;&lt;span&gt;&amp;quot;Usb_Proccess_Command&amp;quot; i check the user presence with while loop. i expected that as i called function &amp;quot;Usb_Proccess_Command&amp;quot; with &amp;quot;app_sched_event_put&amp;quot;, priority of&amp;nbsp;&amp;quot;Usb_Proccess_Command&amp;quot; was lower&amp;nbsp;than &amp;quot;hid_user_ev_handler&amp;quot;. am i correct?&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;thanks&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: data dose not received through USB in some cases</title><link>https://devzone.nordicsemi.com/thread/200262?ContentTypeID=1</link><pubDate>Wed, 24 Jul 2019 11:16:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b9a2faec-8a2e-47ea-9e23-45bc1b58855d</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Have you tried to place this code in your main loop? I&amp;#39;m wondering if maybe your code is called from another interrupt with equal or higher priority than the USB. Thus preventing the USB command from being processed by the app.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>