FOSSASystems / FOSSA-Comms

Reference implementation of FOSSASAT Communication Protocol
12 stars 8 forks source link

Compile error #3

Closed kylix34 closed 4 years ago

kylix34 commented 4 years ago

I get this error when trying to compile the code for Arduino Uno:

Arduino: 1.8.10 (Windows 7), Board: "Arduino/Genuino Uno" ..................... C:\Program Files (x86)\Arduino\libraries\FOSSA-Comms\src\FOSSA-Comms.cpp: In function 'int16_t FCP_Get_OptData_Length(char, uint8_t, uint8_t, const uint8_t, const char)':

C:\Program Files (x86)\Arduino\libraries\FOSSA-Comms\src\FOSSA-Comms.cpp:57:20: error: aggregate 'FCP_Get_OptData_Length(char, uint8_t, uint8_t, const uint8_t, const char)::AES_ctx ctx' has incomplete type and cannot be defined

 struct AES_ctx ctx;

                ^

C:\Program Files (x86)\Arduino\libraries\FOSSA-Comms\src\FOSSA-Comms.cpp:58:27: error: 'AES_init_ctx' was not declared in this scope

 AES_init_ctx(&ctx, key);

                       ^

C:\Program Files (x86)\Arduino\libraries\FOSSA-Comms\src\FOSSA-Comms.cpp:61:50: error: 'AES_ECB_decrypt' was not declared in this scope

   AES_ECB_decrypt(&ctx, encSection + (i * 16));

                                              ^

C:\Program Files (x86)\Arduino\libraries\FOSSA-Comms\src\FOSSA-Comms.cpp: In function 'int16_t FCP_Get_OptData(char, uint8_t, uint8_t, uint8_t, const uint8_t, const char*)':

C:\Program Files (x86)\Arduino\libraries\FOSSA-Comms\src\FOSSA-Comms.cpp:146:20: error: aggregate 'FCP_Get_OptData(char, uint8_t, uint8_t, uint8_t, const uint8_t, const char*)::AES_ctx ctx' has incomplete type and cannot be defined

 struct AES_ctx ctx;

                ^

C:\Program Files (x86)\Arduino\libraries\FOSSA-Comms\src\FOSSA-Comms.cpp:147:27: error: 'AES_init_ctx' was not declared in this scope

 AES_init_ctx(&ctx, key);

                       ^

C:\Program Files (x86)\Arduino\libraries\FOSSA-Comms\src\FOSSA-Comms.cpp:150:50: error: 'AES_ECB_decrypt' was not declared in this scope

   AES_ECB_decrypt(&ctx, encSection + (i * 16));

                                              ^

C:\Program Files (x86)\Arduino\libraries\FOSSA-Comms\src\FOSSA-Comms.cpp: In function 'int16_t FCP_Encode(uint8_t, char, uint8_t, uint8_t, uint8_t, const uint8_t, const char*)':

C:\Program Files (x86)\Arduino\libraries\FOSSA-Comms\src\FOSSA-Comms.cpp:255:20: error: aggregate 'FCP_Encode(uint8_t, char, uint8_t, uint8_t, uint8_t, const uint8_t, const char*)::AES_ctx ctx' has incomplete type and cannot be defined

 struct AES_ctx ctx;

                ^

C:\Program Files (x86)\Arduino\libraries\FOSSA-Comms\src\FOSSA-Comms.cpp:256:27: error: 'AES_init_ctx' was not declared in this scope

 AES_init_ctx(&ctx, key);

                       ^

C:\Program Files (x86)\Arduino\libraries\FOSSA-Comms\src\FOSSA-Comms.cpp:259:50: error: 'AES_ECB_encrypt' was not declared in this scope

   AES_ECB_encrypt(&ctx, encSection + (i * 16));

                                              ^

Multiple libraries were found for "SPI.h" Used: C:\Program Multiple libraries were found for "SoftwareSerial.h" Used: C:\Program Multiple libraries were found for "FOSSA-Comms.h" Used: C:\Program Multiple libraries were found for "aes.h" Used: C:\Program Multiple libraries were found for "RadioLib.h" Used: C:\Program Using library FOSSA-Comms at version 1.0.0 in folder: C:\Program Files Using library AESLib in folder: C:\Program Files Using library RadioLib at version 1.8.0 in folder: C:\Program Files Using library SPI at version 1.0 in folder: C:\Program Files Using library SoftwareSerial at version 1.0 in folder: C:\Program Files exit status 1 Error compiling for board Arduino/Genuino Uno.

jgromes commented 4 years ago

You seem to have loads of conflicting libraries - including core Arduino libraries like SoftwareSerial and SPI. I suggest you reinstall your Arduino IDE and only install each library once.

Also, which AES library are you using?

kylix34 commented 4 years ago

I got the AES library from here: https://github.com/DavyLandman/AESLib Strange, I searched my HDD for Fossa-Comms.h and it didn't find another copy... Anyway, it's using the libraries from he correct folder.

K4KDR commented 4 years ago

I was getting similar errors (even though library setup 'looked' fine) and can confirm that removing Arduino IDE app + delete "Sketchbook location" folder (which includes /libraries folder) and reinstalling allowed me to compile without errors.

Library installation after IDE reinstall on linux was:

cd ~/Arduino/libraries/
git clone https://github.com/DavyLandman/AESLib.git
git clone https://github.com/jgromes/RadioLib.git
git clone https://github.com/FOSSASystems/FOSSA-Comms.git
git clone https://github.com/FOSSASystems/tiny-AES-c.git

-Scott, K4KDR

kylix34 commented 4 years ago

Thanks Jan/Scott! I'll try on another PC and update this topic.

jgromes commented 4 years ago

@kylix34 I updated this library a few hours ago, to use tiny-AES-c instead of AESLib, since AESLib only works on AVR microcontrollers and some people are using ESP32 boards for their ground stations. You basically have two options:

  1. Using FOSSA-Comms release 1.0.0, which uses AESLib. This will only work on AVR Arduino boards.
  2. Using the latest FOSSA-Comms from the repository, which uses our fork of tiny-AES-c. this will work on almost all platforms.

-Jan

kylix34 commented 4 years ago

It all went smooth once I changed the AES library to tiny-AES-c I have one error in the serial window: Initializing.......failed, code -705. I have to see what this -705 initializing code means

jgromes commented 4 years ago

-705 is ERR_SPI_CMD_TIMEOUT - it means that there was a timeout during SPI communication with the SX126x module. I suggest you check the wiring and module type.

kylix34 commented 4 years ago

I have the DRF1268T module and this shield: https://www.tindie.com/products/dorji_com/sx1268-sx1262-testing-kit-for-arduino-st-nucleo/ It could be that the pins are routed differently than set in the sketch.

PS: I changed the pins in the sketch:

// SX1268 has the following connections: // NSS pin: 7 // DIO1 pin: 5 // DIO2 pin: 4 // BUSY pin: 3 SX1268 radio = new Module(7, 5, 4, 3);

but now I get error code -20 (ERR_WRONG_MODEM) and the second time I try, the code is -707 (ERR_SPI_CMD_FAILED)

kylix34 commented 4 years ago

The pin definitions are correct now but I get those error codes :(

jgromes commented 4 years ago

That could suggest a damaged module. You could try few things:

  1. Remove the while(true); loop that stops further program execution if radio.begin() returns an error. It will force the program to continue despite the error code - not sure what will happen there.
  2. If the shield has NRESET connection, you could try to manually reset the module before radio.begin() using the following code:
pinMode(NRESET, OUTPUT);
digitalWrite(NRESET, LOW);
delayMicroseconds(100);
digitalWrite(NRESET, HIGH);

EDIT: also, I noticed the shield you're using has DIO1 and DIO2 connected to Arduino pins 5 and 4, which do not support external interrupts - because of that, you won't be able to use interrupt-driven reception.

kylix34 commented 4 years ago

I tried option 2 and now I only get error code -707 ... Arghhhhh

jgromes commented 4 years ago

What happens when yo try option 1 - ignoring the error code? Alternatively, you could try with a different module, be it SX127x or SX126x.

-707 is ERR_SPI_CMD_FAILED - anything from -705 to -707 suggests the SPI communication is not working correctly.

kylix34 commented 4 years ago

Hi Jan, I'll try to remove the shield and connect it to Arduino through dupont cables, using the default SPI pins. I think this is the problem, otherwise I'll have to use the software SPI.

Inviato da Yahoo Mail su Android

Il dom, 24 nov, 2019 alle 15:25, Jan Gromešnotifications@github.com ha scritto:
What happens when yo try option 1 - ignoring the error code? Alternatively, you could try with a different module, be it SX127x or SX126x.

-707 is ERR_SPI_CMD_FAILED - anything from -705 to -707 suggests the SPI communication is not working correctly.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or unsubscribe.

kylix34 commented 4 years ago

I removed the shield and connected it through dupont wires, using the correct pins on Arduino. It still doesn't recognize the module. I also tried removing the while (true); statement and I get this: "Transmitting packet ... 0x46 F 0x4F O 0x53 S 0x53 S 0x41 A 0x53 S 0x41 A 0x54 T 0x2D - 0x31 1 0x3  Waiting for response ... " This doesn't mean anything (I'm using the GetSystemInfo sketch)

jgromes commented 4 years ago

I've seen this problem pop up from time to time on one of my SX1268 modules - initially, the module returned -707 but subsequent commands were OK. I still don't know what's causing this, as it's only happening sometimes on one of the modules and only after power cycle. I asked Semtech about it, no response yet.

kylix34 commented 4 years ago

I bought the module from Tindie...I hardly believe it's broken... Would an sx1262 work without issues? It's just I'll miss the satellite launch....because I'll have to buy and wait for the module to arrive.

Inviato da Yahoo Mail su Android

Il dom, 24 nov, 2019 alle 20:02, Jan Gromešnotifications@github.com ha scritto:
I've seen this problem pop up from time to time on one of my SX1268 modules - initially, the module returned -707 but subsequent commands were OK. I still don't know what's causing this, as it's only happening sometimes on one of the modules and only after power cycle. I asked Semtech about it, no response yet.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or unsubscribe.

jgromes commented 4 years ago

I don't think the module is broken completely, it seems to transmit just fine - I think you will be able to use it. You could try running one of RadioLib SX126x examples with debug mode enabled to get some more information about the issue.

The one module that was giving me a similar problem was SX1268 too, but since I don't know what is the actual issue, I can't say if SX1262 will work better. On a side note, resetting a few times or unplugging the Arduino and connecting it back has solved the issue for me.

kylix34 commented 4 years ago

Already tried RadioLib examples and I get the same -707 error. Resetted Arduino tens of times and I didn't get even once to recognize the module. 

Inviato da Yahoo Mail su Android

Il dom, 24 nov, 2019 alle 20:36, Jan Gromešnotifications@github.com ha scritto:
I don't think the module is broken completely, it seems to transmit just fine - I think you will be able to use it. You could try running one of RadioLib SX126x examples with debug mode enabled to get some more information about the issue.

The one module that was giving me a similar problem was SX1268 too, but since I don't know what is the actual issue, I can't say if SX1262 will work better. On a side note, resetting a few times or unplugging the Arduino and connecting it back has solved the issue for me.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or unsubscribe.

jgromes commented 4 years ago

Did you try it in debug mode? Open RadioLib/src/TypeDef.h, uncommentd #define RADIOLIB_DEBUG and #define RADIOLIB_VERBOSE and upload.

This seems to be unrelated to this library. Could you please open a new issue in RadioLib?

kylix34 commented 4 years ago

No, without the debug mode on. I'll try again tomorrow... I'll also try to open an issue on RadioLib github. Thanks a lot for your time!!!!

Inviato da Yahoo Mail su Android

Il dom, 24 nov, 2019 alle 20:46, Jan Gromešnotifications@github.com ha scritto:
Did you try it in debug mode? Open RadioLib/src/TypeDef.h, uncommentd #define RADIOLIB_DEBUG and #define RADIOLIB_VERBOSE and upload.

This seems to be unrelated to this library. Could you please open a new issue in RadioLib?

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or unsubscribe.