<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Wayson Chan</title>
    <description>The latest articles on DEV Community by Wayson Chan (@w4ysonch).</description>
    <link>https://dev.to/w4ysonch</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3986704%2F87127f81-1341-47e6-ac0b-f960f503ad73.png</url>
      <title>DEV Community: Wayson Chan</title>
      <link>https://dev.to/w4ysonch</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/w4ysonch"/>
    <language>en</language>
    <item>
      <title>I got tired of hand-rolling message queues in FreeRTOS. So I built embedmq.</title>
      <dc:creator>Wayson Chan</dc:creator>
      <pubDate>Tue, 16 Jun 2026 06:13:24 +0000</pubDate>
      <link>https://dev.to/w4ysonch/i-got-tired-of-hand-rolling-message-queues-in-freertos-so-i-built-embedmq-47l3</link>
      <guid>https://dev.to/w4ysonch/i-got-tired-of-hand-rolling-message-queues-in-freertos-so-i-built-embedmq-47l3</guid>
      <description>&lt;p&gt;Every FreeRTOS project I've worked on has the same problem.&lt;/p&gt;

&lt;p&gt;You have a sensor task that reads temperature. You have a UI task that needs to display it. So you create a QueueHandle_t, pass it to both tasks at init, call xQueueSend on one side and&lt;br&gt;
xQueueReceive on the other. Fine.&lt;/p&gt;

&lt;p&gt;Then you add a WiFi task that also needs temperature. You add another queue. Then a logging task. Another queue. Soon your app_init() is a mess of queue handles being passed around, and&lt;br&gt;
changing one task means touching everything it's connected to.&lt;/p&gt;

&lt;p&gt;On bare metal it's the same story in a different shape — a dozen global flags in main: if (flag_sensor) ... if (flag_button) ... if (flag_timer) ..., each one added as the project grows,&lt;br&gt;
none of them easy to trace back to where they're set.&lt;/p&gt;

&lt;p&gt;On embedded Linux it's pointers — modules holding direct references to each other, so a change in one ripples everywhere.&lt;/p&gt;

&lt;p&gt;I wanted one solution that works across all three without rewriting the dispatch logic every time.&lt;/p&gt;

&lt;p&gt;embedmq collapses it to 3 functions:&lt;/p&gt;

&lt;p&gt;embedmq_register(q, "sensor.temp", on_temp, NULL); // subscriber&lt;br&gt;
embedmq_post(q, "sensor.temp", &amp;amp;data, sizeof(data)); // producer, any thread/task&lt;/p&gt;

&lt;p&gt;No shared queue handles. No global flags. No direct pointers between modules. The library handles the ring buffer, the mutex, and the semaphore wakeup.&lt;/p&gt;

&lt;p&gt;Same API, three platforms:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Linux: pthread + POSIX semaphore, zero external dependencies&lt;/li&gt;
&lt;li&gt;FreeRTOS: counting semaphore + xTaskCreate, static mode for zero heap after init&lt;/li&gt;
&lt;li&gt;Bare-metal: C11 atomic spinlock, drive dispatch with embedmq_poll() from your superloop&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;FreeRTOS PAL is verified on the POSIX simulator in CI — not real hardware yet, I'll be honest about that.&lt;/p&gt;

&lt;p&gt;GitHub: &lt;a href="https://github.com/w4ysonch/embedmq" rel="noopener noreferrer"&gt;https://github.com/w4ysonch/embedmq&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Happy to answer questions about the design or the FreeRTOS porting details.&lt;/p&gt;

</description>
      <category>c</category>
      <category>opensource</category>
      <category>freertos</category>
      <category>embedded</category>
    </item>
  </channel>
</rss>
