corneliusmunz / legoino

Arduino Library for controlling Powered UP and Boost controllers
MIT License
257 stars 34 forks source link

uint32_t type mismatch for ESP32 #79

Open SFrijters opened 6 months ago

SFrijters commented 6 months ago

When trying to compile the TrainHub example for esp32:esp32:XIAO_ESP32C3 I ran into the following error

/<ARDUINO_DIRECTORIES_USER>/internal/Legoino_1.1.0_f5d0c9dbfa55ee37/Legoino/src/LegoinoCommon.cpp:101:10: error: no declaration matches 'uint32_t LegoinoCommon::ReadUInt32LE(uint8_t*, int)'
 uint32_t LegoinoCommon::ReadUInt32LE(uint8_t *data, int offset = 0)
          ^~~~~~~~~~~~~
In file included from /<ARDUINO_DIRECTORIES_USER>/internal/Legoino_1.1.0_f5d0c9dbfa55ee37/Legoino/src/LegoinoCommon.cpp:11:
/<ARDUINO_DIRECTORIES_USER>/internal/Legoino_1.1.0_f5d0c9dbfa55ee37/Legoino/src/LegoinoCommon.h:27:23: note: candidate is: 'static unsigned int LegoinoCommon::ReadUInt32LE(uint8_t*, int)'
   static unsigned int ReadUInt32LE(uint8_t *data, int offset);
                       ^~~~~~~~~~~~
/<ARDUINO_DIRECTORIES_USER>/internal/Legoino_1.1.0_f5d0c9dbfa55ee37/Legoino/src/LegoinoCommon.h:17:7: note: 'class LegoinoCommon' defined here
 class LegoinoCommon
       ^~~~~~~~~~~~~
/<ARDUINO_DIRECTORIES_USER>/internal/Legoino_1.1.0_f5d0c9dbfa55ee37/Legoino/src/LegoinoCommon.cpp:107:9: error: no declaration matches 'int32_t LegoinoCommon::ReadInt32LE(uint8_t*, int)'
 int32_t LegoinoCommon::ReadInt32LE(uint8_t *data, int offset = 0)
         ^~~~~~~~~~~~~
In file included from /<ARDUINO_DIRECTORIES_USER>/internal/Legoino_1.1.0_f5d0c9dbfa55ee37/Legoino/src/LegoinoCommon.cpp:11:
/<ARDUINO_DIRECTORIES_USER>/internal/Legoino_1.1.0_f5d0c9dbfa55ee37/Legoino/src/LegoinoCommon.h:28:21: note: candidate is: 'static int LegoinoCommon::ReadInt32LE(uint8_t*, int)'
   static signed int ReadInt32LE(uint8_t *data, int offset);
                     ^~~~~~~~~~~
/<ARDUINO_DIRECTORIES_USER>/internal/Legoino_1.1.0_f5d0c9dbfa55ee37/Legoino/src/LegoinoCommon.h:17:7: note: 'class LegoinoCommon' defined here
 class LegoinoCommon
       ^~~~~~~~~~~~~

I think this may be related to https://github.com/espressif/esp-idf/issues/6906#issuecomment-1207373706 , assuming it used to work?

For me, replacing unsigned int -> unsigned long and signed int -> signed long in https://github.com/corneliusmunz/legoino/blob/master/src/LegoinoCommon.h solved the issue, but I'm not sure why the function prototypes don't use uint32_t in the first place, like their implementations?