Go Down

Topic: Want to test and debug 4 code projects for 3 different MCU types (Read 391 times) previous topic - next topic


I'm working on a project which involves 3 different microcontrollers/modules, all of which can be handled through the Arduino IDE.

This is proving quite prone to error as when you are testing & debugging you have to keep remembering to check that you have the correct board listed in board manager and that you have the right serial port before recompiling & flashing/uploading - this is because the Arduino cannot have multiple instances of the board & serial port etc.

This is especially problematic where I have two separate code projects for 2 MCU's which are of the same type - not always helpful where some GPIO's which are assigned as inputs now becoming outputs on the board (with sensors attached) due to the wrong project being flashed onto the wrong board.

I've done a quick search on the forum and results showed that a similar question has been asked before:

2015: http://forum.arduino.cc/index.php?topic=351643.0
2017: https://forum.arduino.cc/index.php?topic=480263.0
2017: https://forum.arduino.cc/index.php?topic=480594.0

So I wanted to raise this issue again as the ecosystem is now very broad due to the number of cross-compatible libraries and robust communication interfaces (A GOOD THING  :) ). It would be nice to have an IDE that can handle this. So I am wondering, are there any plans for changing the IDE as this is problematic - and this issue has been raised before.

Otherwise, what is the recommended approach, for now, to handling multiple instances for safely compiling and flashing/uploading code?


I use the Geany editor for all my Arduino (and other) programming

I have written a simple Python program to compile and upload Arduino code using the command-line IDE. The Python program converts relative references to absolute references.

At the top of my .ino files I have some comments like this
Code: [Select]
// python-build-start
// action, verify
// board, arduino:avr:mega:cpu=atmega2560
// port, /dev/ttyACM0
// ide, 1.8.6
// python-build-end

which my Python program uses to figure out the various settings.

That means that I don't have to worry about compiling a program for the wrong board, or on the wrong serial port if I am working with two separate Arduino boards at the same time.

The program also expands relative file references so that I can easily share a file between several programs - for example several wireless devices will need to use the same frequency and data rate

The program is very straightforward, it just runs through from top to bottom once. If it is not exactly what you need it may not be difficult to adapt it. The Python program will also work standalone without Geany.

Two or three hours spent thinking and reading documentation solves most programming problems.


Thanks for this option. Yes, I like the approach of manually inserting meta-data in the code to facilitate this process. It is a nice workaround/enhancement, although it would be nice if the IDE automated this.

So, if I understand this option your python code is used via CLI and this app uses this metadata to chose compiler and serial port options to compile and upload correctly. Nice.


Is there any way there could be a simple solution introduced where the compiler compares board manager settings to meta-data (which would be defined in a certain format) inside a comment in the first lines etc. or create some new pre-compiler definition or something along those lines e.g.

This could at least generate a message to say that the two do not match. If the comments or pre-compile directives do not match the defined format then the compiler can ignore. Arduino could still be left to compile as normal but at least the user can see that a warning message has been logged.

Go Up