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

espidf added flush, clean task stop , commented out crashing debug log #362

Closed
wants to merge 3 commits into from
Closed

Conversation

vortex314
Copy link
Contributor

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

@eclipse-zenoh-bot
Copy link

@vortex314 If this pull request contains a bugfix or a new feature, then please consider using Closes #ISSUE-NUMBER syntax to link it to an issue.

@vortex314
Copy link
Contributor Author

Test program can be found here : https://github.com/vortex314/zenoh-projects/tree/main/zenoh-serial

@vortex314 vortex314 closed this Feb 29, 2024
@vortex314 vortex314 reopened this Feb 29, 2024
@vortex314
Copy link
Contributor Author

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));
Copy link
Member

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.

Copy link
Contributor

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);

int r = uart_read_bytes(sock._serial, &before_cobs[i], 1, 100);
if (r == 0) {
timeout_count++;
if (timeout_count > 10) {
Copy link
Member

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.

if (timeout_count > 10) {
_Z_DEBUG("Timeout reading from serial");
zp_free(before_cobs);
return 0;
Copy link
Member

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.

Copy link
Contributor

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.

Copy link
Member

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?

Copy link
Contributor

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.

} else {
_Z_DEBUG("Error reading from serial");
zp_free(before_cobs);
return _Z_ERR_GENERIC;
Copy link
Member

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
Copy link
Contributor

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?

Copy link
Contributor Author

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
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

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));
Copy link
Contributor

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);

@vortex314
Copy link
Contributor Author

My attempts to merge fail, any suggestions. ? My Git kungfu is not strong enough.

lieven@pcpav2:~/workspace/zenoh-pico$ git push
To https://github.com/vortex314/zenoh-pico.git
 ! [rejected]          serial_retry -> serial_retry (non-fast-forward)
error: failed to push some refs to 'https://github.com/vortex314/zenoh-pico.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
lieven@pcpav2:~/workspace/zenoh-pico$ git status
On branch serial_retry
Your branch and 'origin/serial_retry' have diverged,
and have 14 and 3 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)

nothing to commit, working tree clean

@vortex314
Copy link
Contributor Author

too many changes already in main branch, try another pull request

@vortex314 vortex314 closed this Mar 19, 2024
@vortex314 vortex314 deleted the serial_retry branch March 19, 2024 18:45
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.

4 participants