Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FreeRTOS giveFromISR() when releasing within a handler #846

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mws-rmain
Copy link
Contributor

Due to a recent commit (#13523c95b42c77b4263ef98ce054962bcb338636) to esp-idf, when releasing a semaphore from within a handler, it is required to use giveFromISR() instead of give(), or an assert (freertos/queue.c:729) that verifies the release request is from the current owner will fail. I have made this change to all locations within cpp_utils where semaphore.give() was invoked from within a callback or handler, since freertos semaphore handling is generic.

I have not verified this works on pre-commit versions of esp-idf.

…Otherwise esp-idf commit 13523c95b42c77b4263ef98ce054962bcb338636 will fail when an assert verifies request to release is by owner task.
@@ -440,7 +440,7 @@ void BLECharacteristic::handleGATTServerEvent(
case ESP_GATTS_CONF_EVT: {
// ESP_LOGD(LOG_TAG, "m_handle = %d, conf->handle = %d", m_handle, param->conf.handle);
if(param->conf.conn_id == getService()->getServer()->getConnId()) // && param->conf.handle == m_handle) // bug in esp-idf and not implemented in arduino yet
m_semaphoreConfEvt.give(param->conf.status);
m_semaphoreConfEvt.giveFromISR();
Copy link
Contributor

@copercini copercini Jun 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be m_semaphoreConfEvt.giveFromISR(param->conf.status); ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you check FreeRTOS.cpp:138, the .give() variant that passes a value stores the value in m_value, which is returned by the .wait() call. Nothing is currently done with this value, so passing & storing it is irrelevant.

Also, there is currently no '.giveFromISR()' variant that passes a value (see FreeRTOS.cpp:147).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants