timmbogner / Farm-Data-Relay-System

A system that uses ESP-NOW, LoRa, and other protocols to transport sensor data in remote areas without relying on WiFi.
MIT License
485 stars 108 forks source link

Platformio: Compilation fails when using FDRS_DEBUG without DBG_LEVEL #196

Closed shaffenmeister closed 4 months ago

shaffenmeister commented 4 months ago

Observation

When compiling FDRS projects using platformio, the compilation fails when DEBUG_FDRS is defined in fdrs_gateway_config.h without defining DBG_LEVEL as introduced with #194 .

Same applies to nodes / controllers (fdrs_node_config.h etc.).

Compilation passes:

  1. Without definining DEBUG_FDRS.
  2. Defining both DEBUG_FDRS and DBG_LEVEL accordingly.

Environment

CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/lolin32.html PLATFORM: Espressif 32 (2024.1.1) > WEMOS LOLIN32 HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash PACKAGES:

FDRS commit a0a4fa396d0b9b360168a0a94366a2349f993993 (latest as of 12.02.2024)

Error message

Compiling .pio/build/lolin32/src/TempController.cpp.o> Compiling .pio/build/lolin32/src/gaerbox_controller.ino.cpp.o> Building .pio/build/lolin32/bootloader.bin> Generating partitions .pio/build/lolin32/partitions.bin> esptool.py v4.7.0> Creating esp32 image...> Merged 1 ELF section> Successfully created esp32 image.> Compiling .pio/build/lolin32/lib011/WiFi/WiFi.cpp.o> Compiling .pio/build/lolin32/lib011/WiFi/WiFiAP.cpp.o> Compiling .pio/build/lolin32/lib011/WiFi/WiFiClient.cpp.o> In file included from /home/cappel/dev/fdrs-fl8/lib/fdrs/src/fdrs_node.h:58,> from /home/cappel/dev/fdrs-fl8/fdrs-gaerbox/src/gaerbox_controller.ino:8:> /home/cappel/dev/fdrs-fl8/lib/fdrs/src/fdrs_node.h: In function 'void beginFDRS()':> /home/cappel/dev/fdrs-fl8/lib/fdrs/src/fdrs_debug.h:2:23: error: 'GLOBAL_DBG_LEVEL' was not declared in this scope>

define DBG_LEVEL GLOBAL_DBG_LEVEL>

                   ^~~~~~~~~~~~~~~~> 

/home/cappel/dev/fdrs-fl8/lib/fdrs/src/fdrs_debug.h:9:61: note: in definition of macro 'DBG'>

define DBG(a) Serial.print(" "); Serial.println(a);>

                                                         ^> 

/home/cappel/dev/fdrs-fl8/lib/fdrs/src/fdrs_node.h:89:46: note: in expansion of macro 'DBG_LEVEL'> DBG("Debugging verbosity level: " + String(DBG_LEVEL));> ^~~~~> /home/cappel/dev/fdrs-fl8/lib/fdrs/src/fdrs_debug.h:2:23: note: suggested alternative: 'XCHAL_INT_LEVEL'>

define DBG_LEVEL GLOBAL_DBG_LEVEL>

                   ^~~~~~~~~~~~~~~~> 

/home/cappel/dev/fdrs-fl8/lib/fdrs/src/fdrs_debug.h:9:61: note: in definition of macro 'DBG'>

define DBG(a) Serial.print(" "); Serial.println(a);>

                                                         ^> 

/home/cappel/dev/fdrs-fl8/lib/fdrs/src/fdrs_node.h:89:46: note: in expansion of macro 'DBG_LEVEL'> DBG("Debugging verbosity level: " + String(DBG_LEVEL));> ^~~~~> *** [.pio/build/lolin32/src/gaerbox_controller.ino.cpp.o] Error 1>

Files

platformio.ini.txt fdrs_node_config.h.txt

aviateur17 commented 4 months ago

Hmmm, I would have thought

in fdrs_globals.h

#define GLOBAL_DBG_LEVEL 0

in fdrs_debug.h

#ifndef DBG_LEVEL
    #define DBG_LEVEL GLOBAL_DBG_LEVEL
#endif

Should have taken care of that but maybe there's an issue with the order of the files. I'll have to check this out again.

"error: 'GLOBAL_DBG_LEVEL' was not declared in this scope>" means that maybe GLOBAL_DBG_LEVEL is not yet defined or not defined at all before fdrs_debug is compiled.

Thanks so much for reporting this and for all of that information that you provided.

aviateur17 commented 4 months ago

@shaffenmeister, I cannot reproduce the issue. Can you check your src fdrs_globals.h line 9 and see if it says:

#define GLOBAL_DBG_LEVEL 0

and then fdrs_debug.h line 1-3 and see if they say:

#ifndef DBG_LEVEL
    #define DBG_LEVEL GLOBAL_DBG_LEVEL
#endif

Thanks!

shaffenmeister commented 4 months ago

@aviateur17 Yes, cross-checked both files again and they are ok. I am using the current commit as given above. Will dive a bit deeper and come back.

Thank you!

aviateur17 commented 4 months ago

@shaffenmeister, if you feel comfortable, you can direct me to your github repo with the code or paste a zip file attachment with the entire code. Maybe email me directly, I don't know if that's possible through GitHub.

shaffenmeister commented 4 months ago

@aviateur17 , stupid me. I checked my code over and again and just now found the issue in a local library for my system, where I used #define __FDRS_GLOBALS_h__ instead of my library-local define.

My bad. Owe you a coffee, or two.

Nevermind and sorry and thank you...