- Benefits of multiple membrane sweeps
- How to index multiple values with Search API?
- Resolve CORS issue without changing services.yml file
- Translatable strings not appearing in the translation interface
- How long is considered `long-term'?
- Generating Brainf*** NOPs
- Can Random String Generation be faster in Java?
- Notification system same code running twice, simplify it
- Array Interlacing
- Remove unwanted characters from a string
- Fancy padding of wide strings
- When did the first back-in-time Time-Traveling Robot appear in literature?
- Are there any other mages (beyond Raistlin) known for being able to “cheat” on the Test of High Sorcery?
- Short story about a space salvage tug called the Dido, which salvages a passenger ship
- Is there any significant meaning behind the term “Saruman of Many Colours”?
- Does Lovecraft's The Colour Out of Space reference the concept of radioactivity?
- Anime about a boy with powers engraved on his back, monsters turn into crystals when dead
- Why didn’t Darth Vader’s body disappear in Return of the Jedi?
- SQL error object
- unpivot 2 coloum into one cloumn sql server table
Why is python3 stopping without an error message durring a spidev xfer2 call?
I am having a problem with a python3 script where xfer2() from spidev fails with no warning or error message.
I am using Raspbian 8.0
I am trying to use the spi bus to talk to an MCP3008
When I do an ls /dev I see the spidev0.0 and spidev0.1 drivers so spi is enabled.
I have tried several different versions of the python wrapper for spidev.
The following code is simplified/minimized to just show the problem:
print('Starting test code')
print('initializing the spi bus instance')
spi_bus = spidev.SpiDev()
print('opening the spi bus')
print('getting the adc output ')
adc_output = spi_bus.xfer2(1, 240, 0 )
# The program never gets to the following print statement.
# Instead it just exits and returns to the prompt with no error statement
print('adc read complete')
This is what I get when I run the python script:
pi@raspberrypi: ~ software $sudo python3 spi_testcode.py
starting test code
initializing the s
I have run your code on both a Pi2B and a Pi3B. On both I get a segmentation fault with spidev. I don't know why. I'm not sure where I sourced those versions from (they may be part of the raspberrypi.org image at the moment).
Just checked, part of the raspberrypi.org image.
apt-cache policy python-spidev
*** 2.0~git20150907 0
500 http://archive.raspberrypi.org/debian/ jessie/main armhf Packages
I suggest you raise an issue (not sure where).
My pigpio Python module has an alternative SPI implementation (spi_open, spi_xfer, spi_close).
From the command line
$ sudo pigpiod
$ pigs spio 1 1000000 256 # my MCP3008 is on channel 1 of auxiliary SPI
0 # returns handle 0
$ pigs spix 0 1 240 0 # I don't have anything connected to channel 7
3 0 0 51
$ pigs spix 0 1 240 0
3 0 0 210
$ pigs spix 0 1 240 0
3 0 0 225
$ pigs spix 02018-04-15 00:52:19
With some help of Clem over at Element14 and a hint from joan here I solved the problem.
My code was passing 3 decimal bytes without brackets:
I discovered I needed to add brackets. The following seems to work:
So.... xfer2() is looking for a list but I was passing 3 separate variables.
Now the embarrassing thing: The code examples on the web that I was following had the brackets!! I had visually compared my code to the examples several times but never noticed that difference..... :-(.
I caused the problem but it is too bad the spidev code did not flag the error better
Problem solved.... now I am able to move forward with the build.
can you post your entire code?2018-04-15 01:57:38