2016-12-06 06:04 AM
Hi,
I was checking through the implementation of osSignal in the file installed by STM32CubeMX to 'Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS/cmsis_os.c'
The
http://www.keil.com/pack/doc/CMSIS/RTOS/html/group__CMSIS__RTOS__SignalMgmt.html
specifies that the call to osSignalWait will 'Suspend the execution of the current
runningthread until ALL specified signal flags with the parametersignalsare set.'This is exactly the behavior of the FreeRTOS function
http://www.freertos.org/xEventGroupWaitBits.html
. However, in the osSignal implementation, the FreeRTOS primitive 'TaskNotify' is used. As noted onhttp://www.freertos.org/RTOS_Task_Notification_As_Event_Group.html
, 'Unlike when using an event group the receiving task cannot specify that it only wants to leave the Blocked state when a combination of bits are active at the same time. Instead the task is unblocked when any bit becomes active, and must test for bit combinations itself.'This means that the osSignal functionality does not behave as specified.
Please let me know if I have misunderstood the situation, or please let me know how this can be fixed?
Cheers,
Oskar
#cmsis-rtos #freertos2016-12-21 02:10 AM
Hi Oskar,
Unfortunately the osSignalClear is not implemented in stm32Cubemx. Only he declaration is exists on cmsis_os.c
by
Zamek
2016-12-21 05:34 AM
Hello,
osSignal functionality is not supported by STM
32CubeMx
.In fact, the osSignalClear
function is specified in the generic cmsis_os wrapper for RTOS, but it is not supported by FreeRtos.Maybe you can review the example in the Cube package firmware to
get more details on how to use and apply
osSignal functionality.
Best Regards
Imen
2017-01-17 11:29 AM
Hello,
I do believe that you specify in your user manual
on page 14 that the osSignal functionality is available and supported.I do see that osSignalClear is not implemented, but it is the behaviour of osSignalWait (and by extension osSignalSet) that I am using, and which is incorrect. The specification says that ALL required bits have to be set for the control to be released, but the implementation by the ST MCD Application Team releases the control as soon as ANY signal is received.
Cheers,
Oskar
2017-01-20 11:19 AM
Signals are supported but yes, the behavior is not what is to be expected. osSignalClear is there in prototype, but not implemented. What happens is the signal is clear and therefore runs the first time, then it behaves as expected.
2017-02-01 08:44 AM
I'm also suffering with issues regarding osSignal management in the cmsis_os abstraction layer (poorly) provided by ST, is there a way to remove the abstraction layer from the code generation in CubeMX? So the code will be generated with FreeRTOS calls instead of
cmsis_os calls?
In this way, I can standardize the use of the FreeRTOS in my application, without mixing cmsis_os calls with direct FreeRTOS calls
I can deal with the portability loss in order to keep my API calls standardized all over my application source.
2017-03-15 02:59 AM
As of the most recent HAL version. osSignal functions (except clear) seem to be working as expected.
Using signals is by far the fastest inter-thread communication scheme. Best when used to schedule high priority ISR callbacks:
void HAL_CAN_RxCpltCallback(CAN_HandleTypeDef* hcan)
{
if( hcan->Instance == CAN1 )
{
osSignalSet(can_rx_taskHandle, CAN_RX_ISR_FLAG);
}
}�?�?�?�?�?�?�?
2017-03-20 11:42 AM
Which version of cmsis_os.c do you have? I have 'CMSIS-RTOS API implementation for FreeRTOS V8.2.3' and I still see the inconsistent implementation of osSignalWait, which will wake-up on ANY signal (regardless of the specified signals, which are only a clear mask but not a filter) instead of waiting for all specified signals to be set.
2017-03-20 04:09 PM
FreeRTOS v9.0.0
CMSIS v1.02I can't comment on multiple signals since in the last application I wrote I was only using single flags with all signals. But, looking through the function that sets and waits for the flag looks to be functional:
Found in tasks.c / FunctionxTaskGenericNotifyFromISR approx line 4888
switch( eAction )
{
case eSetBits:
pxTCB->ulNotifiedValue |= ulValue;
break;
case eIncrement:
( pxTCB->ulNotifiedValue )++;
break;
case eSetValueWithOverwrite:
pxTCB->ulNotifiedValue = ulValue;
break;
�?�?�?�?�?�?�?�?�?�?�?�?�?
Appears correct.
Compare that with the version you have.
2017-04-04 01:47 PM
I've been using the signal flags extensively these past weeks and can proclaim they are working as desired.
But...
You have to use them like the
states.Once you set a signal:
osSignalSet(my_super_thread, MY_GO_FLAG);�?�?
You need to check for it in the thread like so:
osEvent evt;
for(;;)
{
evt = osSignalWait(MY_GO_FLAG, osWaitForever);
if( evt.value.signals & MY_GO_FLAG)
{
...magic goes here.
}
if( evt.value.signals & MY_EXTRA_FLAG )
{
... more magic happens.
}
}�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?
I have a few threads with at least 4 signals on it and all works as advertised.