Dear Chris,
Brilliant! It worked perfectly.
Beside this, i have a question on the os_msys_get_pkthdr function
parameters; because no matter how i changed the param doesn't make any
changes to the result and by looking into some examples eg:
Ble_adaptor.c it just put m = os_msys_get_pkthdr(0, 0) ;
Can you elaborate more on this so i know how to assign the values to it.
Thank you very much.
Regards,
Then Yoong Ze
On 3/1/2017 6:18 AM, Christopher Collins wrote:
Hi Then,
On Mon, Jan 02, 2017 at 06:26:05PM +0800, then yon wrote:
Dear Chris,
I tried to apply your solution but i stuck somewhere in middle as the
handler parameter is diff that cause build error
void shell_task_handler(void *arg)
static void queue_task_handler(struct os_event *ev)
1. At os_eventq_init(&shell_task_evq);
2. At os_task_init(&queue_task, "queue", queue_task_handler, NULL,
QUEUE_TASK_PRIO, OS_WAIT_FOREVER, queue_stack, QUEUE_STACK_SIZE);
I have attached a copy of main.c which incorporates the "option 1" that
I mentioned in my last email. I also had to make a few other changes to
successfully test this change. I will briefly describe them below.
1. Rename shell_{task,stack,etc.} to data_[...]. This is probably just
to scratch an OCD itch, but I had a hard time with this because the
shell task wasn't actually related to the shell.
2. Don't perform 1,000,000 GPIO writes upfront. When I tested this in
sim, the GPIO writes were taking too long. Since the work task has the
highest priority, this means the mqueue operations never took place.
This could just be a sim thing, though, since sim calls printf on each
GPIO set.
3. Don't allocate the mbuf on the stack; get it from
os_msys_get_pkthdr() instead. This change is analogous to changing a
variable from being automatic (stack) to dynamic via a call to malloc().
It is important that the mbuf is dynamic because:
* It is passed to a different task, so when it gets processed, the
original stack's contents are lost.
* It gets freed via a call to os_mbuf_free_chain(). When you try to
free an mbuf on the stack, you will get a very confusing crash
that will take all day to debug. I'm afraid I know this from
experience :).
4. Don't call shell_init() explicitly. The shell package gets
initialized automatically by the sysinit mechanism.
5. The changes I mentioned earlier:
* Remove the queue_task_evq
* Associate the mqueue with blinky_evq (used to be queue_task_evq).
Thanks,
Chris