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

System design / thread communication

Hello,

I am evaluating what the best way is to solve this problem:
We have 2 network interfaces on our board. We would like to be able to switch between them dynamically.
Many other threads need network functionality.

Idea:
Have a networking thread that receives requests (open socket, write data, close socket) from other threads, and forwards received data to them.

What would be the best way to implement this?
- Other threads call functions that alter state of networking thread
- Other threads queue requests in a FIFO for example, and the networking thread responds in their FIFOs
- No networking thread, but then all threads must do their own socket management and stuff

I would very much appreciate some insight to help me decide the best solution! Thank you

  • Hello! 

    Thank you for reaching out! The idea of a dedicated network manager thread is good and it sounds like you can make use of the Zephyr event manager.  This library enables easy propagation of events between different modules and threads. I've had good experiences using it! However, note that it is currently limited to 32 event types.

    If the event manager does not fit your needs I recommend taking a look at the NCS Asset Tracker example. The "network thread" (cloud thread) only communicates with main, but it's a good demonstration on how event handlers can be used across threads. This application uses work queues, and is in that manner similar to your second alternative with internal FIFOs in each thread.

    Hope this helps you on your way!

    Best regards,
    Carl Richard

  • Hi Carl Richard,

    Thank you for the response and the nice suggestions. This definitely helped me on my way.

Related