Anonymous
Not applicable
Feb 26, 2013
01:29 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Feb 26, 2013
01:29 PM
[WICED-SDK-2.2.1]
I want to create a simple program that calls sntp_get_time() periodically.
I attempted to register a timed event, similarly to the UDP timed event which works fine.
/* Register a function to process received UDP packets */ wiced_rtos_register_timed_event( &process_udp_rx_event, WICED_NETWORKING_WORKER_THREAD, &process_received_udp_packet, UDP_CHECK_PERIOD, 0 ); /* Register a function to update the time */ wiced_rtos_register_timed_event( &process_ntp_event, WICED_NETWORKING_WORKER_THREAD, &process_ntp_time, TIME_UPDATE_PERIOD, 0 );
The above timed event called the function below around 8 times and
then stopped. If I commented out the UDP timed event it would run OK.
Why doesnt this work?
Labels
- Labels:
-
TCPIP
- Tags:
- &process_ntp_event
- &process_ntp_time
- &process_received_udp_packet
- &process_udp_rx_event
- [wiced-sdk-2.2.1]
- attempted
- called
- calls
- commented
- create
- event
- fine
- function
- issue
- packets
- periodically
- process
- program
- received
- register
- similarly
- simple
- sntp_get_time
- stopped
- time
- time_update_period
- timed
- times
- udp_check_period
- update
- wiced_networking_worker_thread
- wiced_rtos_register_timed_event
- work
- works
2 Replies
Anonymous
Not applicable
Feb 26, 2013
01:42 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Feb 26, 2013
01:42 PM
For convenience purposes, WICED provides two worker threads dedicated to doing asynchronous work.One for networking activity (WICED_NETWORKING_WORKER_THREAD) and the other for non-networking activity (WICED_HARDWARE_IO_WORKER_THREAD). The network worker thread pulls function pointers out of a message queue and executes them in order of insertion.Functions that may take a long time to complete eg. sntp_get_time(), which has a five second receive timeout, can cause situations where the message queue fills with other jobs such as process_received_udp_packet(). As a general rule you should NOT register a timed event at a rate faster than the longest time the function will take to execute/timeout.If you want to ensure responsiveness to multiple timed events, you can either setup shorter timeout periods for each event and call them regularly, or create additional worker threads. Is there a particular reason you need to poll the NTP server once a second? Once or twice a day should be sufficient assuming the microprocessor clock isnt too far out.
Anonymous
Not applicable
Feb 26, 2013
02:13 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Feb 26, 2013
02:13 PM
You are correct, I only need to execute the sntp_get_time() function one or twice a day. I was executing it more frequently just for test purposes. So it looks like I do in fact need to use the second worker thread.