patacongo commented on issue #5412:
URL:
https://github.com/apache/incubator-nuttx/issues/5412#issuecomment-1030362138
Yes, NuttX always supporting sending messages from interrupt handlers.
Sorry to hear that has been broken.
The original IPC philosophy was that the providing side of all IPCs
should work from interrupt handlers: messages, semaphores, signals, etc.
On 2/4/2022 9:58 AM, szymonm wrote:
>
> Hello everyone,
>
> I have a problem with the message queue driver. I am currently porting
> our project of the current version of NuttX. So up until now, our
> project was using NuttX 8.2 and I am working on making it functional
> with NuttX 10.2.
>
> Anyway, in one part of our project, we want to put some data on a
> message queue from an interrupt service routine.
>
> static int stm32_ubx_tp_irq_handler(int irq, FARvoid *context, FARvoid
*arg)
> {
> struct data_to_send dummy;
> (....)
> mq_send(mq, (char*)&dummy,sizeof(struct data_to_send),0);
> return 0;
> }
>
> And it worked flawlessly on NuttX 8.2, but after porting the project
> to NuttX 10.2 this operation triggers assertion.
> To be specific, this is the assertion that is being triggered
>
<https://github.com/apache/incubator-nuttx/blob/master/sched/semaphore/sem_wait.c#L78>:
>
> int nxsem_wait(FARsem_t *sem)
> {
> FARstruct tcb_s *rtcb =this_task();
> irqstate_t flags;
> int ret = -EINVAL;
>
> /* This API should not be called from interrupt handlers */
>
> DEBUGASSERT(sem !=NULL &&up_interrupt_context() ==false);
>
> So, I have looked into the history of changes and it turns out that
> between 8.2 and 10.2 the function |nxmq_send()| has been modified. In
> the older version, it was only executing the logic related to putting
> an item in the message queue, but now it has to obtain the file struct
> instance first, and obtaining it using regular mechanisms fails
> because of the fact that we are doing it from an ISR.
> The current call order is like this:
> |mq_send -> nxmq_send -> fs_getfilep -> _files_semtake ->
> nxsem_wait_uninterruptible -> nxsem_wait -> ASSERTION TRIGGERED|
>
> So my question is, what is the correct way on NuttX 10.2 to send an
> item using a message queue from ISR? The documentation doesn't say
> anything about it not being possible
>
<https://cwiki.apache.org/confluence/display/NUTTX/User+Guide#Message_Queue>.
> I was also not able to find an alternative API (some RTOSes I have
> worked with in the past had two separate functions for that, like for
> example |msgq_send()| and |msgq_send_from_isr()|)
>
> —
> Reply to this email directly, view it on GitHub
> <https://github.com/apache/incubator-nuttx/issues/5412>, or
> unsubscribe
>
<https://github.com/notifications/unsubscribe-auth/ABFUG6TZ5G4QY5OUDEF5Z43UZPZSBANCNFSM5NSE5FTA>.
> Triage notifications on the go with GitHub Mobile for iOS
>
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
> or Android
>
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
>
> You are receiving this because you are subscribed to this
> thread.Message ID: ***@***.***>
>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]