Hi all,
I am building software for the arduino platform, but want to run the tests using the native platform and ArduinoFake. This works, except that all the Arduino libraries specify platforms="arduino"
in the library.json, which means the libraries can’t be used on the “native” platform? I am using for instance ArduinoJson, DallasTemperature, etc. I understand that if it really depends on hardware, for instance because of SPI or stuff, it won’t work on the native platform. I don’t mind having to create Mock versions in that case (if ArduinoFake doesn’t provide them). But making Mock versions of every library seems a bit of a waste of time. Am I doing something wrong here?
Basically the error I run into when running pio run -e native
is
fatal error: ArduinoJson.h: No such file or directory
and similar for DallasTemperature.h and others. The libaries are located in .pio/libdeps/native (after running pio lib install ArduinoJson
. Also, if I run pio run -t idedata -d .
it doesn’t list the libraries in the ‘includes’ list for the native environment, but it does list them for the other environments.
This is the native environment of my platform.ini:
[env:native]
platform = native
test_ignore = test_embedded
build_flags = -g
lib_deps =
ArduinoFake
MockLib
2 Likes
You should be able to add lib_compat_mode = off
to that platformio.ini
to make it so the LDF doesn’t do any compatibility checks… as the default soft
mode still does the framework = arduino
check.
2 Likes
I think I am getting closer. I added lib_compat_mode = off
to my platformio.ini “native” environment, which makes sure that libraries that compatibility check for frameworks isn’t done. So all libraries are included, irrespective of platform or framework. I made sure at the top of src/main.h
(for NATIVE devices) I first #include <MockLib.h>
which in turn #include <ArduinoFake.json>
. So that way I think it should first include ArduinoFake and all it’s stuff, and I can add additional stuff in MockLib.
This works except for one issue: I see that ArduinoFake does include the avr/interrupt.h
. But in my source I also #include <avr/interrupt.h>
but during compiling, I get the error
fatal error: avr/interrupt.h: No such file or directory
This is the building output:
Building in release mode
Compiling .pio/build/native/src/main.o
Compiling .pio/build/native/lib818/ArduinoFake_ID1689/ArduinoFake.o
Compiling .pio/build/native/lib818/ArduinoFake_ID1689/ClientFake.o
Compiling .pio/build/native/lib818/ArduinoFake_ID1689/FunctionFake.o
Compiling .pio/build/native/lib818/ArduinoFake_ID1689/PrintFake.o
Compiling .pio/build/native/lib818/ArduinoFake_ID1689/SerialFake.o
Compiling .pio/build/native/lib818/ArduinoFake_ID1689/StreamFake.o
Compiling .pio/build/native/lib818/ArduinoFake_ID1689/arduino/IPAddress.o
Compiling .pio/build/native/lib818/ArduinoFake_ID1689/arduino/WString.o
Compiling .pio/build/native/lib818/ArduinoFake_ID1689/arduino/noniso.o
Compiling .pio/build/native/liba73/MockLib/MockEEPROM.o
Compiling .pio/build/native/liba73/MockLib/MockSX1272.o
Compiling .pio/build/native/libd3d/MyConfig/MyConfig.o
Compiling .pio/build/native/libc3a/MyLora/MyLora.o
Compiling .pio/build/native/lib3ac/OneWire_ID1/OneWire.o
Compiling .pio/build/native/lib500/DallasTemperature_ID54/DallasTemperature.o
In file included from .pio/libdeps/native/OneWire_ID1/OneWire.cpp:144:
.pio/libdeps/native/OneWire_ID1/util/OneWire_direct_gpio.h:416:2: warning: #warning "OneWire. Fallback mode. Using API calls for pinMode,digitalRead and digitalWrite. Operation of this library is not guaranteed on this architecture." [-Wcpp]
416 | #warning "OneWire. Fallback mode. Using API calls for pinMode,digitalRead and digitalWrite. Operation of this library is not guaranteed on this architecture."
| ^~~~~~~
Compiling .pio/build/native/libc4f/MySensors/MySensors.o
Compiling .pio/build/native/lib26a/mylib/mylib.o
Archiving .pio/build/native/liba73/libMockLib.a
Indexing .pio/build/native/liba73/libMockLib.a
Compiling .pio/build/native/libfcc/mylib/mylib.o
In file included from lib/mylib/src/mylib.cpp:17:
lib/mylib/src/mylib.h:5:10: fatal error: avr/interrupt.h: No such file or directory
The issue I had here is that ArduinoFake has these files in arduino/avr/interrup.h
. The easy way for me to fix it is make my own ‘avr/interrupt.h’ in my MockLib library and in there just #include arduino/avr/interrupt.h
, effectively creating an alias.
2 Likes