You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix Arduino build and warnings on PlatformIO and Arduino (#5)
* Enable warnings for PlatformIO builds
Enable a basic set of warnings to find problems with
PlatformIO builds. Stop on error so they don't build up
in future.
Note: There are many warnings currently so this breaks the build.
* Remove unused variables and redundant code
* Fix serious warnings in OICan
This addresses the following problems in OICan functions:
- handleSdoResponse() and handleUpdate() explicitly handle the
end states of the state machines to fix a warnings with
unhandled switch cases.
- SendJson() function was not correctly advancing the update
state.
- SendCanMapping() is more careful about the initial state of
the data for each CAN mapping to avoid an uninitialised data
read warning.
* Fix CppCheck linting problems
CppCheck was picking up a number of issues:
- Missing prototype for deleteOldest()
- Not setting the path correctly in handleFileList()
- Confusing type and variable names for OICan::state
and OICan::updstate
* Fix ambigous overload of OICan::setValueSdo()
The newer gcc 12.2 compiler in the Arduino platform for the ESP32
objects to the overload of OICan::setValueSdo(). As the floating
point conversion is used in only one place it is probably
easiest to move the conversion to the call site.
* Portable printf/snprintf formatting of uint32_t values
The PlatformIO esp32 platform uses an older ESP-IDF compiler based
on gcc 8.4 whereas the official Espressif Arduino IDE platform
uses a much newer gcc 12.2 compiler. The definition of uint32_t
has changed from unsigned int to unsigned long int. This causes
problems for printf() and snprintf() format strings.
The format strings have been updated to use the portable PRI_xxx
macros. This reduces readability somewhat but stops undefined
behaviour.
* Fix structure initialisation in ESP-IDF structures
The uart_config_t structure used in the main sketch setup() was
not fully initialised. The fix uses the correct constants from
the ESP-IDF to represent the zero value the original code was
implicitly assuming.
The twai_general_config_t structure in OICan::Init() was missing
an interrupt flag initialiser. Fix the warning by explicitly
setting to zero to match the previous implict assumption.
* Fix odd stringop-overread warning in binaryLoggingStart()
The newer gcc 12.2 in the Arduino platform reports
-Wstringop-overread in binaryLoggingStart(). The length check
doesn't make a lot of sense so change to using a plain strlen().
* Allow boards with a pre-defined LED_BUILTIN
A warning about masking the LED_BUILTIN define is reported when
using a WEMOS LOLIN32 Lite board. The board should be compatible
with the official hardware so only define LED_BUILTIN if required.
* Upgrade to ArduinoJson 7
ArduinoJson 7 uses the heap (intelligently) for
allocations rather than requiring users to choose
between static and dynamic allocation. This updates
the project to use the new API.
In doing this it fixes an intermittent allocation failure in
SendJson() when concurrent requests are received
from the browser.
0 commit comments