-
Notifications
You must be signed in to change notification settings - Fork 85
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
espidf added flush, clean task stop , commented out crashing debug log #362
Conversation
@vortex314 If this pull request contains a bugfix or a new feature, then please consider using |
Test program can be found here : https://github.com/vortex314/zenoh-projects/tree/main/zenoh-serial |
learning pull requests; Maybe shouldn´t have closed |
@@ -185,7 +185,7 @@ int8_t _z_trigger_subscriptions(_z_session_t *zn, const _z_keyexpr_t keyexpr, co | |||
zp_mutex_lock(&zn->_mutex_inner); | |||
#endif // Z_FEATURE_MULTI_THREAD == 1 | |||
|
|||
_Z_DEBUG("Resolving %d - %s on mapping 0x%x", keyexpr._id, keyexpr._suffix, _z_keyexpr_mapping_id(&keyexpr)); | |||
// _Z_DEBUG("Resolving %d - %s on mapping 0x%x", keyexpr._id, keyexpr._suffix, _z_keyexpr_mapping_id(&keyexpr)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't comment the debug lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand these pose issues when receiving something without a suffix, then I suggest you something like:
_Z_DEBUG("Resolving %d on mapping 0x%x", keyexpr._id, _z_keyexpr_mapping_id(&keyexpr));
_z_keyexpr_t key = __unsafe_z_get_expanded_key_from_key(zn, &keyexpr);
if (key._suffix != NULL) {
_Z_DEBUG("Triggering subs for %d - %s", key._id, key._suffix);
_z_subscription_rc_list_t *subs = __unsafe_z_get_subscriptions_by_key(zn, _Z_RESOURCE_IS_LOCAL, key);
src/system/espidf/network.c
Outdated
int r = uart_read_bytes(sock._serial, &before_cobs[i], 1, 100); | ||
if (r == 0) { | ||
timeout_count++; | ||
if (timeout_count > 10) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make this a configuration parameter, defined in the locator.
Ideally, a timer timeout instead of a counter timeout.
src/system/espidf/network.c
Outdated
if (timeout_count > 10) { | ||
_Z_DEBUG("Timeout reading from serial"); | ||
zp_free(before_cobs); | ||
return 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid early returns to avoid breaking MISRA-C rules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For MISRA-C rules we decided to relax rule 15.5 so early returns are welcomed if they're useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a list of the rules that were decided to be relaxed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the very least 15.5 for early returns, and 17.7 in cases where the return value is truly meaningless.
src/system/espidf/network.c
Outdated
} else { | ||
_Z_DEBUG("Error reading from serial"); | ||
zp_free(before_cobs); | ||
return _Z_ERR_GENERIC; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid early returns to avoid breaking MISRA-C rules.
…h lease and read task start top of 2 x 16 bytes - -DZ_FEATURE_SUBSCRIPTION=0 didn´t compile previously - used freeRtos in espidf - read now times out in 1 sec fixed
@@ -279,8 +279,10 @@ template<> inline int8_t z_drop(z_owned_publisher_t* v) { return z_undeclare_pub | |||
template<> inline void z_drop(z_owned_keyexpr_t* v) { z_keyexpr_drop(v); } | |||
template<> inline void z_drop(z_owned_config_t* v) { z_config_drop(v); } | |||
template<> inline void z_drop(z_owned_scouting_config_t* v) { z_scouting_config_drop(v); } | |||
#if Z_FEATURE_SUBSCRIPTION==1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one, I'd say we should either have all the feature token in the file or none.
Did you need this for a reason?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I seem to remember that otherwise it didn´t compile with Z_FEATURE_SUBSCRIPTION=0
lib/zenoh-pico/include/zenoh-pico/api/macros.h:282:72: error: 'z_undeclare_pull_subscriber' was not declared in this scope
@@ -746,15 +747,15 @@ int8_t z_publisher_put(const z_publisher_t pub, const uint8_t *payload, size_t l | |||
opt.attachment | |||
#endif | |||
); | |||
|
|||
#if Z_FEATURE_SUBSCRIPTION == 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You shouldn't need this because _z_trigger_local_subscriptions
is replaced by a dummy function if subscription function is off.... Suposedly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see comment above, it doesn´t compile. Feels like code was tested with this feature off.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No it's definitely tested with both in CI, I recall you use C++ to compile, so maybe this is the source of our compilation diverging behavior.
@@ -185,7 +185,7 @@ int8_t _z_trigger_subscriptions(_z_session_t *zn, const _z_keyexpr_t keyexpr, co | |||
zp_mutex_lock(&zn->_mutex_inner); | |||
#endif // Z_FEATURE_MULTI_THREAD == 1 | |||
|
|||
_Z_DEBUG("Resolving %d - %s on mapping 0x%x", keyexpr._id, keyexpr._suffix, _z_keyexpr_mapping_id(&keyexpr)); | |||
// _Z_DEBUG("Resolving %d - %s on mapping 0x%x", keyexpr._id, keyexpr._suffix, _z_keyexpr_mapping_id(&keyexpr)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand these pose issues when receiving something without a suffix, then I suggest you something like:
_Z_DEBUG("Resolving %d on mapping 0x%x", keyexpr._id, _z_keyexpr_mapping_id(&keyexpr));
_z_keyexpr_t key = __unsafe_z_get_expanded_key_from_key(zn, &keyexpr);
if (key._suffix != NULL) {
_Z_DEBUG("Triggering subs for %d - %s", key._id, key._suffix);
_z_subscription_rc_list_t *subs = __unsafe_z_get_subscriptions_by_key(zn, _Z_RESOURCE_IS_LOCAL, key);
My attempts to merge fail, any suggestions. ? My Git kungfu is not strong enough.
|
too many changes already in main branch, try another pull request |
trying to improve the serial espidf connectivity by adding timeouts in the session establishment .
Duplicate vTaskDelete removed
testing shows good results
flushing input and output makes recovery easier