Hi Then,

On Mon, Jan 02, 2017 at 01:23:33PM +0800, then yon wrote:
> Dear Support,
> 
> I been using MyNewt v1.0.0-dev, and i tried to make use of Mqueue.
> 
> What i did was following the tutorial below:
> 
> https://mynewt.apache.org/os/core_os/mqueue/mqueue/
> Since the tutorial is not updated, i tried to modify it but unfortunately i 
> can't make it work.

[...]

Your code looks good.  There is just one crucial step missing: a task
needs to poll the eventq you created (queue_task_evq).  Just to clarify
how mqueues work: when os_mqueue_put() is called, two things happen:
    1. The specified mbuf is placed on the mqueue.
    2. The event associated with the mqueue is put on the specified
       eventq, but only if the event is not already enqueued.

If a task is listening on the eventq, then it can your mqueue processing
function when it sees the mqueue event.

I think you have two options:
    1. Remove queue_task_evq from your code; use the other eventq
       (blinky_evq) with your mqueue.  blinky_evq is already being
       processed correctly by the shell_task_handler() function, so if
       you enqueue an mqueue event to it, your mqueue data will get
       processed.

    2. Create an additional task which processes the queue_task_evq
       eventq.  This task's handler would probably look identical to
       shell_task_handler(), i.e., a tight loop that repeatedly calls
       os_eventq_run().

I recommend trying the simpler option 1 first.  Generally, it is best to
minimize the number of tasks your app uses so that it requires less RAM.

Thanks,
Chris

Reply via email to