RobTillaart / MS5611

Arduino library for MS5611 temperature and pressure sensor
MIT License
17 stars 5 forks source link

MS5611 compilation error: lvalue required as left operand of assignment uint32_t D1 = readADC(); #16

Closed ratio-x closed 2 years ago

ratio-x commented 2 years ago

Testing with the minimal example at master/examples/MS5611_minimal/MS5611_minimal.ino. During sketch compilation I get following error:

c:\...\Arduino\libraries\MS5611\MS5611.cpp: In member function 'int MS5611::read(uint8_t)':
c:\...\Arduino\libraries\MS5611\MS5611.cpp:141:25: error: lvalue required as left operand of assignment
   uint32_t D1 = readADC();
                         ^
c:\...\Arduino\libraries\MS5611\MS5611.cpp:146:25: error: lvalue required as left operand of assignment
   uint32_t D2 = readADC();
                         ^
Compilation error: exit status 1}

Tested with MS5611 library versions 0.3.1, 0.3.2 and 0.3.3. Tested with Arduino IDE v1.8.19 and v2.0.0-rc3.

RobTillaart commented 2 years ago

Thanks for reporting, i will investigate asap. Might rake a few days Two questions

  1. Do other examples compile?
  2. Which board do you compile for
ratio-x commented 2 years ago

The board is an Arduino Nano 33 BLE. Other examples of the MS5611 library throw the same error. Compiling other examples of other libraries (e.g. i2c_scanner) works without errors, unable to find any devices so far. But that should not prevent compiling the MS5611 lib.

RobTillaart commented 2 years ago

In the github build system it compiles - https://github.com/RobTillaart/MS5611/runs/4644607374?check_suite_focus=true around line 215-220 it compiles the minimal sketch. This is a UBUNTU environment

I use the 1.8.13 compiler, so that is a difference. Tested all compilers I installed (AVR, ESP, SAMD) but they do not throw this error. As I have no NANO BLE I will install the MBED environment later.

to be continued.

RobTillaart commented 2 years ago

OK, recreated the error under IDE 1.8.13.
Changed the name of the local variables D1 and D2 in _D1 and _D2 in the read() function.

Now it compiles without problem => so I created a branch https://github.com/RobTillaart/MS5611/tree/fix16

Can you please verify this works, then I can merge it into the master branch. (NB I have no NANO BLE to verify runtime)

RobTillaart commented 2 years ago

https://github.com/RobTillaart/MS5611/pull/18 ran succesfully unfortunately the build system I use does not support the MBED platform (need to check that again)

RobTillaart commented 2 years ago

Quick look => No support for MBED - https://github.com/Arduino-CI/arduino_ci/blob/master/misc/default.yml

ratio-x commented 2 years ago

That fixed it. Compiling and uploading now without errors:

Sketch uses 92472 bytes (9%) of program storage space. Maximum is 983040 bytes.
Global variables use 45696 bytes (17%) of dynamic memory, leaving 216448 bytes for local variables. Maximum is 262144 bytes.

--------------------------
Compilation complete.
Device       : nRF52840-QIAA
Version      : Arduino Bootloader (SAM-BA extended) 2.0 [Arduino:IKXYZ]
Address      : 0x0
Pages        : 256
Page Size    : 4096 bytes
Total Size   : 1024KB
Planes       : 1
Lock Regions : 0
Locked       : none
Security     : false
Erase flash

Done in 0.000 seconds
Write 92480 bytes to flash (23 pages)

[                              ] 0% (0/23 pages)
[=                             ] 4% (1/23 pages)
[==                            ] 8% (2/23 pages)
[===                           ] 13% (3/23 pages)
[=====                         ] 17% (4/23 pages)
[======                        ] 21% (5/23 pages)
[=======                       ] 26% (6/23 pages)
[=========                     ] 30% (7/23 pages)
[==========                    ] 34% (8/23 pages)
[===========                   ] 39% (9/23 pages)
[=============                 ] 43% (10/23 pages)
[==============                ] 47% (11/23 pages)
[===============               ] 52% (12/23 pages)
[================              ] 56% (13/23 pages)
[==================            ] 60% (14/23 pages)
[===================           ] 65% (15/23 pages)
[====================          ] 69% (16/23 pages)
[======================        ] 73% (17/23 pages)
[=======================       ] 78% (18/23 pages)
[========================      ] 82% (19/23 pages)
[==========================    ] 86% (20/23 pages)
[===========================   ] 91% (21/23 pages)
[============================  ] 95% (22/23 pages)
[==============================] 100% (23/23 pages)
Done in 3.798 seconds

--------------------------
upload complete.

Unfortunately I get no output from the serial monitor, but that seems to be another problem independent from the MS5611 board and library, since this happens randomly with other libraries and example sketches.

Anyway, this is a good moment to thank you for your work on that valuable library. I really appreciate it!

RobTillaart commented 2 years ago

Welcome, I will merge the fix asap. (and put an NANO BLE on my wish list for testing)

Happy new year!