Skip to content

Cellular: Convert to Chrono #12430

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

Merged
merged 4 commits into from
May 13, 2020
Merged

Cellular: Convert to Chrono #12430

merged 4 commits into from
May 13, 2020

Conversation

kjbracey
Copy link
Contributor

Summary of changes

Covert cellular code to use new Chrono APIs from #12142

Note that documentation for random_max_start_delay config setting has
been changed to indicate that the setting is in seconds, and always has
been. No functional change.

Impact of changes

Eliminate use of deprecated core APIs.

Some public cellular APIs now have dual Chrono and non-Chrono forms - non-Chrono not yet deprecated.

Migration actions required

Documentation

None


Pull request type

[] Patch update (Bug fix / Target update / Docs update / Test update / Refactor)
[X] Feature update (New feature / Functionality change / New API)
[] Major update (Breaking change E.g. Return code change / API behaviour change)

Test results

[] No Tests required for this change (E.g docs only update)
[X] Covered by existing mbed-os tests (Greentea or Unittest)
[] Tests / results supplied as part of this PR

Reviewers


@mergify mergify bot added the needs: work label Feb 13, 2020
@ciarmcom ciarmcom requested review from a team February 13, 2020 16:00
@ciarmcom
Copy link
Member

@kjbracey-arm, thank you for your changes.
@ARMmbed/mbed-os-wan @ARMmbed/mbed-os-maintainers please review.

// so that not every device don't start at the exact same time (for example after power outage)
_start_time = rand() % (MBED_CONF_CELLULAR_RANDOM_MAX_START_DELAY);
_start_time(rand() % (MBED_CONF_CELLULAR_RANDOM_MAX_START_DELAY)),

Choose a reason for hiding this comment

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

Is else _start_time(0) needed here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, because Chrono durations and time_points are initialised to zero by default. Still, could have it explicit. That would be more consistent with the existing code.

I guess I was pushing back a bit on the long C++98-style initialiser lists on constructors. Since C++11, member initialisation that doesn't depend on constructor parameters shouldn't be there. They should be in default member initialisers (if even necessary).

uint64_t start_time = rtos::Kernel::get_ms_count();
while (!ready_to_send && start_time < rtos::Kernel::get_ms_count() + SOCKET_SEND_READY_TIMEOUT) {
auto start_time = rtos::Kernel::Clock::now() ;
while (!ready_to_send && rtos::Kernel::Clock::now() < start_time + SOCKET_SEND_READY_TIMEOUT) {

Choose a reason for hiding this comment

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

Good catch 👍

@@ -10,7 +10,7 @@
"value": false
},
"random_max_start_delay": {
"help": "Maximum random delay value used in start-up sequence in milliseconds",
"help": "Maximum random delay value used in start-up sequence in seconds",

Choose a reason for hiding this comment

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

Another good catch 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's kind of the point of the Chrono stuff - it catches it for you :)

@kjbracey
Copy link
Contributor Author

Re-looking at code after review comments, noticed this print needed fixing:

    -    tr_info("Startup delay %d ms", _start_time);
    +    tr_info("Startup delay %d s", _start_time.count());

@mergify mergify bot removed the needs: review label Feb 14, 2020
@mergify
Copy link

mergify bot commented Mar 16, 2020

This PR cannot be merged due to conflicts. Please rebase to resolve them.

@kjbracey
Copy link
Contributor Author

Rebased.

@0xc0170
Copy link
Contributor

0xc0170 commented May 8, 2020

CI started

@mbed-ci
Copy link

mbed-ci commented May 8, 2020

Test run: FAILED

Summary: 1 of 3 test jobs failed
Build number : 1
Build artifacts

Failed test jobs:

  • jenkins-ci/mbed-os-ci_unittests

@0xc0170
Copy link
Contributor

0xc0170 commented May 8, 2020

Unittests failed, please review

@kjbracey
Copy link
Contributor Author

kjbracey commented May 8, 2020

One actual code fix - legacy ATHandler::set_at_timeout wasn't passing through default_timeout parameter to Chrono version.

Cellular unit tests updated.

@kjbracey
Copy link
Contributor Author

CI started

@mbed-ci
Copy link

mbed-ci commented May 11, 2020

Test run: FAILED

Summary: 1 of 3 test jobs failed
Build number : 3
Build artifacts

Failed test jobs:

  • jenkins-ci/mbed-os-ci_unittests

kjbracey added 2 commits May 11, 2020 14:18
Note that documentation for random_max_start_delay config setting has
been changed to indicate that the setting is in seconds, and always has
been. No functional change.
@kjbracey
Copy link
Contributor Author

Correction - _start_time not being properly initialised to 0.

@kjbracey
Copy link
Contributor Author

CI started

@mbed-ci
Copy link

mbed-ci commented May 11, 2020

Test run: SUCCESS

Summary: 6 of 6 test jobs passed
Build number : 4
Build artifacts

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

Successfully merging this pull request may close these issues.

5 participants