8000 Use consistent naming for Serial interfaces by sebromero · Pull Request #54 · arduino/ArduinoCore-mbed · GitHub
[go: up one dir, main page]

Skip to content

Use consistent naming for Serial interfaces #54

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

Closed
wants to merge 3 commits into from

Conversation

sebromero
Copy link
Collaborator
@sebromero sebromero commented Sep 12, 2020

After a discussion with @hpssjellis I concluded that it's confusing to map the serial interfaces to different UART port depending on the core. It's probably more understandable if the M4 doesn't support Serial for now, or to map it also to _UART1_. In the future we can add support for Serial to the M4 by piping the messages to the M7.

@sebromero sebromero marked this pull request as draft September 12, 2020 09:28
@github-actions
Copy link

Memory usage change @ 6511709

Board flash % RAM for global variables %
arduino-beta:mbed:envie_m7 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino-beta:mbed:nano33ble 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
Click for full report table
Board libraries/Scheduler/examples/MultipleBlinks
flash
% libraries/Scheduler/examples/MultipleBlinks
RAM for global variables
% libraries/doom/examples/Doom
flash
% libraries/doom/examples/Doom
RAM for global variables
% libraries/KernelDebug/examples/KernelDebug
flash
% libraries/KernelDebug/examples/KernelDebug
RAM for global variables
% libraries/Portenta_Audio/examples/PortentaAudioMicPDM
flash
% libraries/Portenta_Audio/examples/PortentaAudioMicPDM
RAM for global variables
% libraries/Portenta_SDCARD/examples/TestSDCARD
flash
% libraries/Portenta_SDCARD/examples/TestSDCARD
RAM for global variables
% libraries/Portenta_System/examples/PortentaH7_getBootloaderInfo
flash
% libraries/Portenta_System/examples/PortentaH7_getBootloaderInfo
RAM for global variables
% libraries/Portenta_System/examples/PortentaH7_updateBootloader
flash
% libraries/Portenta_System/examples/PortentaH7_updateBootloader
RAM for global variables
% libraries/Portenta_Video/examples/Envie_video_coreboot
flash
% libraries/Portenta_Video/examples/Envie_video_coreboot
RAM for global variables
% libraries/ThreadDebug/examples/ThreadDebug
flash
% libraries/ThreadDebug/examples/ThreadDebug
RAM for global variables
% libraries/USBHOST/examples/KeyboardController
flash
% libraries/USBHOST/examples/KeyboardController
RAM for global variables
% libraries/USBHOST/examples/Shell
flash
% libraries/USBHOST/examples/Shell
RAM for global variables
% libraries/PDM/examples/PDMSerialPlotter
flash
% libraries/PDM/examples/PDMSerialPlotter
RAM for global variables
%
arduino-beta:mbed:envie_m7 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0
arduino-beta:mbed:nano33ble 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0
Click for full report CSV
Board,libraries/Scheduler/examples/MultipleBlinks<br>flash,%,libraries/Scheduler/examples/MultipleBlinks<br>RAM for global variables,%,libraries/doom/examples/Doom<br>flash,%,libraries/doom/examples/Doom<br>RAM for global variables,%,libraries/KernelDebug/examples/KernelDebug<br>flash,%,libraries/KernelDebug/examples/KernelDebug<br>RAM for global variables,%,libraries/Portenta_Audio/examples/PortentaAudioMicPDM<br>flash,%,libraries/Portenta_Audio/examples/PortentaAudioMicPDM<br>RAM for global variables,%,libraries/Portenta_SDCARD/examples/TestSDCARD<br>flash,%,libraries/Portenta_SDCARD/examples/TestSDCARD<br>RAM for global variables,%,libraries/Portenta_System/examples/PortentaH7_getBootloaderInfo<br>flash,%,libraries/Portenta_System/examples/PortentaH7_getBootloaderInfo<br>RAM for global variables,%,libraries/Portenta_System/examples/PortentaH7_updateBootloader<br>flash,%,libraries/Portenta_System/examples/PortentaH7_updateBootloader<br>RAM for global variables,%,libraries/Portenta_Video/examples/Envie_video_coreboot<br>flash,%,libraries/Portenta_Video/examples/Envie_video_coreboot<br>RAM for global variables,%,libraries/ThreadDebug/examples/ThreadDebug<br>flash,%,libraries/ThreadDebug/examples/ThreadDebug<br>RAM for global variables,%,libraries/USBHOST/examples/KeyboardController<br>flash,%,libraries/USBHOST/examples/KeyboardController<br>RAM for global variables,%,libraries/USBHOST/examples/Shell<br>flash,%,libraries/USBHOST/examples/Shell<br>RAM for global variables,%,libraries/PDM/examples/PDMSerialPlotter<br>flash,%,libraries/PDM/examples/PDMSerialPlotter<br>RAM for global variables,%
arduino-beta:mbed:envie_m7,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0
arduino-beta:mbed:nano33ble,0,0.0,0,0.0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0,0.0,0,0.0,,,,,,,,,0,0.0,0,0.0

@per1234
Copy link
Contributor
per1234 commented Sep 12, 2020

@sbhklr if the "Compile Examples" CI workflow needs to be adjusted to not compile the /libraries/Scheduler/examples/MultipleBlinks, etc. example sketches for the Portenta (M4 core) board, I'm happy to assist with that.

@sebromero
Copy link
Collaborator Author

@sbhklr if the "Compile Examples" CI workflow needs to be adjusted to not compile the /libraries/Scheduler/examples/MultipleBlinks 8000 example sketch for the Portenta (M4 core) board, I'm happy to assist with that.

Thanks Per! No, I think it should absolutely be compiled, but I forgot to adjust the example. Will do now :-)

@github-actions
Copy link

Memory usage change @ 8d731ef

Board flash % RAM for global variables %
arduino-beta:mbed:envie_m7 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino-beta:mbed:nano33ble 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
Click for full report table
Board libraries/Scheduler/examples/MultipleBlinks
flash
% libraries/Scheduler/examples/MultipleBlinks
RAM for global variables
% libraries/doom/examples/Doom
flash
% libraries/doom/examples/Doom
RAM for global variables
% libraries/KernelDebug/examples/KernelDebug
flash
% libraries/KernelDebug/examples/KernelDebug
RAM for global variables
% libraries/Portenta_Audio/examples/PortentaAudioMicPDM
flash
% libraries/Portenta_Audio/examples/PortentaAudioMicPDM
RAM for global variables
% libraries/Portenta_SDCARD/examples/TestSDCARD
flash
% libraries/Portenta_SDCARD/examples/TestSDCARD
RAM for global variables
% libraries/Portenta_System/examples/PortentaH7_getBootloaderInfo
flash
% libraries/Portenta_System/examples/PortentaH7_getBootloaderInfo
RAM for global variables
% libraries/Portenta_System/examples/PortentaH7_updateBootloader
flash
% libraries/Portenta_System/examples/PortentaH7_updateBootloader
RAM for global variables
% libraries/Portenta_Video/examples/Envie_video_coreboot
flash
% libraries/Portenta_Video/examples/Envie_video_coreboot
RAM for global variables
% libraries/ThreadDebug/examples/ThreadDebug
flash
% libraries/ThreadDebug/examples/ThreadDebug
RAM for global variables
% libraries/USBHOST/examples/KeyboardController
flash
% libraries/USBHOST/examples/KeyboardController
RAM for global variables
% libraries/USBHOST/examples/Shell
flash
% libraries/USBHOST/examples/Shell
RAM for global variables
% libraries/PDM/examples/PDMSerialPlotter
flash
% libraries/PDM/examples/PDMSerialPlotter
RAM for global variables
%
arduino-beta:mbed:envie_m7 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0
arduino-beta:mbed:nano33ble 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0
Click for full report CSV
Board,libraries/Scheduler/examples/MultipleBlinks<br>flash,%,libraries/Scheduler/examples/MultipleBlinks<br>RAM for global variables,%,libraries/doom/examples/Doom<br>flash,%,libraries/doom/examples/Doom<br>RAM for global variables,%,libraries/KernelDebug/examples/KernelDebug<br>flash,%,libraries/KernelDebug/examples/KernelDebug<br>RAM for global variables,%,libraries/Portenta_Audio/examples/PortentaAudioMicPDM<br>flash,%,libraries/Portenta_Audio/examples/PortentaAudioMicPDM<br>RAM for global variables,%,libraries/Portenta_SDCARD/examples/TestSDCARD<br>flash,%,libraries/Portenta_SDCARD/examples/TestSDCARD<br>RAM for global variables,%,libraries/Portenta_System/examples/PortentaH7_getBootloaderInfo<br>flash,%,libraries/Portenta_System/examples/PortentaH7_getBootloaderInfo<br>RAM for global variables,%,libraries/Portenta_System/examples/PortentaH7_updateBootloader<br>flash,%,libraries/Portenta_System/examples/PortentaH7_updateBootloader<br>RAM for global variables,%,libraries/Portenta_Video/examples/Envie_video_coreboot<br>flash,%,libraries/Portenta_Video/examples/Envie_video_coreboot<br>RAM for global variables,%,libraries/ThreadDebug/examples/ThreadDebug<br>flash,%,libraries/ThreadDebug/examples/ThreadDebug<br>RAM for global variables,%,libraries/USBHOST/examples/KeyboardController<br>flash,%,libraries/USBHOST/examples/KeyboardController<br>RAM for global variables,%,libraries/USBHOST/examples/Shell<br>flash,%,libraries/USBHOST/examples/Shell<br>RAM for global variables,%,libraries/PDM/examples/PDMSerialPlotter<br>flash,%,libraries/PDM/examples/PDMSerialPlotter<br>RAM for global variables,%
arduino-beta:mbed:envie_m7,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0
arduino-beta:mbed:nano33ble,0,0.0,0,0.0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0,0.0,0,0.0,,,,,,,,,0,0.0,0,0.0

@sebromero
Copy link
Collaborator Author

@per1234 Hmm, I was thinking of remapping the Serial for the M4 in the examples using

#ifdef CORE_CM4
  #define Serial Serial1
#endif

or

#ifdef CORE_CM4
  #define Serial _UART1_
#endif

It pollutes the examples a bit though. Not sure if it's the best approach. How would you go about it?

@per1234
Copy link
Contributor
per1234 commented Sep 12, 2020

That is a good consideration!

We are using this sketch for two purposes:

  • Demonstrate the library to the user
  • Test the compilation of the library

Only considering the first, I would say that it's best to:

and leave it up to the user to adjust the example to Serial1 when they want to use it on the Portenta (M4 core) board.

However, this will require us to configure the CI workflow to not compile the sketch, meaning we lose that basic check on compatibility of the Scheduler library with the Portenta (M4 Core) board.

A workaround for that could be to add a sketch only intended to be used for testing to a dedicated location in the Arduino mbed OS-enabled platforms platform, something like test/sketches/libraries/Scheduler/Scheduler.ino, then configure the CI workflow to compile the test sketch for all boards and the user example only for the boards its expected to compile for. That test sketch can be as user-unfriendly as we like because it's never intended to be seen by the standard users. It can also be more targeted on excercising only the API of the Scheduler library, rather than needing to contain code unrelated to make it actually do something useful.

I think something like this was done in the ArduinoIoTCloud library:
https://github.com/arduino-libraries/ArduinoIoTCloud/tree/master/examples/utility/ArduinoIoTCloud_Travis_CI


As for the examples in the Portenta_System library, I'm not concerned about a little preprocessor "pollution" there because those examples are targeted to more advanced users who won't get confused by the preprocessor stuff. I actually don't even know enough about Portenta to understand whether those examples are relevant to the M4 core board.

@per1234
Copy link
Contributor
per1234 commented Sep 13, 2020

Due to the long standing precedent set by other Arduino boards, I think it would be confusing for Serial and Serial1 to be names for the same interface.

I actually prefer for users to be required to adjust the sketch to use Serial1 instead of Serial because this will make it clear to them that they shouldn't expect the code to use the CDC serial port, but rather pins 13/14 just as it would on the Portenta (M7 core) or MKR boards, and similar to any other Arduino board.

Consider Sebastian's suggestion from eariler:

In the future we can add support for Serial to the M4 by piping the messages to the M7.

It would be confusing for the meaning of Serial to change once more when that happens.

@hpssjellis
Copy link
Contributor

@per1234 and @sbhklr

In the future we can add support for Serial to the M4 by piping the messages to the M7.

That makes a lot of sense. I can do my way with a #define Serial Serial1 statement.

The piping will probably use RPC which for me does not work unless I change my library cflags.txt and cxxflags.txt files with -fexceptions added to the bottom of the files. Is that something you want to make default to the library? I placed an issue here

@sebromero sebromero force-pushed the serial-interface-rename branch from 8d731ef to 6511709 Compare September 21, 2020 07:37
@sebromero
Copy link
Collaborator Author

@per1234 We're gonna merge this PR and in a second step figure out a mechanism for mapping Serial on the M4. How do you suggest to proceed with the examples for CI? I like the test folder approach that you mentioned. This would eventually allow us to do some sort of unit/integration testing.

@per1234
Copy link
Contributor
per1234 commented Sep 25, 2020

We're gonna merge this PR and in a second step figure out a mechanism for mapping Serial on the M4.

I think that's the best approach.

How do you suggest to proceed with the examples for CI?

I would make a sketch that uses the full API of the Scheduler library, and nothing else. Something like this:

#include <Scheduler.h>

void setup() {
  Scheduler.startLoop(startLoopTask1);
  Scheduler.startLoop(startLoopTask2, 123);
  Scheduler.start(startTask1);
  Scheduler.start(startTask2, 123);
  Scheduler.start(startParametricTask1, (void*)"asdf");
  Scheduler.start(startParametricTask2, (void*)"zxcv", 123);
  Scheduler.yield();
}

void loop() {}
void startLoopTask1() {}
void startLoopTask2() {}
void startTask1() {}
void startTask2() {}
void startParametricTask1(void *bar) {}
void startParametricTask2(void *bar) {}

Put it in the dedicated folder for test sketches and then configure the "Compile Examples" workflow to compile it for all three boards:

UNIVERSAL_SKETCH_PATHS: '"libraries/Scheduler"'

UNIVERSAL_SKETCH_PATHS: test

@sebromero sebromero marked this pull request as ready for review September 25, 2020 13:16
Copy link
Contributor
@per1234 per1234 left a comment

Choose a reason for hiding this comment

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

I would like to see the following added to this PR:

  • Add your preprocessor code to the Portenta_System library's examples to make them still compile for the Portenta H7 (M4 core) board.
  • Update "Compile Examples" workflow so the Scheduler library examples are not compiled for the Portenta H7 (M4 core) board. This only requires moving the "libraries/Scheduler" path from here to there and there

After a discussion with @hpssjellis I concluded that it's confusing the map the serial interfaces to different UART port depending on the core. It's probably more understandable if the M4 doesn't support `Serial` for now, or to map it also to _UART1_. In the future we can add support for `Serial` to the M4 by piping the messages to the M7.
@sebromero sebromero force-pushed the serial-interface-rename branch from 6511709 to 86962f7 Compare October 12, 2020 10:04
@sebromero sebromero requested a review from facchinm October 12, 2020 10:17
@sebromero
Copy link
Collaborator Author

@per1234 Github doesn't allow me to re-request a review from you, so I'm just gonna tag you here :-) Can you have a look at the changes? I'd love to get this into the imminent release of 1.2.3

@github-actions
Copy link

Memory usage change @ 86962f7

Board flash % RAM for global variables %
arduino-beta:mbed:envie_m4 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino-beta:mbed:envie_m7 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino-beta:mbed:nano33ble 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
Click for full report table
Board libraries/doom/examples/Doom
flash
% libraries/doom/examples/Doom
RAM for global variables
% libraries/KernelDebug/examples/KernelDebug
flash
% libraries/KernelDebug/examples/KernelDebug
RAM for global variables
% libraries/Portenta_SDCARD/examples/TestSDCARD
flash
% libraries/Portenta_SDCARD/examples/TestSDCARD
RAM for global variables
% libraries/Portenta_System/examples/PortentaH7_getBootloaderInfo
flash
% libraries/Portenta_System/examples/PortentaH7_getBootloaderInfo
RAM for global variables
% libraries/Portenta_System/examples/PortentaH7_updateBootloader
flash
% libraries/Portenta_System/examples/PortentaH7_updateBootloader
RAM for global variables
% libraries/Portenta_Video/examples/Envie_video_coreboot
flash
% libraries/Portenta_Video/examples/Envie_video_coreboot
RAM for global variables
% libraries/ThreadDebug/examples/ThreadDebug
flash
% libraries/ThreadDebug/examples/ThreadDebug
RAM for global variables
% libraries/USBHOST/examples/KeyboardController
flash
% libraries/USBHOST/examples/KeyboardController
RAM for global variables
% libraries/USBHOST/examples/Shell
flash
% libraries/USBHOST/examples/Shell
RAM for global variables
% libraries/Scheduler/examples/MultipleBlinks
flash
% libraries/Scheduler/examples/MultipleBlinks
RAM for global variables
% libraries/PDM/examples/PDMSerialPlotter
flash
% libraries/PDM/examples/PDMSerialPlotter
RAM for global variables
%
arduino-beta:mbed:envie_m4 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0
arduino-beta:mbed:envie_m7 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0
arduino-beta:mbed:nano33ble 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0
Click for full report CSV
Board,libraries/doom/examples/Doom<br>flash,%,libraries/doom/examples/Doom<br>RAM for global variables,%,libraries/KernelDebug/examples/KernelDebug<br>flash,%,libraries/KernelDebug/examples/KernelDebug<br>RAM for global variables,%,libraries/Portenta_SDCARD/examples/TestSDCARD<br>flash,%,libraries/Portenta_SDCARD/examples/TestSDCARD<br>RAM for global variables,%,libraries/Portenta_System/examples/PortentaH7_getBootloaderInfo<br>flash,%,libraries/Portenta_System/examples/PortentaH7_getBootloaderInfo<br>RAM for global variables,%,libraries/Portenta_System/examples/PortentaH7_updateBootloader<br>flash,%,libraries/Portenta_System/examples/PortentaH7_updateBootloader<br>RAM for global variables,%,libraries/Portenta_Video/examples/Envie_video_coreboot<br>flash,%,libraries/Portenta_Video/examples/Envie_video_coreboot<br>RAM for global variables,%,libraries/ThreadDebug/examples/ThreadDebug<br>flash,%,libraries/ThreadDebug/examples/ThreadDebug<br>RAM for global variables,%,libraries/USBHOST/examples/KeyboardController<br>flash,%,libraries/USBHOST/examples/KeyboardController<br>RAM for global variables,%,libraries/USBHOST/examples/Shell<br>flash,%,libraries/USBHOST/examples/Shell<br>RAM for global variables,%,libraries/Scheduler/examples/MultipleBlinks<br>flash,%,libraries/Scheduler/examples/MultipleBlinks<br>RAM for global variables,%,libraries/PDM/examples/PDMSerialPlotter<br>flash,%,libraries/PDM/examples/PDMSerialPlotter<br>RAM for global variables,%
arduino-beta:mbed:envie_m4,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0
arduino-beta:mbed:envie_m7,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0
arduino-beta:mbed:nano33ble,,,,,,,,,,,,,,,,,,,,,,,,,0,0.0,0,0.0,,,,,,,,,0,0.0,0,0.0,0,0.0,0,0.0

Copy link
Contributor
@per1234 per1234 left a comment

Choose a reason for hiding this comment

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

I like this change. Thanks @sbhklr for making it and also to @hpssjellis for the suggestion!

facchinm added a commit that referenced this pull request Oct 27, 2020
Supersedes #54

When we'll have full support for SerialRPC we can simply replace that line
(still need to understand how to notify the error in case CM7 is missing the "companion" code).
@facchinm
Copy link
Member

Replaced by 58fee8b .
96a3416 will be merged standalone

@facchinm facchinm closed this Oct 27, 2020
@sebromero sebromero deleted the serial-interface-rename branch October 27, 2020 15:02
@sebromero
Copy link
Collaborator Author

@facchinm no need to apply 96a3416 as this is redundant with your changes from 58fee8b

sebromero pushed a commit to sebromero/ArduinoCore-mbed that referenced this pull request Feb 2, 2022
Supersedes arduino#54

When we'll have full support for SerialRPC we can simply replace that line
(still need to understand how to notify the error in case CM7 is missing the "companion" code).
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
0