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

Dev - sketches in examples folder of current dev branch do not compile. #86

Closed Gulpman closed 1 year ago

Gulpman commented 1 year ago

Example sketches do not compile.

I could fix some of the issues but am stuck with what is left.

Here's the compile output from Arduino IDE for this pull request:

In file included from D:\_sync\Sascha\OneDrive\Documents\Arduino\libraries\Farm-Data-Relay-System\examples\1_LoRa_Sensor\1_LoRa_Sensor.ino:10:0:
D:\_sync\Sascha\OneDrive\Documents\Arduino\libraries\Farm-Data-Relay-System/fdrs_sensor.h: In function 'crcResult getLoRa()':
D:\_sync\Sascha\OneDrive\Documents\Arduino\libraries\Farm-Data-Relay-System/fdrs_sensor.h:199:33: error: 'SystemPacket' was not declared in this scope
   if ((packetSize - 6) % sizeof(SystemPacket) == 0 && packetSize > 0) {  // packet size should be 6 bytes plus multiple of size of SystemPacket
                                 ^
D:\_sync\Sascha\OneDrive\Documents\Arduino\libraries\Farm-Data-Relay-System/fdrs_sensor.h:206:18: error: expected ';' before 'receiveData'
     SystemPacket receiveData[ln];
                  ^
D:\_sync\Sascha\OneDrive\Documents\Arduino\libraries\Farm-Data-Relay-System/fdrs_sensor.h:216:14: error: 'receiveData' was not declared in this scope
       memcpy(receiveData, &packet[4], packetSize - 6);   //Split off data portion of packet (N bytes)
              ^
In file included from D:\_sync\Sascha\OneDrive\Documents\Arduino\libraries\Farm-Data-Relay-System\examples\1_LoRa_Sensor\1_LoRa_Sensor.ino:10:0:
D:\_sync\Sascha\OneDrive\Documents\Arduino\libraries\Farm-Data-Relay-System/fdrs_sensor.h: In function 'void sendFDRS()':
D:\_sync\Sascha\OneDrive\Documents\Arduino\libraries\Farm-Data-Relay-System/fdrs_sensor.h:340:49: error: invalid conversion from 'uint16_t {aka short unsigned int}' to 'uint16_t* {aka short unsigned int*}' [-fpermissive]
   transmitLoRa(gtwyAddress, fdrsData, data_count);
                                                 ^
In file included from D:\_sync\Sascha\OneDrive\Documents\Arduino\libraries\Farm-Data-Relay-System\examples\1_LoRa_Sensor\1_LoRa_Sensor.ino:10:0:
D:\_sync\Sascha\OneDrive\Documents\Arduino\libraries\Farm-Data-Relay-System/fdrs_sensor.h:270:6: note:   initializing argument 1 of 'void transmitLoRa(uint16_t*, DataReading*, uint8_t)'
 void transmitLoRa(uint16_t* destMAC, DataReading * packet, uint8_t len) {
      ^
exit status 1
Fehler beim Kompilieren für das Board ESP32 Dev Module.

As this is only happening in the examples folder but not in the FDRS_Sensor and FDRS_Gateway folder I think it may have to do something with an order issue?

@aviateur17 can you check this?

aviateur17 commented 1 year ago

Yep, I will make sure all of the sketches in the dev branch compile by the next couple days.

aviateur17 commented 1 year ago

In the Stress Test sketch, FDRS_DEBUG needs to be uncommented out in the fdrs_sensor_config.h or compilation will fail. Seems that the code under DEBUG_NODE_CONFIG also depends upon FDRS_DEBUG uncommented as well. When FDRS_DEBUG is commented then resetReason is not defined and compile fails. Not sure what the original intention here was. Were both DEBUG_NODE_CONFIG and FDRS_DEBUG to be used in tandem together or individually. I'm not going to change that part of the code but just a heads up on the reason it may not compile due to undefined resetReason.

timmbogner commented 1 year ago

I've merged everything else, leaving this for now. Fingers crossed I fixed all the conflicts correctly. As mentioned in #87, you guys are now free to reorganize the repo!

Gulpman commented 1 year ago

I've merged everything else, leaving this for now. Fingers crossed I fixed all the conflicts correctly. As mentioned in #87, you guys are now free to reorganize the repo!

Unfortunately not fully: FDRS_Sensor and FDRS_Gateway do compile, the examples don't:

Output from 01_LoRa_sensor:

In file included from D:\_sync\Sascha\OneDrive\Documents\Arduino\libraries\Farm-Data-Relay-System\examples\1_LoRa_Sensor\1_LoRa_Sensor.ino:10:0:
D:\_sync\Sascha\OneDrive\Documents\Arduino\libraries\Farm-Data-Relay-System/fdrs_sensor.h: In function 'crcResult getLoRa()':
D:\_sync\Sascha\OneDrive\Documents\Arduino\libraries\Farm-Data-Relay-System/fdrs_sensor.h:235:51: error: 'transmitLoRa' was not declared in this scope
             transmitLoRa(&sourceMAC, &pingReply, 1);
                                                   ^
D:\_sync\Sascha\OneDrive\Documents\Arduino\libraries\Farm-Data-Relay-System/fdrs_sensor.h:257:51: error: 'transmitLoRa' was not declared in this scope
             transmitLoRa(&sourceMAC, &pingReply, 1);
                                                   ^
exit status 1
Fehler beim Kompilieren für das Board ESP32 Dev Module.

Output from the 4_UART_Gateway:

sketch\4_UART_Gateway.ino.cpp.o:(.literal._Z7getLoRav+0x90): undefined reference to `transmitLoRa(unsigned short*, SystemPacket*, unsigned char)'
sketch\4_UART_Gateway.ino.cpp.o: In function `getLoRa()':
D:\_sync\Sascha\OneDrive\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/Misc/SafeBoolIdiom.hpp:15: undefined reference to `transmitLoRa(unsigned short*, SystemPacket*, unsigned char)'
D:\_sync\Sascha\OneDrive\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/Misc/SafeBoolIdiom.hpp:15: undefined reference to `transmitLoRa(unsigned short*, SystemPacket*, unsigned char)'
D:\_sync\Sascha\OneDrive\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/Misc/SafeBoolIdiom.hpp:15: undefined reference to `transmitLoRa(unsigned short*, SystemPacket*, unsigned char)'
collect2.exe: error: ld returned 1 exit status
exit status 1
Fehler beim Kompilieren für das Board ESP32 Dev Module.
Gulpman commented 1 year ago

@timmbogner could you check why this commit is not compiling? Or maybe @aviateur17 can help?

It would be helpful to have this fixed before reorganizing the folder structure as we can then assure during reorganization everything compiles well and we do not break something.

timmbogner commented 1 year ago

I mentioned this in #90 because I hadn't seen this. Still getting used to navigating GitHub.

I don't think it's something I did in conflict resolution, but let's see what @aviateur17 thinks.

aviateur17 commented 1 year ago

The "not declared" messages during compile in Arduino are related to functions that are used before they are defined. The workaround this is to add function prototypes near the top of the file. I did this in PR #88 in commit fdc941658ec3ab7d08dee555ef6d00dc8367fe80. It was merged into dev branch so I'm wondering why the issue still exists. Have you updated the dev branch on your computer and it still does not compile? If so then we have some merging issue.

For gateway you can try adding the following code on line 261 of fdrs_functions.h:

// Function prototypes
void transmitLoRa(uint16_t*, DataReading*, uint8_t);
void transmitLoRa(uint16_t*, SystemPacket*, uint8_t);
static uint16_t crc16_update(uint16_t, uint8_t);

Try the same function prototypes in the sensor.h file. Add the prototypes before any functions in the file but after the #defines and variables.

aviateur17 commented 1 year ago

In the dev branch, line #263 of fdrs_functions.h has the function prototypes. Can you check your fdrs_functions.h files and make sure they have the prototypes present on line #263?

timmbogner commented 1 year ago

I'm not very familiar with function prototypes, but I think there is a prototype but no function definition for the SystemPacket version of transmitLoRa().

aviateur17 commented 1 year ago

I'm not very familiar with function prototypes, but I think there is a prototype but no function definition for the SystemPacket version of transmitLoRa().

for fdrs_functions.h The prototype should be on line 265 The definition should be on line .....

Yep the function is missing. Wonder how that happened.

aviateur17 commented 1 year ago

PR #84 commit f32a4f9f9d13d7fe43dc94e0959baad0993abcc8 Added the function. Maybe it was lost in merge? Should I submit another PR?

timmbogner commented 1 year ago

It could have been an error on my part resolving conflicts. I'll take a look.

timmbogner commented 1 year ago

I'm not sure where it went wrong, but adding the function back fixes the gateway. The sensor looks like it already has it though, I'm confused why it doesn't work.

I am going to merge this PR right now and let's move this discussion to issue #90

aviateur17 commented 1 year ago

Will do. Dev branch, right?

On Sat, Jul 30, 2022, 2:59 PM Sascha @.***> wrote:

Example sketches do not compile.

I could fix some of the issues but am stuck with what is left.

Here's the compile output from Arduino IDE for this pull request:

In file included from D:_sync\Sascha\OneDrive\Documents\Arduino\libraries\Farm-Data-Relay-System\examples\1_LoRa_Sensor\1_LoRa_Sensor.ino:10:0:

D:_sync\Sascha\OneDrive\Documents\Arduino\libraries\Farm-Data-Relay-System/fdrs_sensor.h: In function 'crcResult getLoRa()':

D:_sync\Sascha\OneDrive\Documents\Arduino\libraries\Farm-Data-Relay-System/fdrs_sensor.h:199:33: error: 'SystemPacket' was not declared in this scope

if ((packetSize - 6) % sizeof(SystemPacket) == 0 && packetSize > 0) { // packet size should be 6 bytes plus multiple of size of SystemPacket

                             ^

D:_sync\Sascha\OneDrive\Documents\Arduino\libraries\Farm-Data-Relay-System/fdrs_sensor.h:206:18: error: expected ';' before 'receiveData'

 SystemPacket receiveData[ln];

              ^

D:_sync\Sascha\OneDrive\Documents\Arduino\libraries\Farm-Data-Relay-System/fdrs_sensor.h:216:14: error: 'receiveData' was not declared in this scope

   memcpy(receiveData, &packet[4], packetSize - 6);   //Split off data portion of packet (N bytes)

          ^

In file included from D:_sync\Sascha\OneDrive\Documents\Arduino\libraries\Farm-Data-Relay-System\examples\1_LoRa_Sensor\1_LoRa_Sensor.ino:10:0:

D:_sync\Sascha\OneDrive\Documents\Arduino\libraries\Farm-Data-Relay-System/fdrs_sensor.h: In function 'void sendFDRS()':

D:_sync\Sascha\OneDrive\Documents\Arduino\libraries\Farm-Data-Relay-System/fdrs_sensor.h:340:49: error: invalid conversion from 'uint16_t {aka short unsigned int}' to 'uint16_t {aka short unsigned int}' [-fpermissive]

transmitLoRa(gtwyAddress, fdrsData, data_count);

                                             ^

In file included from D:_sync\Sascha\OneDrive\Documents\Arduino\libraries\Farm-Data-Relay-System\examples\1_LoRa_Sensor\1_LoRa_Sensor.ino:10:0:

D:_sync\Sascha\OneDrive\Documents\Arduino\libraries\Farm-Data-Relay-System/fdrs_sensor.h:270:6: note: initializing argument 1 of 'void transmitLoRa(uint16_t, DataReading, uint8_t)'

void transmitLoRa(uint16_t destMAC, DataReading packet, uint8_t len) {

  ^

exit status 1

Fehler beim Kompilieren für das Board ESP32 Dev Module.

As this is only happening in the examples folder but not in the FDRS_Sensor and FDRS_Gateway folder I think it may have to do something with an order issue?

@aviateur17 https://github.com/aviateur17 can you check this?

You can view, comment on, or merge this pull request online at:

https://github.com/timmbogner/Farm-Data-Relay-System/pull/86 Commit Summary

File Changes

(20 files https://github.com/timmbogner/Farm-Data-Relay-System/pull/86/files)

Patch Links:

— Reply to this email directly, view it on GitHub https://github.com/timmbogner/Farm-Data-Relay-System/pull/86, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOTXENKO2ILYUQ2T4L465Y3VWWCSLANCNFSM55DW2RWA . You are receiving this because you were mentioned.Message ID: @.***>

timmbogner commented 1 year ago

@aviateur17 Hey is this a glitch? I got another response to an outdated topic right around the same time.

aviateur17 commented 1 year ago

@timmbogner not sure that I put that comment up yesterday. Confused as to why that is there.

Are you referring to the compile issues in VSCode that someone brought up?

timmbogner commented 1 year ago

@timmbogner not sure that I put that comment up yesterday. Confused as to why that is there.

Are you referring to the compile issues in VSCode that someone brought up?

@aviateur17 No, a user who hasn't been around since July posted a response in a closed issue about 30 mins before this one.

Must have been a glitch, very odd.