arduino-libraries / MKRWAN_v2

[Beta] Library for Arduino MKRWAN 1300 / 1310 suitable for firmwares derived from ST sources
GNU Lesser General Public License v3.0
7 stars 6 forks source link

'SerialLoRa' was not declared in this scope when compiling for Portenta X8 #34

Closed marimelhanafy closed 9 months ago

marimelhanafy commented 9 months ago

When running (MKRWANFWUpdate_standalone.ino), I am getting this error:

WARNING: library MKRWAN_v2 claims to run on samd, mbed architecture(s) and may be incompatible with your current board which runs on mbed_portenta architecture(s).
C:\Users\M\AppData\Local\Temp\.arduinoIDE-unsaved2023818-7392-ond0ck.taup\MKRWANFWUpdate_standalone\MKRWANFWUpdate_standalone.ino: In function 'void setup()':
C:\Users\M\AppData\Local\Temp\.arduinoIDE-unsaved2023818-7392-ond0ck.taup\MKRWANFWUpdate_standalone\MKRWANFWUpdate_standalone.ino:39:18: error: 'SerialLoRa' was not declared in this scope
   port.dev   =  &SerialLoRa;
                  ^~~~~~~~~~
C:\Users\M\AppData\Local\Temp\.arduinoIDE-unsaved2023818-7392-ond0ck.taup\MKRWANFWUpdate_standalone\MKRWANFWUpdate_standalone.ino:39:18: note: suggested alternative: 'SerialFifo'
   port.dev   =  &SerialLoRa;
                  ^~~~~~~~~~
                  SerialFifo
C:\Users\M\AppData\Local\Temp\.arduinoIDE-unsaved2023818-7392-ond0ck.taup\MKRWANFWUpdate_standalone\MKRWANFWUpdate_standalone.ino:45:11: error: 'LORA_BOOT0' was not declared in this scope
   pinMode(LORA_BOOT0, OUTPUT);
           ^~~~~~~~~~
C:\Users\M\AppData\Local\Temp\.arduinoIDE-unsaved2023818-7392-ond0ck.taup\MKRWANFWUpdate_standalone\MKRWANFWUpdate_standalone.ino:45:11: note: suggested alternative: 'LORA_OK'
   pinMode(LORA_BOOT0, OUTPUT);
           ^~~~~~~~~~
           LORA_OK
C:\Users\M\AppData\Local\Temp\.arduinoIDE-unsaved2023818-7392-ond0ck.taup\MKRWANFWUpdate_standalone\MKRWANFWUpdate_standalone.ino:47:11: error: 'LORA_RESET' was not declared in this scope
   pinMode(LORA_RESET, OUTPUT);
           ^~~~~~~~~~
C:\Users\M\AppData\Local\Temp\.arduinoIDE-unsaved2023818-7392-ond0ck.taup\MKRWANFWUpdate_standalone\MKRWANFWUpdate_standalone.ino:47:11: note: suggested alternative: 'LORA_ERROR'
   pinMode(LORA_RESET, OUTPUT);
           ^~~~~~~~~~
           LORA_ERROR
C:\Users\M\AppData\Local\Temp\.arduinoIDE-unsaved2023818-7392-ond0ck.taup\MKRWANFWUpdate_standalone\MKRWANFWUpdate_standalone.ino: In function 'void resetModuleRunning()':
C:\Users\M\AppData\Local\Temp\.arduinoIDE-unsaved2023818-7392-ond0ck.taup\MKRWANFWUpdate_standalone\MKRWANFWUpdate_standalone.ino:270:16: error: 'LORA_BOOT0' was not declared in this scope
   digitalWrite(LORA_BOOT0, LOW);
                ^~~~~~~~~~
C:\Users\M\AppData\Local\Temp\.arduinoIDE-unsaved2023818-7392-ond0ck.taup\MKRWANFWUpdate_standalone\MKRWANFWUpdate_standalone.ino:270:16: note: suggested alternative: 'LORA_OK'
   digitalWrite(LORA_BOOT0, LOW);
                ^~~~~~~~~~
                LORA_OK
C:\Users\M\AppData\Local\Temp\.arduinoIDE-unsaved2023818-7392-ond0ck.taup\MKRWANFWUpdate_standalone\MKRWANFWUpdate_standalone.ino:271:3: error: 'SerialLoRa' was not declared in this scope
   SerialLoRa.end();
   ^~~~~~~~~~
C:\Users\M\AppData\Local\Temp\.arduinoIDE-unsaved2023818-7392-ond0ck.taup\MKRWANFWUpdate_standalone\MKRWANFWUpdate_standalone.ino:271:3: note: suggested alternative: 'SerialFifo'
   SerialLoRa.end();
   ^~~~~~~~~~
   SerialFifo
C:\Users\M\AppData\Local\Temp\.arduinoIDE-unsaved2023818-7392-ond0ck.taup\MKRWANFWUpdate_standalone\MKRWANFWUpdate_standalone.ino:274:16: error: 'LORA_RESET' was not declared in this scope
   digitalWrite(LORA_RESET, HIGH);
                ^~~~~~~~~~
C:\Users\M\AppData\Local\Temp\.arduinoIDE-unsaved2023818-7392-ond0ck.taup\MKRWANFWUpdate_standalone\MKRWANFWUpdate_standalone.ino:274:16: note: suggested alternative: 'LORA_ERROR'
   digitalWrite(LORA_RESET, HIGH);
                ^~~~~~~~~~
                LORA_ERROR
C:\Users\M\AppData\Local\Temp\.arduinoIDE-unsaved2023818-7392-ond0ck.taup\MKRWANFWUpdate_standalone\MKRWANFWUpdate_standalone.ino: In function 'void loop()':
C:\Users\M\AppData\Local\Temp\.arduinoIDE-unsaved2023818-7392-ond0ck.taup\MKRWANFWUpdate_standalone\MKRWANFWUpdate_standalone.ino:286:5: error: 'SerialLoRa' was not declared in this scope
     SerialLoRa.end();
     ^~~~~~~~~~
C:\Users\M\AppData\Local\Temp\.arduinoIDE-unsaved2023818-7392-ond0ck.taup\MKRWANFWUpdate_standalone\MKRWANFWUpdate_standalone.ino:286:5: note: suggested alternative: 'SerialFifo'
     SerialLoRa.end();
     ^~~~~~~~~~
     SerialFifo

exit status 1

Compilation error: 'SerialLoRa' was not declared in this scope
cturvey commented 9 months ago

This board? https://store-usa.arduino.cc/products/arduino-portenta-vision-shield-lora%C2%AE?selectedStore=us

This isn't really the MKR WAN 13xx series boards this code targets

You'd need to define SerialLoRa (Serial Instance), LORA_BOOT0 (GPIO Pin designation), LORA_RESET to platform appropriate values.

https://github.com/arduino-libraries/MKRWAN/blob/master/src/MKRWAN.h#L26

marimelhanafy commented 9 months ago

This board? https://store-usa.arduino.cc/products/arduino-portenta-vision-shield-lora%C2%AE?selectedStore=us

This isn't really the MKR WAN 13xx series boards this code targets

You'd need to define SerialLoRa (Serial Instance), LORA_BOOT0 (GPIO Pin designation), LORA_RESET to platform appropriate values.

https://github.com/arduino-libraries/MKRWAN/blob/master/src/MKRWAN.h#L26

I have a testbed that consists of 4 ESP-WROOM-32 units, each connected to different kinds of sensors. I want to send the data from all of them to the Portenta X8 simultaneously. I have also connected the Portenta X8 with the Portenta Max Carrier, which is already has the LoRaWAN Module. I have already completed the ESPs part, as I connected all of them to the WiFi and sent the data using the TCP protocol. I used these headers (#include / #include / #include ). My question is: how should I receive the data on the Portenta X8? I searched but did not find any related header for it. So, could you please let me know what the possible solutions are for this? I followed this tutorial (https://docs.arduino.cc/tutorials/portenta-max-carrier/connecting-to-ttn) and I got the error that I posted.

cturvey commented 9 months ago

Seems odd you'd get the other errors if PORTENTA_CARRIER was defined. And where do you define SerialLoRa ? Presumably to Serial1 if that's what it is attached too.

#define SerialLoRa  Serial1
#define PORTENTA_CARRIER
#include <MKRWAN.h>
marimelhanafy commented 9 months ago

First, I tried using #include <MKRWAN.h> and #include <MKRWAN_v2.h>, but both are giving the same error.

Now I am using #include <MKRWAN_v2.h> and I have putted what you mentioned (#define SerialLoRa Serial1), but the error now as the following:

WARNING: library MKRWAN_v2 claims to run on samd, mbed architecture(s) and may be incompatible with your current board which runs on mbed_portenta architecture(s).
In file included from C:\Users\Marim\Documents\MKRWANFWUpdate_standalone\MKRWANFWUpdate_standalone.ino:20:0:
c:\Users\Marim\Documents\Arduino\libraries\MKRWAN_v2\src/MKRWAN_v2.h: In member function 'bool LoRaModem::begin(_lora_band)':
c:\Users\Marim\Documents\Arduino\libraries\MKRWAN_v2\src/MKRWAN_v2.h:429:13: error: 'LORA_BOOT0' was not declared in this scope
     pinMode(LORA_BOOT0, OUTPUT);
             ^~~~~~~~~~
c:\Users\Marim\Documents\Arduino\libraries\MKRWAN_v2\src/MKRWAN_v2.h:429:13: note: suggested alternative: 'LORA_OK'
     pinMode(LORA_BOOT0, OUTPUT);
             ^~~~~~~~~~
             LORA_OK
c:\Users\Marim\Documents\Arduino\libraries\MKRWAN_v2\src/MKRWAN_v2.h:431:13: error: 'LORA_RESET' was not declared in this scope
     pinMode(LORA_RESET, OUTPUT);
             ^~~~~~~~~~
c:\Users\Marim\Documents\Arduino\libraries\MKRWAN_v2\src/MKRWAN_v2.h:431:13: note: suggested alternative: 'LORA_ERROR'
     pinMode(LORA_RESET, OUTPUT);
             ^~~~~~~~~~
             LORA_ERROR
C:\Users\Marim\Documents\MKRWANFWUpdate_standalone\MKRWANFWUpdate_standalone.ino: In function 'void setup()':
C:\Users\Marim\Documents\MKRWANFWUpdate_standalone\MKRWANFWUpdate_standalone.ino:47:11: error: 'LORA_BOOT0' was not declared in this scope
   pinMode(LORA_BOOT0, OUTPUT);
           ^~~~~~~~~~
C:\Users\Marim\Documents\MKRWANFWUpdate_standalone\MKRWANFWUpdate_standalone.ino:47:11: note: suggested alternative: 'LORA_OK'
   pinMode(LORA_BOOT0, OUTPUT);
           ^~~~~~~~~~
           LORA_OK
C:\Users\Marim\Documents\MKRWANFWUpdate_standalone\MKRWANFWUpdate_standalone.ino:49:11: error: 'LORA_RESET' was not declared in this scope
   pinMode(LORA_RESET, OUTPUT);
           ^~~~~~~~~~
C:\Users\Marim\Documents\MKRWANFWUpdate_standalone\MKRWANFWUpdate_standalone.ino:49:11: note: suggested alternative: 'LORA_ERROR'
   pinMode(LORA_RESET, OUTPUT);
           ^~~~~~~~~~
           LORA_ERROR
C:\Users\Marim\Documents\MKRWANFWUpdate_standalone\MKRWANFWUpdate_standalone.ino: In function 'void resetModuleRunning()':
C:\Users\Marim\Documents\MKRWANFWUpdate_standalone\MKRWANFWUpdate_standalone.ino:272:16: error: 'LORA_BOOT0' was not declared in this scope
   digitalWrite(LORA_BOOT0, LOW);
                ^~~~~~~~~~
C:\Users\Marim\Documents\MKRWANFWUpdate_standalone\MKRWANFWUpdate_standalone.ino:272:16: note: suggested alternative: 'LORA_OK'
   digitalWrite(LORA_BOOT0, LOW);
                ^~~~~~~~~~
                LORA_OK
C:\Users\Marim\Documents\MKRWANFWUpdate_standalone\MKRWANFWUpdate_standalone.ino:276:16: error: 'LORA_RESET' was not declared in this scope
   digitalWrite(LORA_RESET, HIGH);
                ^~~~~~~~~~
C:\Users\Marim\Documents\MKRWANFWUpdate_standalone\MKRWANFWUpdate_standalone.ino:276:16: note: suggested alternative: 'LORA_ERROR'
   digitalWrite(LORA_RESET, HIGH);
                ^~~~~~~~~~
                LORA_ERROR

exit status 1

Compilation error: 'LORA_BOOT0' was not declared in this scope

I have noticed that "'SerialLoRa' was not declared in this scope" is not there any more.

marimelhanafy commented 9 months ago

@facchinm @per1234 @cturvey @dcuartielles @pillo79, I am in need of help here. Could you please assist me? The code is not working at all. Is there another header missing for Portenta X8? Thanks in advance.

cturvey commented 9 months ago

Not a board I'm using, you'll need to debug/diagnose why the compiler isn't pulling in the definitions. The pins physically called out here https://github.com/arduino-libraries/MKRWAN/blob/master/src/MKRWAN.h#L26 for the PORTENTA_CARRIER build. So either it's not being passed to the compiler via the make or build process, or what it's defining isn't correct ,ie PD_5 Perhaps you can have the build generate the intermediate pre-processor output, and inspect that to understand why these things aren't defined suitably for your board. Double check you're using the source matching that in the repository. Perhaps you have someone on your team who can assist you more directly?

marimelhanafy commented 9 months ago

Not a board I'm using, you'll need to debug/diagnose why the compiler isn't pulling in the definitions. The pins physically called out here https://github.com/arduino-libraries/MKRWAN/blob/master/src/MKRWAN.h#L26 for the PORTENTA_CARRIER build. So either it's not being passed to the compiler via the make or build process, or what it's defining isn't correct ,ie PD_5 Perhaps you can have the build generate the intermediate pre-processor output, and inspect that to understand why these things aren't defined suitably for your board. Double check you're using the source matching that in the repository. Perhaps you have someone on your team who can assist you more directly?

I am the only one working on this part in my team, but thank you so much for replying. I will check your three notes or comments (1. either it's not being passed to the compiler via the make or build process, or what it's defining isn't correct, i.e., PD_5. / 2. Perhaps you can have the build generate the intermediate pre-processor output, and inspect that to understand why these things aren't defined suitably for your board. / 3. Ensure that the source you're using matches the one in the repository.) and comment back. Thank you.

facchinm commented 9 months ago

Hi everyone, the Portenta X8 is quite a different beast compared to the microcontroller based ones; we don't have any ready made library to talk with the Lora module, so you'll need to follow some Linux-fu:

@jcarolinares @manchoz do you happen to have any python example for the X8+Max+Lora combination?

marimelhanafy commented 9 months ago

Hi everyone, the Portenta X8 is quite a different beast compared to the microcontroller based ones; we don't have any ready made library to talk with the Lora module, so you'll need to follow some Linux-fu:

  • ensure /dev/ttymxc3 is present (Max carrier should get automatically recognized and add the proper device tree overlay at boot)
  • launch a docker container where we'll be able to install some utilities docker run -it --device /dev/ttymxc3:/dev/ttymxc3 --privileged debian:11-slim
  • you can now install an utility to talk with the serial port (eg. microcom) and interact with the module ( microcom -p /dev/ttymxc3 -s 19200 )

@jcarolinares @manchoz do you happen to have any python example for the X8+Max+Lora combination?

Thank you so much for your response. I will try out the solution you suggested. Additionally, I wanted to inquire if there's an alternative solution that would allow me to receive data directly from the Wi-Fi using the TCP protocol. I attempted to do this by uploading the code from Arduino IDE, but I couldn't find any header files for the Portenta X8.

As I mentioned before that I have a testbed that consists of 4 ESP-WROOM-32 units, each connected to different kinds of sensors. I want to send the data from all of them to the Portenta X8 simultaneously. I have already completed the ESPs part, as I connected all of them to the WiFi and sent the data using the TCP protocol. I used these headers (#include <WiFi.h> / #include <AsyncTCP.h> / #include <ESPAsyncWebSrv.h>). Now, my question is: how should I receive the data on the Portenta X8? I searched but did not find any related header for it. So, could you please let me know what the possible solutions are for this?

manchoz commented 9 months ago

Yes, please see https://github.com/arduino/portenta-containers/tree/release/lora-node-x8

marimelhanafy commented 9 months ago

Yes, please see https://github.com/arduino/portenta-containers/tree/release/lora-node-x8

I tried to clone this repository but encountered an error message. Could you please assist me with this issue? Capture1

manchoz commented 9 months ago

@marimelhanafy is your connection working? Can you ping, resolve hosts, etc.

Please consider also cloning the repo on your PC and copying only the lora-node-x8 folder on the X8 using the adb push command.

[PC]$ git clone https://github.com/arduino/portenta-containers.git
[PC]$ adb push portenta-containers/lora-node-x8 /var/rootdirs/home/fio/
[PC]$ adb shell
[X8]$ cd lora-node-x8
[X8]$ newgrp - docker
[X8]$ docker build -t lora-node-x8 .
[X8]$ sed -i 's#hub.foundries.io/${FACTORY}/##g' docker-compose.yml
[X8]$ docker compose up

EDIT: fixed typo in build command

marimelhanafy commented 9 months ago

@marimelhanafy is your connection working? Can you ping, resolve hosts, etc.

Please consider also cloning the repo on your PC and copying only the lora-node-x8 folder on the X8 using the adb push command.

[PC]$ git clone https://github.com/arduino/portenta-containers.git
[PC]$ adb push portenta-containers/lora-node-x8 /var/rootdirs/home/fio/
[PC]$ adb shell
[X8]$ cd lora-node-x8
[X8]$ newgrp - docker
[X8]$ docker build compile -t lora-node-x8 .
[X8]$ sed -i 's#hub.foundries.io/${FACTORY}/##g' docker-compose.yml
[X8]$ docker compose up

Thank you for providing the steps, but in ([X8]$ docker build compile -t lora-node-x8 .) , I got an error message. image

manchoz commented 9 months ago

@marimelhanafy, the commands that starts with [X8]$ must be run on the X8 after connecting to it with adb shell.

Also, I made a typo, the correct build command is:

[X8]$ docker build -t lora-node-x8 .

marimelhanafy commented 9 months ago

@marimelhanafy, the commands that starts with [X8]$ must be run on the X8 after connecting to it with adb shell.

Also, I made a typo, the correct build command is:

[X8]$ docker build -t lora-node-x8 .

I double checked and I ran the commands on X8 after doing adb shell. Also, I tried to make it run and it ran, but I encountered a different error. image

manchoz commented 9 months ago

@marimelhanafy, you are definitely having issues with your connectivity. Is there any firewall on your network?

Please solve them and then open a ticket by writing an email to pro@arduino.cc if you still need help.

marimelhanafy commented 9 months ago

Is there any firewall on your network?

I think yes, there might be a firewall in the network as it is not my private network. I will check this issue further. Thank you so much for your assistance and time and my apologies for any inconvenience caused.

marimelhanafy commented 9 months ago
sed -i 's#hub.foundries.io/${FACTORY}/##g' docker-compose.yml

I have now resolved the network issue. However, I am getting an error with the step [X8]$ sed -i 's#hub.foundries.io/${FACTORY}/##g' docker-compose.yml. Could you please assist?: image

manchoz commented 9 months ago

@marimelhanafy, you are launching the command from the wrong directory. You can alternatively launch either of the following commands:

[X8]$ cd lora-node-x8
[X8]$ sed -i 's#hub.foundries.io/${FACTORY}/##g' docker-compose.yml

or

[X8]$ sed -i 's#hub.foundries.io/${FACTORY}/##g' lora-node-x8/docker-compose.yml

@marimelhanafy I think getting familiar with the Linux command line would be a good idea before proceeding further. Here are a couple of links that you might find helpful:

marimelhanafy commented 9 months ago

@marimelhanafy, you are launching the command from the wrong directory. You can alternatively launch either of the following commands:

[X8]$ cd lora-node-x8
[X8]$ sed -i 's#hub.foundries.io/${FACTORY}/##g' docker-compose.yml

or

[X8]$ sed -i 's#hub.foundries.io/${FACTORY}/##g' lora-node-x8/docker-compose.yml

@marimelhanafy I think getting familiar with the Linux command line would be a good idea before proceeding further. Here are a couple of links that you might find helpful:

I am quite familiar with Linux and OS, but perhaps I wasn't focused and missed it, sorry for that, but thank you so much for your assistance; everything is working now. My question now related to the Portenta X8+Max Carrier+LoRa combination. I'm trying to follow this tutorial (https://docs.arduino.cc/tutorials/portenta-max-carrier/connecting-to-ttn), but I'm unsure how to link what we've done so far to the steps in this tutorial. Could you clarify at which step I should start?

manchoz commented 9 months ago

@marimelhanafy, the tutorial you are referring to is dedicated to the H7. Unfortunately, we don't have a tutorial for LoRa and X8 at this moment, but you will definitely be able to run LoRaWAN on the X8 following the custom container tutorial available at Deploy a Custom Container with Portenta X8 Manager and using the container at portenta-containers/lora-node-x8.

Since your issue is unrelated to a problem with the MKRWAN_v2 library, please open a ticket at pro@arduino.cc for further support.

@facchinm, please close the issue.

marimelhanafy commented 9 months ago

@marimelhanafy, the tutorial you are referring to is dedicated to the H7. Unfortunately, we don't have a tutorial for LoRa and X8 at this moment, but you will definitely be able to run LoRaWAN on the X8 following the custom container tutorial available at Deploy a Custom Container with Portenta X8 Manager and using the container at portenta-containers/lora-node-x8.

Since your issue is unrelated to a problem with the MKRWAN_v2 library, please open a ticket at pro@arduino.cc for further support.

@facchinm, please close the issue.

I learned a lot from you and I will try that option. Thank you so much.

marimelhanafy commented 9 months ago

@manchoz I apologize for reopening the issue. Using (https://github.com/arduino/portenta-containers/tree/release/lora-node-x8), I have successfully obtained the Device EUI of the Portenta X8 using these steps, which I am happy to share for everyone's benefit:

# Open adb shell
> adb shell

# Run docker image in detached mode (runs in another process in the background)
> sudo docker compose up -d

# Get docker container id of loranode image
# This will display all container ids, copy the id of lora node container
> sudo docker ps

# Bash into the running container
> sudo docker exec -it {continer_id} sh

# now you are inside the lora server
# now run the lora node python script
> python lora-node.py deviceinfo

The results are as follows: image

The Device EUI is used in the tutorial I previously mentioned (https://docs.arduino.cc/tutorials/portenta-max-carrier/connecting-to-ttn). Now, I'm at step 4 (Sending Data to an Application in TTN). However, I'm encountering the same main issue: the #include header is not compatible with Portenta X8. Could you advise on how I can modify it to work correctly with X8?

per1234 commented 9 months ago

Hi @marimelhanafy. This library and the MKRWAN library do not support the Portenta X8; only the Portenta H7 so the error messages you encountered are expected.