Closed darksworm closed 3 years ago
Upon some further inspection this seems to be an issue with the arduino upload command.
arduino --upload --board arduino:avr:uno --port /dev/ttyUSB0 --pref programmer=arduino:avrispmkii --pref build.path=./build test.ino
Results in the same error (this command is similar to that which is currently used in the plugin).
But this this works (after changing test.h
to test.cpp
):
arduino-cli compile -b arduino:avr:uno . -v --build-path `pwd`/build && arduino-cli upload -p /dev/ttyUSB0 --fqbn arduino:avr:uno
Some time later... I don't know what I did, but it suddenly started working...
It has been working flawlessly ever since. It was probably a peculiarity with my system.
Glad to hear it's working! LMK if you ever manage to repro
Just managed to reproduce it - the issue occurs when the main ino
file is in a directory that is named differently than it.
In my case - my main source file is named wul.ino
, so it expects that it's parent directory is called wul
.
See attached gifs for reproduction steps & proof:
compiling wul.ino
from a directory named src
- does not work.
compiling wul.ino
from a directory named wul
- works.
I'm sure that this issue is isolated to the directory naming, but just in case, the source code I'm trying to compile is availlable here.
Unfortunately this seems to be a limitation of the Arduino toolchain. There has been some discussion and it's possible that this requirement will be lifted in the future https://github.com/arduino/arduino-cli/issues/948
Looks like the arduino-cli enhancement was declined. Seems like this is just the way Arduino works for the foreseeable future.
User story: When writing more complicated arduino sketches, I want to split the code up into multiple files.
Issue: Currently if I try to use
include
to inclue another source file, the compilation fails.How to recreate
Create two files in the same directory:
Try to compile & upload the sketch and this error will appear:
This code, however, compiles and uploads successfully when using the arduino-ide.