-
Notifications
You must be signed in to change notification settings - Fork 4
Bugs: Typical sketches that do not compile with arduino-cli
(MT)
#43
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
Comments
So, that's in fact a lot 🙃
The proposal about the threading class looks interesting but I'm thinking about how it copes with variables (which is the thing we want to protect). Adding |
Hi @facchinm 👋 ☕ 🐐 It sure looks like a lot but in fact every single item results from the fact that the whole But in my understanding this is not a problem. Instead I think this is fantastic because we only need to fix one thing instead of coming up with work-arounds and solutions for each of the 4 cases I listed above (and there may be more which I've simply not uncovered yet). Now, I don't understand how /* Arduino_Threads.h */
#define THD_ENTER(tabname) class ARDUINO_THREADS_CONCAT(tabname, Class) : public Arduino_Threads { \
public: \
ARDUINO_THREADS_CONCAT(tabname, Class)() { _tabname = ARDUINO_THREADS_TO_STRING(tabname); } \
protected: \
virtual void setup() override; \
virtual void loop () override; \
}; \
ARDUINO_THREADS_CONCAT(tabname,Class) tabname;
/* MyThread.inot */
THD_ENTER("MyThread"); and to just prefix -void setup() {
+void MyThread::setup() {
-void loop() {
+void MyThread::loop() { Doing so would eliminate all issues introduced by putting every |
My main concern is due to variable, which can't be prefixed (it would change their scope) and we don't want them to be available to other parts of the "project" (and this is enforced by the |
This could still be solved by encapsulating the whole file in +namespace MyThreadNamespace {
/* ... */
+} /* MyThreadNamespace */ |
Would you mind creating a PoC of the resulting "preprocessed" code so I can reproduce it in the cli? I'm still not 100% it's working as expected 🙂 |
Dear Community! The way multi-threading for Arduino currently works is by wrapping the complete content of an inot-file within the class body of a special C++ class. This comes with certain disadvantages as begin discussed in this thread. There is a solution for most of these problems by instead of encapsulating the whole file within a class body you just encapsulate the whole inot-file within a namespace (see #47). Alternately you can either write your code in a different way (see https://github.com/arduino-libraries/Arduino_Threads/pull/52/files). What's your opinion on this subject? Would you prefer inot-files to be realised via class-body or via namespace? |
This issue contains a list of sketches which contain typical programming paradigms which break when compiling with the current version of the multi-threading supporting
arduino-cli
, due to the relatively simple wrapping of the whole file within a class.1)
.inot
contains both function definition and declarationBreaks_1.zip
2) Failure to register callback since all functions within the .inot` file are effectively member functions (and not free functions)
Breaks_2.zip
3) Initialisation of static variable fails (due to being a class member instead of a default global variable)
Breaks_3.zip
4) Instantiating any kind of object with constructor within the class fails (obviously)
Breaks_4.zip
One possible fix for all those issues would be to directly instantiate the threading class within the start of the
inot
file, then only prefix setup/loop with class name, i.e.@facchinm What do you think? Can you rework the arduino-cli branch to support this?
CC @pnndra
The text was updated successfully, but these errors were encountered: