Skip to content

Conversation

@adbridge
Copy link
Contributor

Summary of changes

The period method currently allows any ms value:
positive, negative and zero.

A negative value means dispatch a non periodic event. ie just once.
0 is unspecified behaviour.

This commit forces the user to use either positive periods or a new constant, non_periodic
and should any other value be provided will default to non_periodic.

A Greentea test case is also provided to check this works as
expected.

I'm classifying this as a feature change rather than major because allowing a zero value was actually a bug.

Impact of changes

If the user provides a 0 value this will now behave differently. Previously it would have run for a period of
time as if this was an indefinite event before eventually (with a timer wrap) have unspecified behaviour.
Now the event period will default instead to non periodic.

To specify a non periodic event a user could previously use any negative value. Whilst this will still work (due a default
being set on invalid values), the user is encouraged to use the new constant, 'non_periodic' to show that this is what was
intended.

Migration actions required

Use periods that are > 0ms or non_periodic constant.

Documentation

Should be picked up automatically in the doxygen

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)
[] Covered by existing mbed-os tests (Greentea or Unittest)
[x] Tests / results supplied as part of this PR

Reviewers


@adbridge adbridge requested a review from evedon December 23, 2020 17:41
@mergify mergify bot added the needs: work label Dec 23, 2020
0xc0170
0xc0170 previously requested changes Jan 5, 2021
@0xc0170
Copy link
Contributor

0xc0170 commented Jan 5, 2021

Please also rebase to the latest master to fix Travis

evedon
evedon previously requested changes Jan 6, 2021
@mergify mergify bot dismissed stale reviews from 0xc0170 and evedon January 6, 2021 15:47

Pull request has been modified.

The period method currently allows any ms value positive, negative
and zero. A negative value means dispatch a non periodic event
ie just once. 0 is unspecified behaviour. This commit forces the
user to use either positive periods or a new constant non_periodic
and should any other value be provided will default to
non_periodic.

A Greentea test case is also provided to check this works as
expected.
non_periodic constant has been moved out of the Event class and
made static within the events namespace so that it is available
both internally within the class and externally.

The MBED_ASSERT has been changed to MBED_WARNING.

The greentea test has been updated:
1) timings reduced to make the test cases run faster
2) The call handler simplified
@adbridge
Copy link
Contributor Author

adbridge commented Jan 6, 2021

Hopefully rebased for travis fix also.

@adbridge
Copy link
Contributor Author

adbridge commented Jan 6, 2021

@0xc0170 @evedon please re-review

@adbridge adbridge closed this Jan 6, 2021
@adbridge adbridge reopened this Jan 6, 2021
@adbridge
Copy link
Contributor Author

adbridge commented Jan 6, 2021

Test results:

> mbed test -t GCC_ARM -m K64F -n events-tests-tests-events-queue 
[mbed] Working path "/home/anna/git/mbed-os" (program)
[mbed] WARNING: Missing Python modules were not auto-installed.
       The Mbed OS tools in this program require the following Python modules: psutil, click, cbor
       You can install all missing modules by running "pip install -r requirements.txt" in "/home/anna/git/mbed-os"
       On Posix systems (Linux, etc) you might have to switch to superuser account or use "sudo"
---
WARNING: MBED_ARMC6_PATH set as environment variable but doesn't exist
Building library mbed-build (K64F, GCC_ARM)
Scan: mbed-os
Copy: Event.h
Compile [ 99.3%]: ns_event_loop_mbed.cpp
Compile [ 99.4%]: arm_hal_timer.cpp
Compile [ 99.5%]: DTLSSocketWrapper.cpp
Compile [ 99.7%]: TLSSocketWrapper.cpp
Compile [ 99.8%]: PolledQueue.cpp
Compile [ 99.9%]: TaskBase.cpp
Compile [100.0%]: EventQueue.cpp
Building project queue (K64F, GCC_ARM)
Scan: GCC_ARM
Scan: queue
Compile [100.0%]: main.cpp
[Warning] main.cpp@116,54: 'int mbed::TimerBase::read_ms() const' is deprecated: Use the Chrono-based elapsed_time method.  If integer milliseconds are needed, you can use `duration_cast<milliseconds>(elapsed_time()).count()` [since mbed-os-6.0.0] [-Wdeprecated-declarations]
Link: queue
Elf2Bin: queue
| Module                   |      .text |    .data |      .bss |
|--------------------------|------------|----------|-----------|
| [fill]                   |    137(+2) |    7(+0) |  2327(+0) |
| [lib]/c.a                |  12807(+0) | 2472(+0) |    89(+0) |
| [lib]/gcc.a              |    920(+0) |    0(+0) |     0(+0) |
| [lib]/misc               |    180(+0) |    4(+0) |    28(+0) |
| [lib]/nosys.a            |     32(+0) |    0(+0) |     0(+0) |
| cmsis/CMSIS_5            |   7190(+0) |  164(+0) |  1612(+0) |
| cmsis/device             |   1716(+0) |    4(+0) |  4344(+0) |
| connectivity/drivers     |      4(+0) |    0(+0) |     0(+0) |
| connectivity/nanostack   |    164(+0) |    0(+0) |     0(+0) |
| drivers/source           |    990(+0) |    0(+0) |     0(+0) |
| events/source            |   1681(+0) |    0(+0) |     0(+0) |
| events/tests             | 15523(+32) |    0(+0) |  1109(+0) |
| features/frameworks      |   7065(+0) |   69(+0) |   369(+0) |
| hal/source               |   1679(+0) |    8(+0) |   115(+0) |
| platform/source          |  7751(+14) |  260(+0) |   365(+0) |
| rtos/source              |    217(+0) |    0(+0) |     8(+0) |
| targets/TARGET_Freescale |   9117(+0) |   36(+0) |   386(+0) |
| Subtotals                | 67173(+48) | 3024(+0) | 10752(+0) |
Total Static RAM memory (data + bss): 13776(+0) bytes
Total Flash memory (text + data): 70197(+48) bytes

Image: BUILD/tests/K64F/GCC_ARM/events/tests/TESTS/events/queue/queue.bin


Memory map breakdown for built projects (values in Bytes):
| name  | target | toolchain | static_ram | total_flash |
|-------|--------|-----------|------------|-------------|
| queue | K64F   | GCC_ARM   |      13776 |       70197 |


Build successes:
  * K64F::GCC_ARM::EVENTS-TESTS-TESTS-EVENTS-QUEUE
  * K64F::GCC_ARM::MBED-BUILD
mbedgt: greentea test automation tool ver. 1.8.3
mbedgt: test specification file './BUILD/tests/K64F/GCC_ARM/test_spec.json' (specified with --test-spec option)
mbedgt: using './BUILD/tests/K64F/GCC_ARM/test_spec.json' from current directory!
mbedgt: detecting connected mbed-enabled devices...
mbedgt: detected 1 device
mbedgt: processing target 'K64F' toolchain 'GCC_ARM' compatible platforms... (note: switch set to --parallel 1)
mbedgt: test case filter (specified with -n option)
	events-tests-tests-events-queue
	test filtered in 'events-tests-tests-events-queue'
mbedgt: running 1 test for platform 'K64F' and toolchain 'GCC_ARM'
mbedgt: mbed-host-test-runner: started
mbedgt: checking for GCOV data...
mbedgt: test on hardware with target id: 0240000034544e45000800048e3800265a91000097969900
mbedgt: test suite 'events-tests-tests-events-queue' ................................................. OK in 23.41 sec
	test case: 'Testing allocate failure' ........................................................ OK in 0.05 sec
	test case: 'Testing call_every' .............................................................. OK in 2.04 sec
	test case: 'Testing call_in' ................................................................. OK in 2.02 sec
	test case: 'Testing calls with 0 args' ....................................................... OK in 0.06 sec
	test case: 'Testing calls with 1 args' ....................................................... OK in 0.06 sec
	test case: 'Testing calls with 2 args' ....................................................... OK in 0.05 sec
	test case: 'Testing calls with 3 args' ....................................................... OK in 0.07 sec
	test case: 'Testing calls with 4 args' ....................................................... OK in 0.05 sec
	test case: 'Testing calls with 5 args' ....................................................... OK in 0.06 sec
	test case: 'Testing event cancel 1' .......................................................... OK in 0.06 sec
	test case: 'Testing event period values' ..................................................... OK in 0.77 sec
	test case: 'Testing mixed dynamic & static events queue' ..................................... OK in 0.17 sec
	test case: 'Testing static events queue' ..................................................... OK in 0.46 sec
	test case: 'Testing the event class' ......................................................... OK in 0.06 sec
	test case: 'Testing the event class helpers' ................................................. OK in 0.07 sec
	test case: 'Testing the event inference' ..................................................... OK in 0.07 sec
	test case: 'Testing time_left' ............................................................... OK in 0.36 sec
mbedgt: test case summary: 17 passes, 0 failures
mbedgt: all tests finished!
mbedgt: shuffle seed: 0.7562750330
mbedgt: test suite report:
| target       | platform_name | test suite                      | result | elapsed_time (sec) | copy_method |
|--------------|---------------|---------------------------------|--------|--------------------|-------------|
| K64F-GCC_ARM | K64F          | events-tests-tests-events-queue | OK     | 23.41              | default     |
mbedgt: test suite results: 1 OK
mbedgt: test case report:
| target       | platform_name | test suite                      | test case                                   | passed | failed | result | elapsed_time (sec) |
|--------------|---------------|---------------------------------|---------------------------------------------|--------|--------|--------|--------------------|
| K64F-GCC_ARM | K64F          | events-tests-tests-events-queue | Testing allocate failure                    | 1      | 0      | OK     | 0.05               |
| K64F-GCC_ARM | K64F          | events-tests-tests-events-queue | Testing call_every                          | 1      | 0      | OK     | 2.04               |
| K64F-GCC_ARM | K64F          | events-tests-tests-events-queue | Testing call_in                             | 1      | 0      | OK     | 2.02               |
| K64F-GCC_ARM | K64F          | events-tests-tests-events-queue | Testing calls with 0 args                   | 1      | 0      | OK     | 0.06               |
| K64F-GCC_ARM | K64F          | events-tests-tests-events-queue | Testing calls with 1 args                   | 1      | 0      | OK     | 0.06               |
| K64F-GCC_ARM | K64F          | events-tests-tests-events-queue | Testing calls with 2 args                   | 1      | 0      | OK     | 0.05               |
| K64F-GCC_ARM | K64F          | events-tests-tests-events-queue | Testing calls with 3 args                   | 1      | 0      | OK     | 0.07               |
| K64F-GCC_ARM | K64F          | events-tests-tests-events-queue | Testing calls with 4 args                   | 1      | 0      | OK     | 0.05               |
| K64F-GCC_ARM | K64F          | events-tests-tests-events-queue | Testing calls with 5 args                   | 1      | 0      | OK     | 0.06               |
| K64F-GCC_ARM | K64F          | events-tests-tests-events-queue | Testing event cancel 1                      | 1      | 0      | OK     | 0.06               |
| K64F-GCC_ARM | K64F          | events-tests-tests-events-queue | Testing event period values                 | 1      | 0      | OK     | 0.77               |
| K64F-GCC_ARM | K64F          | events-tests-tests-events-queue | Testing mixed dynamic & static events queue | 1      | 0      | OK     | 0.17               |
| K64F-GCC_ARM | K64F          | events-tests-tests-events-queue | Testing static events queue                 | 1      | 0      | OK     | 0.46               |
| K64F-GCC_ARM | K64F          | events-tests-tests-events-queue | Testing the event class                     | 1      | 0      | OK     | 0.06               |
| K64F-GCC_ARM | K64F          | events-tests-tests-events-queue | Testing the event class helpers             | 1      | 0      | OK     | 0.07               |
| K64F-GCC_ARM | K64F          | events-tests-tests-events-queue | Testing the event inference                 | 1      | 0      | OK     | 0.07               |
| K64F-GCC_ARM | K64F          | events-tests-tests-events-queue | Testing time_left                           | 1      | 0      | OK     | 0.36               |
mbedgt: test case results: 17 OK
mbedgt: completed in 24.05 sec

@adbridge
Copy link
Contributor Author

adbridge commented Jan 6, 2021

@0xc0170 why does travis keep failing ? I rebased master :(
Seems to be the astyle job which is failing but there is no indication of why ...

Copy link
Contributor

@evedon evedon left a comment

Choose a reason for hiding this comment

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

Two minor comments. The rest looks fine.

(Also minor whitespace correction)
@adbridge
Copy link
Contributor Author

adbridge commented Jan 8, 2021

Ci started

evedon
evedon previously approved these changes Jan 8, 2021
@adbridge
Copy link
Contributor Author

adbridge commented Jan 8, 2021

@0xc0170 I can't see why astyle isn't happy? Any idea ?

@mbed-ci
Copy link

mbed-ci commented Jan 8, 2021

Jenkins CI Test : ✔️ SUCCESS

Build Number: 1 | 🔒 Jenkins CI Job | 🌐 Logs & Artifacts

CLICK for Detailed Summary

jobs Status
jenkins-ci/mbed-os-ci_cmake-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_unittests ✔️
jenkins-ci/mbed-os-ci_cmake-example-ARM ✔️
jenkins-ci/mbed-os-ci_build-greentea-ARM ✔️
jenkins-ci/mbed-os-ci_build-greentea-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_build-cloud-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_build-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_build-cloud-example-ARM ✔️
jenkins-ci/mbed-os-ci_build-example-ARM ✔️
jenkins-ci/mbed-os-ci_greentea-test ✔️
jenkins-ci/mbed-os-ci_cmake-example-test ✔️

@mergify mergify bot dismissed evedon’s stale review January 12, 2021 12:56

Pull request has been modified.

@adbridge
Copy link
Contributor Author

@0xc0170 this was already approved and has passed CI (the whitespace push caused reviews to be dismissed). Just needs maintainer approval and merging now..

Copy link
Contributor

@0xc0170 0xc0170 left a comment

Choose a reason for hiding this comment

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

events/include/events/Event.h 100644 → 100755 - please revert the file attributes change

@adbridge
Copy link
Contributor Author

adbridge commented Jan 18, 2021

events/include/events/Event.h 100644 → 100755 - please revert the file attributes change

What file attribute changes ? And why would any of those changes need reverting they compile and run perfectly ? They're also fixing things that are currently wrong ?

@ladislas
Copy link
Contributor

Screenshot 2021-01-18 at 15 40 16

here, it means that the files were marked as executable.

This post can help: https://stackoverflow.com/questions/1257592/how-do-i-remove-files-saying-old-mode-100755-new-mode-100644-from-unstaged-cha?noredirect=1&lq=1

@mergify mergify bot dismissed 0xc0170’s stale review January 18, 2021 14:59

Pull request has been modified.

@0xc0170
Copy link
Contributor

0xc0170 commented Jan 18, 2021

CI restarted

@mergify mergify bot added needs: CI and removed needs: work labels Jan 18, 2021
@mbed-ci
Copy link

mbed-ci commented Jan 18, 2021

Jenkins CI Test : ✔️ SUCCESS

Build Number: 3 | 🔒 Jenkins CI Job | 🌐 Logs & Artifacts

CLICK for Detailed Summary

jobs Status
jenkins-ci/mbed-os-ci_unittests ✔️
jenkins-ci/mbed-os-ci_cmake-example-ARM ✔️
jenkins-ci/mbed-os-ci_cmake-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_build-greentea-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_build-greentea-ARM ✔️
jenkins-ci/mbed-os-ci_build-cloud-example-ARM ✔️
jenkins-ci/mbed-os-ci_build-example-ARM ✔️
jenkins-ci/mbed-os-ci_build-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_build-cloud-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_cmake-example-test ✔️
jenkins-ci/mbed-os-ci_greentea-test ✔️

@0xc0170 0xc0170 merged commit 97c7c91 into ARMmbed:master Jan 18, 2021
@mergify mergify bot added release version missing When PR does not contain release version, bot should label it and we fix it afterwards and removed ready for merge labels Jan 18, 2021
@mergify
Copy link

mergify bot commented Jan 18, 2021

This PR does not contain release version label after merging.

@adbridge adbridge added release-type: feature and removed release version missing When PR does not contain release version, bot should label it and we fix it afterwards labels Jan 18, 2021
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.

6 participants