<?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>k_msgq_get does not wait till the given timeout period</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/96121/k_msgq_get-does-not-wait-till-the-given-timeout-period</link><description>Hi, 
 I am using Echo bot example in nrf connect sdk v.2.0.2 
 I have connected my UART to BG95 module and i am able to send and recieve data 
 but , the problem is, 
 
 when i run the above set, first time it works perfect, it waits for 8 secs as given</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 31 Jan 2023 07:52:20 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/96121/k_msgq_get-does-not-wait-till-the-given-timeout-period" /><item><title>RE: k_msgq_get does not wait till the given timeout period</title><link>https://devzone.nordicsemi.com/thread/407218?ContentTypeID=1</link><pubDate>Tue, 31 Jan 2023 07:52:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e47c3554-5fd5-43d4-91e8-df19bdc5f6ea</guid><dc:creator>Vignesh R</dc:creator><description>&lt;p&gt;Hey, thank u so much, it worked here&lt;/p&gt;
&lt;p&gt;Now i understood that.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: k_msgq_get does not wait till the given timeout period</title><link>https://devzone.nordicsemi.com/thread/407030?ContentTypeID=1</link><pubDate>Mon, 30 Jan 2023 09:22:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6b6f10ec-5a04-459c-8b7a-f0c10daf32ff</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;K_TIMEOUT_ABS_MS will create a timeout on an absolute value, in your case;&amp;nbsp;always after 8000 ms has elapsed in your system:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v2.7.99-ncs1-1/include/kernel.h#L1200-L1211"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/v2.7.99-ncs1-1/include/kernel.h#L1200-L1211&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Try changing to K_MSEC(...) instead and see if that works better.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: k_msgq_get does not wait till the given timeout period</title><link>https://devzone.nordicsemi.com/thread/406957?ContentTypeID=1</link><pubDate>Sat, 28 Jan 2023 12:21:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a4c53412-105f-4ad0-bd45-02f34bd0e527</guid><dc:creator>Vignesh R</dc:creator><description>&lt;p&gt;Here&amp;#39;s my main for reference&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void main(void)
{
	char tx_buf[MSG_SIZE];

	if (!device_is_ready(uart_dev)) {
		printk(&amp;quot;UART device not found!&amp;quot;);
		return;
	}

	/* configure interrupt and callback to receive data */
	uart_irq_callback_user_data_set(uart_dev, serial_cb, NULL);
	uart_irq_rx_enable(uart_dev);

	print_uart(&amp;quot;Hello! I&amp;#39;m your echo bot.\r\n&amp;quot;);
	print_uart(&amp;quot;Tell me something and press enter:\r\n&amp;quot;);
	uint32_t uptime;
	uptime = k_uptime_get();
	printf(&amp;quot;uptime_1:%d&amp;quot;,uptime);
	/* indefinitely wait for input from the user */
	while (k_msgq_get(&amp;amp;uart_msgq, &amp;amp;tx_buf, K_TIMEOUT_ABS_MS(8000)) == 0) {
		print_uart(&amp;quot;Echo: &amp;quot;);
		print_uart(tx_buf);
		print_uart(&amp;quot;\r\n&amp;quot;);
	}
	uptime = k_uptime_get();
	printf(&amp;quot;uptime_2:%d&amp;quot;,uptime);
	while (k_msgq_get(&amp;amp;uart_msgq, &amp;amp;tx_buf, K_TIMEOUT_ABS_MS(8000)) == 0) {
		print_uart(&amp;quot;Echo: &amp;quot;);
		print_uart(tx_buf);
		print_uart(&amp;quot;\r\n&amp;quot;);
	}
		uptime = k_uptime_get();
	printf(&amp;quot;uptime_3:%d&amp;quot;,uptime);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;and the output&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;*** Booting Zephyr OS build v3.0.99-ncs1-1  ***
Hello! I&amp;#39;m your echo bot.
Tell me something and press enter:
uptime_1:419uptime_2:8000uptime_3:8001&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>