chandrawi / LoRaRF-Python

Python library for basic transmitting and receiving data using LoRa and FSK modem
MIT License
29 stars 15 forks source link

Dependency and pip version problem #20

Open rainerfritz opened 7 months ago

rainerfritz commented 7 months ago

Hi!

I try to get the library running on an RPi 3b+ with the 64bit OS headless. The board I am using is the waveshare board with SX1262 via SPI and GPS via serial.

When I compare the version if install directly LoRa RF via pip3 install LoRaRF, the base.py file seems not uptodate as it misses the classes LoraSPI and LoraGpio. So i am going with the version here from github, manual install in an venv.

I do the following: -create virtual env for python python -m venv lora

--activate if not already source lora/bin/activate

--get the LoRa Repo from git - pip is not actual

cd lora
git clone https://github.com/chandrawi/LoRaRF-Python.git

--install dependencies

pip3 install wheel
pip3 install spidev
pip3 install gpiod

--install LoRaRF

cd LoRaRF-Python
python3 setup.py bdist_wheel
pip3 install dist/LoRaRF-1.4.0-py3-none-any.whl

--try to call the receiver example: python3 examples/SX126x/receiver.py

Gives the Error:

Begin LoRa radio
Traceback (most recent call last):
  File "/home/rainer/lora/LoRaRF-Python/examples/SX126x/receiver.py", line 15, in <module>
    if not LoRa.begin() :
           ^^^^^^^^^^^^
  File "/home/rainer/lora/lib/python3.11/site-packages/LoRaRF/SX126x.py", line 293, in begin
    self.reset()
  File "/home/rainer/lora/lib/python3.11/site-packages/LoRaRF/SX126x.py", line 310, in reset
    self._reset.output(LoRaGpio.LOW)
  File "/home/rainer/lora/lib/python3.11/site-packages/LoRaRF/base.py", line 36, in output
    chip = gpiod.Chip(self.chip)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/rainer/lora/lib/python3.11/site-packages/gpiod/chip.py", line 58, in __init__
    self._chip = _ext.Chip(path)
             ^^^^^^^^^^^^^^^

FileNotFoundError: [Errno 2] No such file or directory

Can it be, that the actual gpiod version 2.1.3 does not work with the code currently?

I changed then in the chip.py the line self._chip = _ext.Chip(path)to self._chip = _ext.Chip("/dev/gpiochip0")which seems to work, but then the chip object complains:

Begin LoRa radio
Traceback (most recent call last):
  File "/home/rainer/lora/LoRaRF-Python/examples/SX126x/receiver.py", line 15, in <module>
    if not LoRa.begin() :
           ^^^^^^^^^^^^
  File "/home/rainer/lora/lib/python3.11/site-packages/LoRaRF/SX126x.py", line 293, in begin
    self.reset()
  File "/home/rainer/lora/lib/python3.11/site-packages/LoRaRF/SX126x.py", line 310, in reset
    self._reset.output(LoRaGpio.LOW)
  File "/home/rainer/lora/lib/python3.11/site-packages/LoRaRF/base.py", line 38, in output
    line = chip.get_line(self.offset)
           ^^^^^^^^^^^^^
AttributeError: 'Chip' object has no attribute 'get_line'. Did you mean: 'get_info'?

Any help to get it running would be awesome. THX, Rainer

JulianGa05 commented 6 months ago

Hello Rainer,

I am currently facing the same issue. Have you managed to fix it yet?

Best regards Julian

Edit: I fixed it with the solution described in issue#19

rainerfritz commented 6 months ago

I try to get the waveshare lora hat running with SX1262 and gps. Took me a little bit to find the right documentation. They provide a LoRaRF version, which works out of the box. I had no time so far to have a look where they modified it. If you want to have a look in the meanwhile here is the link. Scroll down to the bottom of the page: waveshare lorarf library

JulianGa05 commented 6 months ago

Wow, how could I have not found that earlier? Thank you for that! I was always just relayed to a different product page that had only useless demo code. To be honest though, I am still not able to make it work. I've tried to use the transmitter.py example and at first I got an error with the call to SX126x() and after I fixed that I got an error during the LoRa.begin(). Have you encountered similar issues?

Am So., 14. Jan. 2024 um 16:38 Uhr schrieb Rainer Fritz < @.***>:

I try to get the waveshare lora hat running with SX1262 and gps. Took me a little bit to find the right documentation. They provide a LoRaRF version, which works out of the box. I had no time so far to have a look where they modified it. If you want to have a look in the meanwhile here is the link. Scroll down to the bottom of the page: waveshare lorarf library https://www.waveshare.com/wiki/SX1262_XXXM_LoRaWAN/GNSS_HAT

— Reply to this email directly, view it on GitHub https://github.com/chandrawi/LoRaRF-Python/issues/20#issuecomment-1890985734, or unsubscribe https://github.com/notifications/unsubscribe-auth/BDYPCLTIJJGSOZPJIAX7HGLYOP3XHAVCNFSM6AAAAABAOW2IBWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOJQHE4DKNZTGQ . You are receiving this because you commented.Message ID: @.***>

rainerfritz commented 6 months ago

Before you test it with that library, make sure you uninstall from your primary python environment the lorarf package. Thats how I did it:

JulianGa05 commented 6 months ago

That was it, I still had the old installation, thank you so much!! Now it works!

Am Di., 16. Jan. 2024 um 15:19 Uhr schrieb Rainer Fritz < @.***>:

Before you test it with that library, make sure you uninstall from your primary python environment the lorarf package. Thats how I did it:

  • generate a virtual python environment
  • activate it and cd into it
  • copy the whole library into the venv directory
  • pip install ./sx126x_lorawan_hat_code/python/lora But it worked also without installing it on my side

— Reply to this email directly, view it on GitHub https://github.com/chandrawi/LoRaRF-Python/issues/20#issuecomment-1893840023, or unsubscribe https://github.com/notifications/unsubscribe-auth/BDYPCLXYW3IOSC6DAFFIOWTYO2EA3AVCNFSM6AAAAABAOW2IBWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOJTHA2DAMBSGM . You are receiving this because you commented.Message ID: @.***>