Re: Drift through k_sleep or k_msleep
#api
Nikolaus Huber
Thank you all for your answers!
I was kind of assuming that I could achieve this by using a timer. I think that that might be the nicest solution for my use case. I was just wondering if Zephyr maybe has an API similar to FreeRTOS with a dedicated delay command that eliminates drifts. But I guess using a timer actually makes it a bit more explicit. Thank you very much :) /Nick När du har kontakt med oss på Uppsala universitet med e-post så innebär det att vi behandlar dina personuppgifter. För att läsa mer om hur vi gör det kan du läsa här: http://www.uu.se/om-uu/dataskydd-personuppgifter/ E-mailing Uppsala University means that we will process your personal data. For more information on how this is performed, please read here: http://www.uu.se/en/about-uu/data-protection-policy
|
|
Re: Drift through k_sleep or k_msleep
#api
Erik Englund
I guess the internals of this uses a semaphore aswell to get realtime performance. If you control the semaphore yourself as per my example, you can check the status of the semaphore in the end of the function to see if the timer has expired while the work was running, if so, you have a realtime problem. We use this technique in Zephyr within a few PLC-type controller products, using 1000 ticks/second rate and cycletime of 10ms. Med vänlig hälsning Erik Englund Innoware Development AB Hyttvägen 13 73338 SALA Org.nr. 556790-2977 www.innoware.se Den ons 3 feb. 2021 kl 21:10 skrev Michael Rosen <michael.r.rosen@...>:
|
|
Re: Drift through k_sleep or k_msleep
#api
Michael Rosen
Nick,
The design pattern Ive seen for this kind of thing uses the Timer API instead of sleep:
struct k_timer timer; k_timer_init(&timer, NULL, NULL); … k_timer_start(&timer, 0, K_MSEC(1000)); while (1) { k_timer_status_sync(&timer); … }
This lets the body of the main loop run only when the timer expires, and the periodic timer avoid drift from resetting the timer at the top of each loop.
Mike
From: users@... <users@...>
On Behalf Of Erik Englund
Sent: Wednesday, February 3, 2021 2:38 PM To: Nikolaus Huber <nikolaus.huber@...> Cc: users@... Subject: Re: [Zephyr-users] Drift through k_sleep or k_msleep #api
One possible solution is to create a periodic timer and post to a semaphore in the timer callback. A thread could simply wait on the semaphore in an endless loop.
Linux clock_nanosleep (mostly used togheter with Preempt-rt patch) would be a nice addition to Zephyr, that would solve these kinds of tasks.
Med vänlig hälsning Erik Englund
Den ons 3 feb. 2021 kl 20:31 skrev Nikolaus Huber <nikolaus.huber@...>:
|
|
Re: Drift through k_sleep or k_msleep
#api
When I need work to operate on a regular basis and not drift I create a work queue and a timer that is setup to submit the work to the queue on a regular basis. This way it doesn’t matter how long it takes to finish the work, the next work run will still start at exactly the right time. main() calls clock_init() to get this started…
#include <stdio.h> #include <stddef.h> #include <stdint.h> #include <zephyr.h> #include <zephyr/types.h>
#define TIME_INC_FREQUENCY 10 // in secs
void my_work_handler(struct k_work *work) { // do whatever here }
K_WORK_DEFINE(my_work, my_work_handler);
void my_timer_handler(struct k_timer *dummy) { k_work_submit(&my_work); }
K_TIMER_DEFINE(my_timer, my_timer_handler, NULL);
void clock_init(void) { k_timer_start(&my_timer, K_SECONDS(TIME_INC_FREQUENCY), K_SECONDS(TIME_INC_FREQUENCY)); }
Lawrence King Principal Developer +1(416)627-7302
From: users@... <users@...>
On Behalf Of Erik Englund
Sent: Wednesday, February 3, 2021 2:38 PM To: Nikolaus Huber <nikolaus.huber@...> Cc: users@... Subject: Re: [Zephyr-users] Drift through k_sleep or k_msleep #api
One possible solution is to create a periodic timer and post to a semaphore in the timer callback. A thread could simply wait on the semaphore in an endless loop.
Linux clock_nanosleep (mostly used togheter with Preempt-rt patch) would be a nice addition to Zephyr, that would solve these kinds of tasks.
Med vänlig hälsning Erik Englund
Den ons 3 feb. 2021 kl 20:31 skrev Nikolaus Huber <nikolaus.huber@...>:
|
|
Re: Drift through k_sleep or k_msleep
#api
Erik Englund
One possible solution is to create a periodic timer and post to a semaphore in the timer callback. A thread could simply wait on the semaphore in an endless loop. Linux clock_nanosleep (mostly used togheter with Preempt-rt patch) would be a nice addition to Zephyr, that would solve these kinds of tasks. Med vänlig hälsning Erik Englund Innoware Development AB Hyttvägen 13 73338 SALA Org.nr. 556790-2977 www.innoware.se Den ons 3 feb. 2021 kl 20:31 skrev Nikolaus Huber <nikolaus.huber@...>:
Hi all,
|
|
Drift through k_sleep or k_msleep
#api
Nikolaus Huber
Hi all,
I was recently wondering about the correct usage of k_sleep or k_msleep for implementing periodic tasks. In FreeRTOS for example there is a function vTaskDelayUntil which takes a timestamp and a number of ticks to delay. By taking the timestamp at the beginning of the execution of a task we can then make sure that its release time does not slowly drift. So far I have not seen anything similar in Zephyr. Am I missing something, or do I have to somehow create a similar mechanism on my own by measuring the uptime at the release of a periodic task and then again just before using any sleep function to calculate the exact sleep time I want? Thank you very much in advance, Nick
|
|
Jukka Rissanen
Hi Jurgens, have you tried to connect to Azure using for example qemu, this way we could rule out issues in modem config? I did not spot anything obviously wrong in your main.c, but as you have noticed, there are lot of moving parts when connecting to azure using mqtt, so it can be challenging to get things right. Cheers, Jukka
On Wed, 2021-02-03 at 03:00 -0800, petrus.vanderwalt@... wrote: Hi everyone,
|
|
petrus.vanderwalt@...
Hi everyone,
I am really struggling to get the mqtt_azure sample working. It just does not want to connect to IoT hub. Thank you once again for your assistance @Jukka. Can anyone help me to get this working? I am not sure if the issue is related to Azure details that are different from what is recommended by Microsoft or if it is an issue due to using a modem overlay. I would really appreciate it if someone could help me get this working. I have added the project files that have changed. Regards, Jurgens
|
|
Re: undefined reference to `__bswapdi2' when trying to link tinycbor for RISC-V
Kumar Gala
On Jan 29, 2021, at 1:42 PM, Stefan Hristozov <stefan.hristozov@...> wrote:Based on the gcc line, you are getting libgcc pulled in via -L"/opt/zephyr-sdk-0.11.3/riscv64-zephyr-elf/bin/../lib/gcc/riscv64-zephyr-elf/9.2.0” and -lgcc. What version of zephyr are you using? Have you tried running the link with a -Wl,--start-group …. -Wl,—end-group? - k
|
|
API meeting cancelled today
Carles Cufi
Hi all,
I am cancelling the API meeting today due to a conflict and the fact that there were no scheduled discussions to take place besides going over the current open GitHub issues to fix for 2.5. If you did have something you wanted to bring up, please let me know and I'll schedule it for next week. Thanks, Carles
|
|
Network forum agenda
Jukka Rissanen
Hi all,
There is a network forum meeting tomorrow Tue 2 Feb at 8AM PST / 17.00 CET. Currently the agenda is empty, so if there is anything network related topics you want to discuss, please let me know. Live Agenda/Minutes: https://docs.google.com/document/d/1qFsOpvbyLzhflJbbv4Vl__497pKHDoUCy9hjAveyCX0/edit?usp=sharing Shared Folder: https://drive.google.com/drive/folders/1j6d0FLeOjiMil1Ellb59AsfHdzuWdAAc?usp=sharing ___________________________________________________________ Join Microsoft Teams Meeting ( https://teams.microsoft.com/l/meetup-join/19%3ameeting_NDU5ODRkNzktZDBmNC00MDg5LWI2OWEtNzM0MGZjMDU0Yjgw%40thread.v2/0?context=%7b%22Tid%22%3a%22af0096d9-700c-411a-b795-b3dd7122bad2%22%2c%22Oid%22%3a%22841a7c92-7816-4faf-9887-5e334e88f6d8%22%7d ) +1 321-558-6518 ( tel:+1 321-558-6518,,458216365# ) United States, Orlando (Toll) Conference ID: 458 216 365# Local numbers ( https://dialin.teams.microsoft.com/325d775d-c910-441e-90d0-353ebaa56cdd?id=458216365 ) | Reset PIN ( https://mysettings.lync.com/pstnconferencing ) | Learn more about Teams ( https://aka.ms/JoinTeamsMeeting ) | Meeting options ( https://teams.microsoft.com/meetingOptions/?organizerId=841a7c92-7816-4faf-9887-5e334e88f6d8&tenantId=af0096d9-700c-411a-b795-b3dd7122bad2&threadId=19_meeting_NDU5ODRkNzktZDBmNC00MDg5LWI2OWEtNzM0MGZjMDU0Yjgw@thread.v2&messageId=0&language=en-US ) Cheers, Jukka
|
|
undefined reference to `__bswapdi2' when trying to link tinycbor for RISC-V
Stefan Hristozov
I am getting undefined reference to `__bswapdi2' when I am trying to link tinycbor for RISC-V (west build -b=hifive1)
stefan@t460s:~/workspaces/oscore-edhoc/test$ west build -b=hifive1With grep I can see that this function is available in libgcc.a for RISC-V stefan@t460s:/opt/zephyr-sdk-0.11.3/riscv64-zephyr-elf$ grep -nrw '__bswapdi2'How to tell my zephyr project to use libgcc?
|
|
NRF52832 - LPCOMP wakeup example
Martin Kozusky
Hello,
does anybody have working example of using LPCOMP in NRF52832 to wakeup MCU from sleep mode (when input voltage gets above setup voltage) and then read somewhere that it has been woken by LPCOMP interrupt (and if possible, also the voltage of analog input when it was triggered, but I don't see register for this value in datasheet) I see there is NRFX_LPCOMP config, but how can I use that? Thank you, Martin
|
|
petrus.vanderwalt@...
Hi Jukka,
I only had to add a board overlay for my nRF52840 in order to get the gsm_modem sample up and running. Drivers specifically for the Quectell BG 96 and Sara 412 are available in Zephyr. I actually want to connect to azure on both methods, MQTT and HTTPS post. I will try to use TagoIO as a base and see if it works with Azure configs and let you know if it works. Thanks for telling me where to find the errors. I was searching for them in the errorno.h. Have a great day, Jurgens
|
|
Jukka Rissanen
Hi Petrus, On Thu, 2021-01-28 at 03:49 -0800, petrus.vanderwalt@... wrote: Hi, Zephyr community. I am trying to add Azure MQTT functionality to my project. I am using an nRF52840 with a Quectel BG96/Sara R412M-02B. I would also like to use the modem functionality to communicate to cellular towers over PPP. Did you need to do any changes to generic gsm modem in order to get the BG96 or SARA modem working. I do not have these modems, so would be interested to know if they worked ok without any special modifications. To you other question, do you want to connect to azure without using mqtt? Then probably you could use the tagio as a base and change it according to relevant configs found in azure sample. If you get this working, it would be nice to have a separate sample for this.
The 116 errno is ETIMEDOUT and comes from newlib which can be found in Zephyr SDK. Cheers, Jukka
|
|
petrus.vanderwalt@...
Hi, Zephyr community. I am trying to add Azure MQTT functionality to my project. I am using an nRF52840 with a Quectel BG96/Sara R412M-02B. I would also like to use the modem functionality to communicate to cellular towers over PPP.
Currently, I have the gsm_modem sample up and running for my Quectel BG96 and U-Blox SARA R412. I also have the tagio_http_post sample up and running. I would also want to adapt the tagio_http_post sample to work for Azure. Would this be easy to do? Have anyone tried to do this? I am now playing around with the mqtt_azure sample. I have added PPP support by adding a modem overlay. I had to disable the DHCPV4 and use a static IP address. The sample successfully resolves the DNS for azure. The issue comes thereafter. The sample fails to connect. The following is the output I get: [00:00:13.283,172] <inf> modem_gsm: Manufacturer: u-blox [00:00:13.362,243] <inf> modem_gsm: Model: SARA-R412M-02B
[00:00:13.442,871] <inf> modem_gsm: Revision: M0.10.00 [Mar 28 2019 17:13:41]
[00:00:13.523,864] <inf> modem_gsm: IMSI: 655014150468485
[00:00:13.604,797] <inf> modem_gsm: ICCID: 89415000000004684852
[00:00:13.685,394] <inf> modem_gsm: IMEI: 354679092855504
[00:00:13.847,473] <inf> modem_gsm: Attached to packet service!
[00:00:13.880,706] <inf> net_ppp: Initializing PPP to use UART_1
[00:00:13.904,815] <inf> net_config: Interface 1 (0x20000544) coming up
[00:00:13.931,030] <inf> net_config: IPv4 address: 192.0.2.1
[00:00:13.954,803] <dbg> mqtt_azure.main: Waiting for network to setup...
[00:00:15.979,888] <err> mqtt_azure: DNS not resolved for WCM.azure-devices.net:
[00:00:16.744,842] <inf> mqtt_azure: DNS resolved for WCM.azure-devices.net:8883
[00:00:16.770,294] <dbg> mqtt_azure.try_to_connect: attempting to connect...
[00:00:19.802,642] <err> mqtt_azure: mqtt_connect failed -116
[00:00:22.833,923] <err> mqtt_azure: mqtt_connect failed -116
[00:00:25.865,234] <err> mqtt_azure: mqtt_connect failed -116 I can not seem to find the definition of error -116. Does anyone have an idea what this error is referring to? This is my Azure config: #define CONFIG_SAMPLE_CLOUD_AZURE_USERNAME "XXX.azure-devices.net/Device-01/?api-version=2018-06-30"
#define CONFIG_SAMPLE_CLOUD_AZURE_PASSWORD "1XbHvFPxHZq1cD380GqCcCxUOAv3SXtecBRGGIXXXXg="
#define CONFIG_SAMPLE_CLOUD_AZURE_CLIENT_ID "Device-01"
#define CONFIG_SAMPLE_CLOUD_AZURE_HOSTNAME "XXX.azure-devices.net"
#define CONFIG_SAMPLE_CLOUD_AZURE_SERVER_ADDR "XXX.61.54.255"
#define CONFIG_SAMPLE_CLOUD_AZURE_SERVER_PORT 8883
My project config as follows: CONFIG_NETWORKING=y
# Disable IPv6 support
CONFIG_NET_IPV6=n
# Enable IPv4 support
CONFIG_NET_IPV4=y
CONFIG_NET_IF_MAX_IPV4_COUNT=2
CONFIG_NET_IF_UNICAST_IPV4_ADDR_COUNT=3
# Enable TCP support
CONFIG_NET_TCP=y
# Enable Sockets support
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_SOCKOPT_TLS=y
# Disable DHCPv4 and use static address
CONFIG_NET_DHCPV4=n
# Use local DNS server on host
CONFIG_DNS_SERVER1="192.0.2.2"
# Configure static addresses
CONFIG_NET_CONFIG_MY_IPV4_ADDR="192.0.2.1"
CONFIG_NET_CONFIG_MY_IPV4_GW="192.0.2.2"
# Enable SOCKS5 proxy support
CONFIG_SOCKS=n
# Enable MQTT Lib support
CONFIG_MQTT_LIB=y
CONFIG_MQTT_LIB_TLS=y
# Enable Mbed TLS configuration
CONFIG_MBEDTLS=y
CONFIG_MBEDTLS_BUILTIN=y
CONFIG_MBEDTLS_ENABLE_HEAP=y
CONFIG_MBEDTLS_HEAP_SIZE=100000
CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=10240
CONFIG_MBEDTLS_PEM_CERTIFICATE_FORMAT=y
# Network configuration
CONFIG_NET_CONFIG_SETTINGS=y
# Network connection manager
CONFIG_NET_CONNECTION_MANAGER=y
CONFIG_NET_MGMT_EVENT_STACK_SIZE=1024
CONFIG_NET_MGMT_EVENT_QUEUE_SIZE=5
CONFIG_NET_MGMT_EVENT_LOG_LEVEL_DBG=n
CONFIG_DNS_RESOLVER=y
CONFIG_DNS_SERVER_IP_ADDRESSES=y
CONFIG_DNS_SERVER1="8.8.8.8"
CONFIG_DNS_RESOLVER_ADDITIONAL_BUF_CTR=2
CONFIG_NEWLIB_LIBC=y
CONFIG_INIT_STACKS=y
CONFIG_NET_SHELL=y
CONFIG_MAIN_STACK_SIZE=4096
# Enable Logging support
CONFIG_LOG_IMMEDIATE=y
CONFIG_NET_LOG=y
CONFIG_NET_TCP_LOG_LEVEL_DBG=n
CONFIG_NET_SOCKETS_LOG_LEVEL_DBG=n
CONFIG_MQTT_LOG_LEVEL_DBG=n
CONFIG_NET_DHCPV4_LOG_LEVEL_INF=y
CONFIG_NET_IF_LOG_LEVEL_DBG=n
CONFIG_MBEDTLS_DEBUG=n
#CONFIG_MBEDTLS_DEBUG_LEVEL=4
CONFIG_SOCKS_LOG_LEVEL_DBG=n
CONFIG_NET_CONFIG_LOG_LEVEL_DBG=y
CONFIG_NET_CONNECTION_MANAGER_LOG_LEVEL_DBG=n
CONFIG_DNS_RESOLVER_LOG_LEVEL_DBG=n
CONFIG_NET_CONTEXT_LOG_LEVEL_DBG=n
My modem overlay: # UART support
CONFIG_SERIAL=y
# GSM modem support
CONFIG_MODEM=y
CONFIG_MODEM_SHELL=y
CONFIG_MODEM_CMD_HANDLER_MAX_PARAM_COUNT=20
CONFIG_MODEM_GSM_PPP=y
CONFIG_MODEM_GSM_RX_STACK_SIZE=1024
CONFIG_MODEM_GSM_UART_NAME="UART_1"
CONFIG_MODEM_GSM_APN="internet"
# Network management events
CONFIG_NET_CONNECTION_MANAGER=y
# PPP networking support
CONFIG_NET_NATIVE=y
CONFIG_NET_PPP=y
CONFIG_NET_L2_PPP=y
CONFIG_NET_L2_PPP_TIMEOUT=10000
CONFIG_DNS_RESOLVER_MAX_SERVERS=1
CONFIG_DNS_SERVER_IP_ADDRESSES=y
CONFIG_DNS_SERVER1="8.8.8.8"
My main.c stayed unchanged. I am hoping someone in the community has done something similar and can maybe help me out. Any help would be appreciated. Thanks, Jurgens
|
|
Re: Query regarding Bluetooth Controller Porting
Pankaj Singh <PANKAJ.SINGH@...>
Hi Carles,
toggle quoted messageShow quoted text
Thanks for sharing the information. We are planning to use uart-H4 protocol and it’s a dual mode controller. My understanding is that H4tl module on controller side will be interacting with Zephyr BT host over uart and hence there needs to be zephyr based hci driver needed in the controller as well. Please correct me if my understanding is wrong. The hci driver needs to register via bt_hci_driver_register(const struct bt_hci_driver *drv) to send/receive payload with zephyr bt host. Zephyr Host -> custom controller payload flow : bt_send() -> struct bt_hci_driver: h4_send() -> h4: net_buf_put() -> uart_tx_queue -> hci driver controller: struct bt_hci_driver drv: send() ->h4 custom controller for further processing. Controller -> host payload flow : H4 of custom controller -> hci driver controller: bt_buf_get_rx() -> bt_recv() -> bt_dev.rx_queue -> bt host: hci_rx_thread(). -thanks
-----Original Message-----
From: Cufi, Carles <Carles.Cufi@...> Sent: Wednesday, December 9, 2020 3:14 PM To: kumar.gala@...; Pankaj Singh <PANKAJ.SINGH@...>; devel@... Cc: users@... Subject: RE: [Zephyr-users] Query regarding Bluetooth Controller Porting [External Email]: This email arrived from an external source - Please exercise caution when opening any attachments or clicking on links. + devel list Pankaj, If you are using a dual-chip solution, then as long as you controller complies with standard HCI there is no "porting" to do whatsoever. In order to better understand what you need, can you let us know which transport do you plan on using (UART/H4, 3-wire/H3 or SPI) and whether it is a single-mode or dual-mode controller? Unless your controllers has special requirements it should all be a matter of configuring the right Kconfig options and Devicetree nodes. Carles -----Original Message-----
|
|
API meeting: agenda
Carles Cufi
Hi all,
Agenda for today: - Watchdog Example not working as expected on a Nordic chip Issue: https://github.com/zephyrproject-rtos/zephyr/issues/29991 - sensor: add TI FDC2X1X sensor driver and sample application PR comment: https://github.com/zephyrproject-rtos/zephyr/pull/31056#discussion_r563772691 - Go through any API-related bugs to help in the release If you have additional items please let me know. Teams link: https://teams.microsoft.com/l/meetup-join/19%3ameeting_NWU2MjZlYWEtZDcwMi00MWQzLTgwMjEtNDdkYjQwMjBjMmFj%40thread.v2/0?context=%7b%22Tid%22%3a%22af0096d9-700c-411a-b795-b3dd7122bad2%22%2c%22Oid%22%3a%22841a7c92-7816-4faf-9887-5e334e88f6d8%22%7d https://github.com/zephyrproject-rtos/zephyr/wiki/Zephyr-Committee-and-Working-Group-Meetings#zephyr-api-discussion https://github.com/zephyrproject-rtos/zephyr/projects/18 https://docs.google.com/document/d/1lv-8B5QE2m4FjBcvfqAXFIgQfW5oz6306zJ7GIZIWCk/edit Regards, Carles
|
|
SDK 0.12.2 Release
Kumar Gala
Hi,
Latest version of the SDK can be found here: https://github.com/zephyrproject-rtos/sdk-ng/releases/tag/v0.12.2 Please download and try things out and report any issues. [ I skipped the release announcement on SDK 0.12.1 so including the changes since 0.12.0 ] * Add support for MIPS * Enable EFI binary generation for x86_64 binutils * Fix to Kconfig version Thanks to all that contributed fixes and enhancements to this version of the SDK. - k
|
|
CANopen error message
Cristian Anceschi
|
|