-
-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[nightly lib status] Library No Longer working #31
Comments
Sorry about that. I've completely switched all my active development to the rf24-network branch. It includes all changes from the dev branch.So, try
If your program hangs on I've also disabled (commented out) all the
This line won't work with the latest stable release because the wrapper module hasn't been released (yet) |
@jwilts I assume that no further response from you means I can close this issue. (I don't want the issue title to be misleading others passing by) |
Brendan: Unfortunately I am still seeing the problem that the code locks on the line: result = nrf.send(buffer) with nothing ever transmitting across to the receiving side, even using the newest library. I have confirmed that wiring and the modules are good by using the old (non circuit python) library where I am able to get data through. This is what the NRF_details say:
I am open to any suggestions you have on next steps. |
What board are you're running this on (& what OS if any)? If the SPI connections are good, then I am also baffled. Do you know what commit last worked for you? I may have broken something, but everything works fine on all my test setups (excluding rf24mesh module). |
found a local copy of the missing dev branch and re-published it to github. You can use it again via
|
Brendan:
My test bed (at this point) is 2 Pi 4 (4GB) and 1 Pi 3B+
I am running Raspberry PI OS (32 Bit) with desktop released on 2021-05-07
I don’t know what specific branch commit worked for me, unfortunately my test bed blowup earlier this week trashed most of my SD cards so I cant go back and refer to them. (I have an update script that runs on boot and if it is past the 3rd of the month it does a sudo apt full-upgrade on the raspberry OS, and I was pointed at a corrupted mirror) and it took me a bunch of failures to finally figure out what was going on. I initially thought it was a bad PI ☹.
|
Thanks Brendan,
I have to step away for a few hours but will test it as soon as I get back.
I really appreciate all your help with this.
Jeff
|
Brendan:
I have tried using the old dev branch, but still encountering the same issue.
At this point I don’t have a stable image to properly test on and it clearly must be something with my overall software config not the library, so I am going to do a complete re-image of a couple of SD cards starting with an older version of Raspbian-buster-lite and the most minimal config I can do to see if I can get things working on that older version of the OS. I am going to be away from my PC for a week, would you rather I close the ticket for now so that it isn’t hanging out there?
One other thing I should have mentioned is that I am also running Python3. (Although you likely already figured that out)
Jeff
|
I'm patient enough to wait for more than a week (thanks for letting me know). We can keep this ticket open til it is resolved.
I was also thinking it wasn't the library. The dev branch was left in a rather stable state concerning the Minimal setup needed after a fresh install:
|
These are the installation steps I am using. (BTW – thanks for the tip about i2c. I typically enable it, but would have missed that dependency) Let me know if there is anything in here you suggest I change / drop.
1. sudo apt-get install python3-pip
2. cd ~
3. sudo pip3 install --upgrade adafruit-python-shell
4. wget https://raw.githubusercontent.com/adafruit/Raspberry-Pi-Installer-Scripts/master/raspi-blinka.py
5. sudo python3 raspi-blinka.py
6. (REBOOT)
7. sudo pip3 install adafruit-circuitpython-lis3dh
8. mkdir circuit && cd circuit
9. sudo apt-get install python3-venv
10. sudo python3 -m venv .env2
11. source .env2/bin/activate
12. sudo pip3 install ***@***.***
|
Have to run a sudo apt-get update before executing step 1, otherwise I get a whole lot of 404 errors.
|
I modified the instructions a little in my last post (I forgot about rebooting RPi). I think I used your step 4 the first time I ever tried CircuitPython on the RPi (haven't needed to since reading what the script does). Everything else looks fine to me. ps - I like that you're using a virtual env for python projects (I only do that for the RF24 lib's python wrapper). I should really use them more... |
Good Day Brendan:
I finally got back to troubleshooting and have not been able to resolve the problem, but was able to narrow it down a bit.
The following are the exact steps that I went through to do a fresh install and configuration on a pi zero W and a Pi 4 2GB.
*Raspbian lite with no desktop on pi Zero W*
*sudo raspi-config*
*update raspi-config*
*Set wireless LAN to 'CA'*
*Set SSID to 'AAAAAA'*
*Set wifi password 'XXXXXX'*
*Set hostname 'YYYYYY'*
*Interface Options:*
*SSH Enable*
*SPI Enable*
*I2C Enable*
*Set keyboard to US*
*Set Timezone*
*sudo apt-get update*
*sudo apt-get upgrade*
*sudo apt-get install python3-dev python3-pip*
*sudo pip3 install spidev*
*sudo -H pip3 install --upgrade --ignore-installed pip setuptools*
*sudo usermod -a -G spi,gpio pi*
*sudo apt-get install python3-pip*
*cd ~*
*sudo pip3 install --upgrade adafruit-python-shell*
*wget https://raw.githubusercontent.com/adafruit/Raspberry-Pi-Installer-Scripts/master/raspi-blinka.py*
*sudo python3 raspi-blinka.py*
*(REBOOT)*
*sudo pip3 install adafruit-circuitpython-lis3dh*
*mkdir circuit && cd circuit*
*sudo apt-get install python3-venv*
*sudo python3 -m venv .env2*
*source .env2/bin/activate*
*sudo pip3 install circuitpython-nrf24l01*
*sudo pip3 install git+https://github.com/2bndy5/CircuitPython_nRF24L01@rf24-network*
Using the debugger this is the spot in the code where the code infinitely loops:
![image](https://user-images.githubusercontent.com/36136544/126853100-c8241c81-4667-478d-a4d4-65437a7eeadf.png)
These are the errors logged in the debugger if that helps with troubleshooting.
![image](https://user-images.githubusercontent.com/36136544/126853191-2b59ee4c-ff45-428d-abd6-226ec52c152e.png)
![image](https://user-images.githubusercontent.com/36136544/126853196-591481a2-9523-4844-87d9-32cec463df4f.png)
![image](https://user-images.githubusercontent.com/36136544/126853204-0adacc45-dbb3-4bae-affb-c00fa1c363e0.png)
![image](https://user-images.githubusercontent.com/36136544/126853216-8d4b6326-0ed5-47d7-8a37-e16cf338c18a.png)
![image](https://user-images.githubusercontent.com/36136544/126853228-7c1ab2ea-f1a2-4299-bce4-37213bdab90c.png)
![image](https://user-images.githubusercontent.com/36136544/126853233-ac0f9fa8-cba1-4b81-8d85-ee17ca18412a.png)
![image](https://user-images.githubusercontent.com/36136544/126853237-dc6bbf77-d816-4c8b-936d-0422dfdbdc5f.png)
![image](https://user-images.githubusercontent.com/36136544/126853244-6b62b505-3189-4d29-9b32-7cdb0bf591d8.png)
![image](https://user-images.githubusercontent.com/36136544/126853263-fbd19787-3a52-475a-a37c-3ced7ed053bf.png)
I will go through step by step with the debugger with a bit more care on next pass and list out the code lines anywhere that I see errors.
I have confirmed that all the NRF units are good, the wiring is good, SPI is functioning (Using an alternative library)
I am open to any further suggestions you may have for troubleshooting.
Jeff
```python
"""
Simple example of using 1 nRF24L01 to receive data from up to 6 other
transceivers. This technique is called "multiceiver" in the datasheet.
"""
import time
import struct
import board
import digitalio
#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
## Turn on the debugger if the program is being stupid.
import pdb; pdb.set_trace()
#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
# if running this on a ATSAMD21 M0 based board
# from circuitpython_nrf24l01.rf24_lite import RF24
from circuitpython_nrf24l01.rf24 import RF24
# change these (digital output) pins accordingly
ce = digitalio.DigitalInOut(board.D4)
csn = digitalio.DigitalInOut(board.D5)
# using board.SPI() automatically selects the MCU's
# available SPI pins, board.SCK, board.MOSI, board.MISO
spi = board.SPI() # init spi bus object
# we'll be using the dynamic payload size feature (enabled by default)
# initialize the nRF24L01 on the spi bus object
nrf = RF24(spi, csn, ce)
# set the Power Amplifier level to -12 dBm since this test example is
# usually run with nRF24L01 transceivers in close proximity
nrf.pa_level = -12
# setup the addresses for all transmitting nRF24L01 nodes
addresses = [
b"\x78" * 5,
b"\xF1\xB6\xB5\xB4\xB3",
b"\xCD\xB6\xB5\xB4\xB3",
b"\xA3\xB6\xB5\xB4\xB3",
b"\x0F\xB6\xB5\xB4\xB3",
b"\x05\xB6\xB5\xB4\xB3",
]
# uncomment the following 3 lines for compatibility with TMRh20 library
nrf.allow_ask_no_ack = False
nrf.dynamic_payloads = False
nrf.payload_length = 8
# for debugging, we have 2 options that print a large block of details
# radio.printDetails(); # (smaller) function that prints raw register values
#radio.printPrettyDetails(); # (larger) function that prints human readable data
# Show details
nrf.print_details()
def base(timeout=10):
print("Listen")
"""Use the nRF24L01 as a base station for lisening to all nodes"""
# write the addresses to all pipes.
for pipe_n, addr in enumerate(addresses):
nrf.open_rx_pipe(pipe_n, addr)
nrf.listen = True # put base station into RX mode
start_timer = time.monotonic() # start timer
while time.monotonic() - start_timer < timeout:
while not nrf.fifo(False, True): # keep RX FIFO empty for reception
# show the pipe number that received the payload
# NOTE read() clears the pipe number and payload length data
print("Received", nrf.any(), "on pipe", nrf.pipe, end=" ")
node_id, payload_id = struct.unpack("<ii", nrf.read())
print("from node {}. PayloadID: {}".format(node_id, payload_id))
start_timer = time.monotonic() # reset timer with every payload
nrf.listen = False
def node(node_number=0, count=6):
"""start transmitting to the base station.
:param int node_number: the node's identifying index (from the
the `addresses` list)
:param int count: the number of times that the node will transmit
to the base station.
"""
print("Send")
nrf.listen = False
# set the TX address to the address of the base station.
nrf.open_tx_pipe(addresses[node_number])
counter = 0
# use the node_number to identify where the payload came from
while counter < count:
counter += 1
# payloads will include the node_number and a payload ID character
payload = struct.pack("<ii", node_number, counter)
# show something to see it isn't frozen
start_timer = time.monotonic_ns()
print(counter)
report = nrf.send(payload)
end_timer = time.monotonic_ns()
# show something to see it isn't frozen
if report:
print(
"Transmission of payloadID {} as node {} successfull! "
"Transmission time: {} us".format(
counter, node_number, (end_timer - start_timer) / 1000
)
)
else:
print("Transmission failed or timed out")
time.sleep(0.5) # slow down the test for readability
def set_role():
"""Set the role using stdin stream. Node number arg for node() can be
specified using a space delimiter (e.g. 'T 0' calls `node(0)`)
:return:
- True when role is complete & app should continue running.
- False when app should exit
"""
user_input = (
input(
"*** Enter 'R' for receiver role.\n"
"*** Enter 'T' for transmitter role.\n"
"*** Enter 'Q' to quit example.\n"
)
or "?"
)
user_input = user_input.split()
if user_input[0].upper().startswith("R"):
if len(user_input) > 1:
base(int(user_input[1]))
else:
base()
return True
if user_input[0].upper().startswith("T"):
if len(user_input) > 2:
node(int(user_input[1]), int(user_input[2]))
elif len(user_input) > 1:
node(int(user_input[1]))
else:
node()
return True
if user_input[0].upper().startswith("Q"):
nrf.power = False
return False
print(user_input[0], "is an unrecognized input. Please try again.")
return set_role()
print(" nRF24L01 Multiceiver test")
if __name__ == "__main__":
try:
while set_role():
pass # continue example until 'Q' is entered
except KeyboardInterrupt:
print(" Keyboard Interrupt detected. Powering down radio...")
nrf.power = False
else:
print(
" Run base() on the receiver\n "
"Run node(node_number) on a transmitter\n "
"node()'s parameter, `node_number`, must be in range [0, 5]"""
)
```
|
I should have mentioned this before, but using email to post comments on github is not a great approach.
|
Sorry about that - I will post via GitHub going forward. I will repost the last item correctly in a few hours when I get back to my office. (I don’t want to make any extra work for anyone)
Jeff
…Sent from my iPhone
On Jul 23, 2021, at 2:51 PM, Brendan ***@***.***> wrote:
I should have mentioned this before, but using email to post comments on github is not a great approach.
1. After the email's signature, the entire thread is posted as part of the email's history. I have been manually removing them each time you reply from email.
2. Sending attachments seems broken. The last message included no such "word document". In fact, when posting directly through github, it only lets you upload txt files (for security reasons I'm guessing).
3. Using markdown syntax also doesn't seem to be supported when replying from email. I've been manually editing the posted code snippets you include in your replies from email (this didn't work in your last email - probably something to do with the text's encoding).
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2F2bndy5%2FCircuitPython_nRF24L01%2Fissues%2F31%23issuecomment-885834513&data=04%7C01%7C%7C8d7c98672cee4360f74d08d94e0ae531%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637626630965476268%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=%2B6z1joz6gLMqh%2B4qsjGtLq2XuZqics%2FLto9nnRr%2BgNk%3D&reserved=0>, or unsubscribe<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAITWMYDFTYKRA2VULPDOE2TTZG23NANCNFSM47ZZQOKA&data=04%7C01%7C%7C8d7c98672cee4360f74d08d94e0ae531%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637626630965486265%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=C8eCj0%2BWLHR4PZn6nKgGsOet8xT79QdurZvk68%2B2e3Y%3D&reserved=0>.
|
Firstly, I'd like to say that I've never properly used a debugger on the RPi (nor on any circuitpython MCUs for that matter).
The whole purpose of the dev branch (& inherently the rf24-network branch) was to depart from using CirPy API on the RPi. Lately, I've only been using |
I think you're doing too much for no real results here. Stick with:
From the
So, I'm not sure if this |
just to be clear, the newer examples' imports are different than that script you posted. The code you posted doesn't use the spidev package (it uses circuitpython's just in case you didn't notice, this is what the newer imports look like: CircuitPython_nRF24L01/examples/nrf24l01_multiceiver_test.py Lines 12 to 39 in 6013fd7
I know, its wordy as hell, but it will run on MCUs using circuitpython/micropython & RPi using SpiDev/RPi.GPIO. I've been thinking about using a separate module for the newer examples' imports, although I don't want it to seem complicated by requiring 2 files to run a single example. |
Thanks for all the inputs / insights. |
sweet. thanks for the update. BTW I'm playing with some experimental speed-ups on the rf24-network branch. You should stick with the dev branch until I can sort out what helps and what doesn't. I'm trying to get my RF24Mesh to establish a connection consistently with the C++ RF24Mesh master node on the same network tree level... last commit on rf24-network branch helps but seems to break my RF24Mesh on my RPi4. |
This is the pip issue that I am chasing down... Warning not an Error, has been logged when attempting this install line:
and
I get a whole bunch of warnings like
I get no warnings or issues up to this point. (So I think I am getting closer to a clean minimalistic install..) |
I've seen those warnings too, but only when I use more verbose output from pip. |
I just tried to reproduce your problem using the dev branch and nrf24l01_simple_test.py on my RPi2. I should note that I'm using import board
from digitalio import DigitalInOut
from circuitpython_nrf24l01.rf24 import RF24
ce_pin = DigitalInOut(board.D22)
csn_pin = DigitalInOut(board.D8)
spi = board.SPI()
nrf = RF24(spi, csn_pin, ce_pin) which yeilded the following results:
when I use import spidev
from circuitpython_nrf24l01.rf24 import RF24
# import wrappers to imitate circuitPython's DigitalInOut using RPi.GPIO lib
from circuitpython_nrf24l01.wrapper import RPiDIO
ce_pin = RPiDIO(22)
csn_pin = 0 # use CE0 (GPIO8) on default bus
spi = spidev.SpiDev()
nrf = RF24(spi, csn_pin, ce_pin) I get the following results
I could add a raised exception in RuntimeError("tried to get STATUS flags {x > 8000} times. Please check wiring or SPI speed") |
I FINALLY got connectivity working again :-) !!!! Thanks for all your help. I will document all the steps I went through and send over (Although likely not until Thursday) I am using the import board version. |
Brendan: Raspian Lite 32 Bit (No Desktop)
Interesting twist (I don't fully understand) |
@jwilts Thanks for reporting this. It's been a while since I booted up one of my RPi0W boards. This might be something I can fix but I need to reproduce to know what the error message says. I just checked what DigitalInOut uses to control the GPIO pins on the RPi, and it looks like adafruit_blinka uses RPi.GPIO lib by default. So, I can remove the RPiDIO class from the wrapper module. Hopefully, that should avoid future problems. |
Quick update -- (Still investigating) Looks like I declared success a bit too early. On a PiZero I need to use sudo to get the program to run. otherwise I get this error message.
Program works great once it is running. On a Pi 3B the program is still hanging when trying to transmit or receive :-( No error message. I need sudo to even get the program to run. If I run without sudo I get this error message:
I have confirmed with 2 different Pi's, both showing the same behavior. On Pi 4's the test program works without sudo, but if I attempt to run with sudo I get the message:
Program runs great once it is running. I am going to keep investigating. |
I still think you have a bad habit of using
If it says that the FYI: The rf24-network branch seems stable now. I'm just cleaning up the docs for a beta release... |
Why using sudo with pip is bad
(env) pi@rpi2:~/github/CircuitPython_nRF24L01/examples $ sudo pip3 --version
pip 18.1 from /usr/lib/python3/dist-packages/pip (python 3.7)
(env) pi@rpi2:~/github/CircuitPython_nRF24L01/examples $ pip3 --version
pip 21.2.1 from /home/pi/env/lib/python3.7/site-packages/pip (python 3.7)
(env) pi@rpi2:~/github/CircuitPython_nRF24L01/examples $ deactivate
pi@rpi2:~/github/CircuitPython_nRF24L01/examples $ pip3 --version
pip 21.1.3 from /home/pi/.local/lib/python3.7/site-packages/pip (python 3.7) |
@jwilts I added a commit to the dev branch that should help eliminate the possibility that library's DO NOT USE KEYBOARD INTERRUPTS WHILE SPI IS IN USEIf you exit the program unexpectedly, the SPI bus can be left in a unpredictable state. This will require a reboot to fix. |
The commit on the dev branch works beautifully on a Pi3! Does not hang sending or receiving. |
Honestly I don't think it's the commit that helped. All I did was add a if statement to raise an exception (it wasn't meant to "fix" anything, just provide a debug output). You must have installed the library correctly or something... |
closing this. @jwilts Just a heads up, the special commit to the dev branch will not be in the next release because you're problem had to do with improperly installing the lib somehow. |
@jwilts Thought I should let you know that I just released v2.1.0 which includes all updates from the dev branch and the rf24-network branch. You should probably switch to the stable release from pypi
Consequently, I'm removing the dev branch and rf24-network branch from this repo. |
Brendan:
I have been working with your library for the past several months on getting my widegames working and making pretty good progress. But I was working off of a dev branch of your code. (sudo pip3 install git+https://github.com/2bndy5/CircuitPython_nRF24L01@dev)
However that version of the code is no longer available and now I cant get the library working on any new builds.
Any guidance on how to fix the issue would be appreciated.
In the NewLib.py example direct off the CircuitPython website the code runs but never gets past line:
Program just runs without ever transmitting anything and never getting past the line 93. I put a breakpoint before and breakpoint after and I never get to the after breakpoint.
In the OldLib.py example the latest version of the library the following no longer works:
So then code breaks further along. :-(
The oldlib example does a back and forth ping to an arduino that I was using to do some simple concurrency and distance testing. Arduino sends a structure, Pi picks a color and sends back, arduino lights up with correct color.
These are the steps I am using on a brand new install:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install python3-dev python3-pip
sudo pip3 install spidev
python3 -m pip install --upgrade pip setuptools wheel
sudo usermod -a -G spi,gpio pi
sudo apt-get install python3-pip
cd ~
sudo pip3 install --upgrade adafruit-python-shell
wget https://raw.githubusercontent.com/adafruit/Raspberry-Pi-Installer-Scripts/master/raspi-blinka.py
sudo python3 raspi-blinka.py
(REBOOT)
sudo pip3 install adafruit-circuitpython-lis3dh
mkdir circuit && cd circuit
sudo apt-get install python3-venv
sudo python3 -m venv .env
source .env/bin/activate
What I was using previously for all my builds and testing to date
sudo pip3 install git+https://github.com/2bndy5/CircuitPython_nRF24L01@dev
What circuitpython page says to use.
sudo pip3 install circuitpython-nrf24l01
NewLib.txt
OldLib.txt
The text was updated successfully, but these errors were encountered: