0

excamera SPI API problems
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

excamera SPI API problems

by keli on Sat Sep 14, 2019 10:15 pm

I'm trying to use Python 2.7 to talk to a "SPI to 4 channel USART bridge". The API uses simple text commands. Between the Raspberry Pi 4 (running Raspbian) and the "SPI2UART" is a SPIDriver from excamera. The problem is that the version of Python that works with the SPIDriver API commands works with Python 2.7.16; or did at first. When I type in the command " >>> from spidriver import SPIDriver" in Python 3.7.3 I get "ImportError: cannot find import name SPIDriver". When I first started trying to fix the problem that command worked from 2.7.16, but not 3.7.3.. In trying to fix the problem I did some thing that toasted 2.7.16. What I really want to do is not use Python (v2.7), but IDLE (using Python-2.7):

from spidriver import SPIDriver # crashes here
s.sel()
s.write([0x9f])
......

I want to write experimental code to test out my new bridge into a file that I can run and experiment with. I could at first use Python (v2.7) to do that line by line (>>>), but not 3.7. So in the process of getting IDLE (using Python-2.7) working it modified everything so the "from spidriver..." Does not work from any version of Python now. K

Any ideas on how to get working "from spidriver..." with either Python 3 (IDLE), or IDLE (using Python-2.7). Python (v2.7) worked but then I messed it up trying to get an IDLE working. K

keli
 
Posts: 50
Joined: Mon Jul 07, 2008 9:53 am

Re: excamera SPI API problems

by keli on Wed Sep 18, 2019 1:31 am

Fixed my own problem. Have a spare pi 3 with a HD installed. Installed "Raspbian GNU/Linux 10 (buster)" with NOOBS. Then:
1. "pip install spidriver"
2. "sudo apt-get install idle"
3. "sudo apt-get install idle-python2.7"
4. In the "Main Menu Editor" select "IDLE (using Python-2.7)"
5. reboot
Remember I am doing this because the spi API WON'T work with Python 3.7, will with Python 2.7. In 3.7 I get an error saying it can't find the "SPIDriver" and errors out ( "from spidriver import SPIDriver"). I also need to be able to run a program, not just code line by line, so I need IDEL 2.7. I think in trying to get IDEL 2.7 installed I managed to only get the 3.7 framework installed for every thing, so nothing worked even IDLE 2.7. So starting from scratch and reinstalling every thing solved the error. Keli

keli
 
Posts: 50
Joined: Mon Jul 07, 2008 9:53 am

Re: excamera SPI API problems

by keli on Sat Sep 21, 2019 12:03 pm

Result of finally being able to use Python 2.7 IDEL with the excamera SP I API. Keli
Attachments
IMG_20190921_085044.jpg
IMG_20190921_085044.jpg (412.54 KiB) Viewed 79 times

keli
 
Posts: 50
Joined: Mon Jul 07, 2008 9:53 am

Re: excamera SPI API problems

by keli on Sat Sep 21, 2019 12:11 pm

What the result looks like to the to the SPIdriver and the SPI2UART with the SPI API working. Keli
Attachments
IMG_20190921_085926.jpg
IMG_20190921_085926.jpg (687.38 KiB) Viewed 78 times

keli
 
Posts: 50
Joined: Mon Jul 07, 2008 9:53 am

Please be positive and constructive with your questions and comments.