- What is the true pinyin pronunciation for this radical?
- What film has more logos at the beginning than any other?
- Who shot Lester Burnham in “American Beauty” (1999)?
- Why Goliath is named so?
- How can I get the key of blockindex
- How does the existence of the Tomb of the Blessed Virgin Mary fit with the Assumption of Mary?
- Training the model for human activity recognition using optical flow
- prove PRG is secure assuming DDH holds
- Discrete Log with regard to a random base
- Where to propagate my fiddle-leaf fig?
- Are there online stores that specialize in selling plants in pots that bear fruit?
- How to build up clear ideas
- What does “chotim” mean?
- How to play upbeat theme park music?
- What if musical piece not ended with tonic chord?
- A tuners accuracy is +/- 0.5 cents means that it is highly accurate or just decently accurate?
- Sorry, we couldn't
error when opening office documents in the client
- I have a 2015 Kia Forte I have put two Alternators on it within the last 2 weeks why do they keep failing?
- Another car hit my car, impact was mostly to front wheel and fender
- Scrum of Scrum of Scrums
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