Cannot find SPI device - raspberry-pi

I am using Raspberry Pi Zero W with a PiTFT. I have managed to put an image on the screen as explained here: https://learn.adafruit.com/adafruit-pitft-28-inch-resistive-touchscreen-display-raspberry-pi
After that, I've tried to use the Adafruit Python ILI9341 as explained here: https://github.com/adafruit/Adafruit_Python_ILI9341
There is no problem at the instalation, BUT when I've tried to execute an example it said:
Traceback (most recent call last):
File "image.py", line 41, in <module>
disp = TFT.ILI9341(DC, rst=RST, spi=SPI.SpiDev(SPI_PORT,
SPI_DEVICE, max_speed_hz=64000000))
File "build/bdist.linux-armv6l/egg/Adafruit_GPIO/SPI.py", line 42,
in __init__
IOError: [Errno 2] No such file or directory
The tree hierarchy is missing starting with the 'egg' folder.
I've tried to manually create it, but I got the same error.
My instincts were that there is a problem with the SPI connection or the spidev kernel module.
There is no spi device in the /dev/ directory.
In the /boot/config.txt the spi is on, I've enabled it in the raspi-config menu. I've also checked and it is not even blacklisted.
I am using a pi image, not a PiTFT image.
Please HELP!

Related

Adafruit minimqtt on Pi Pico H with Wiznet RP2040 ethernet hat "RuntimeError: Failed to establish connection."

I'm trying to use the adafruit minimqtt library on a Pi Pico H, running circuitpython. I've been following this guide
I'm using a mosquito broker on my windows 10 laptop and connecting directly through an ethernet cable to the Wiznet hat, as in the tutorial. The code I'm using is copied directly from the example with the following changes:
changed the IP address on line 22 to that of my windows machine
uncommneted lines 68 and 70, and commented out line 73 to avoid using DHCP (someone else on the github has noted that the dhcp doesn't work). Also deleted the extra space in line 70
I get the following error:
Traceback (most recent call last):
File "<stdin>", line 84, in <module>
File "/lib/adafruit_minimqtt/adafruit_minimqtt.py", line 441, in connect
File "/lib/adafruit_minimqtt/adafruit_minimqtt.py", line 266, in _get_connect_socket
File "/lib/adafruit_wiznet5k/adafruit_wiznet5k_socket.py", line 246, in connect
File "/lib/adafruit_wiznet5k/adafruit_wiznet5k.py", line 570, in socket_connect
RuntimeError: Failed to establish connection.
I've looked through each of the scripts referenced and can't find any obvious errors (I'm not an expert in this so there might be something I've missed). I can't find anyone who's experienced this same error code, any help here would be appreciated.
I've tried running the first half of the code (up to line 68), and then pinging the pico from my laptop. I've also pinged my laptop from the board. Both were successful, so I don't think it's a hardware issue.
I've double checked that my broker is not in local mode. My .conf file contains
listener 1883
allow_anonymous true
and when I run mosquitto I get
C:\Users\me1xmtx\mosquitto>mosquitto -c rem.conf -v
1676306316: mosquitto version 2.0.15 starting
1676306316: Config loaded from rem.conf.
1676306316: Opening ipv6 listen socket on port 1883.
1676306316: Opening ipv4 listen socket on port 1883.
1676306316: mosquitto version 2.0.15 running
TCP (and UDP just in case) ports 1883 are open on the windows laptop

Using Beautiful Soup on the heroku Application

I am trying to deploy a bot I made in Python using the following libraries:
requests, beautifulsoup4, discord.
This is to be deployed using I believe git hub and Heroku. The bot deploys successfully; however, when I check the logs, the bot has crashed. Here is the error message:
2020-05-17T23:17:42.624634+00:00 app[api]: Deploy 83c32a30 by user ****************************
2020-05-17T23:17:42.624634+00:00 app[api]: Release v12 created by user ****************************
2
2020-05-17T23:17:43.134443+00:00 heroku[worker.1]: State changed from crashed to starting
2020-05-17T23:17:48.338694+00:00 heroku[worker.1]: State changed from starting to up
2020-05-17T23:17:51.764352+00:00 heroku[worker.1]: State changed from up to crashed
2020-05-17T23:17:51.660991+00:00 app[worker.1]: Traceback (most recent call last):
2020-05-17T23:17:51.661016+00:00 app[worker.1]: File "BocoBot_Version1.py", line 126, in <module>
2020-05-17T23:17:51.661182+00:00 app[worker.1]: soup = BeautifulSoup(source, 'lxml')
2020-05-17T23:17:51.661184+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/bs4/__init__.py", line 245, in __init__
2020-05-17T23:17:51.661401+00:00 app[worker.1]: % ",".join(features))
**2020-05-17T23:17:51.661423+00:00 app[worker.1]: bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?**
2020-05-17T23:17:57.000000+00:00 app[api]: Build succeeded
I believe this is the issue in question:
bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?
But I do not know what I need to do to resolve it. My guess is that it has to do with my requirements.txt file where I tell it what packages to add. But no matter what changes I make to BeautifulSoup4, it continues not to work.
Here is the requirements.txt file information:
git+https://github.com/Rapptz/discord.py
PyNaCl==1.3.0
pandas
beautifulsoup4
requests
discord
dnspython==1.16.0
async-timeout==3.0.1
Any suggestions would be greatly appreciated and I will be happy to add more information.
Try adding lxml to your requirements.txt.

pyusb - [Error 5] on Linux, but not Windows

I'm trying to communicate with an AD9913 evaluation board (Analog Devices), which has a Cypress FX-2 USB controller. I wrote a fully functional Python library which works flawlessly on Windows 7 (using a driver generated through libusb-win32-1.2.6.0's inf-wizard.exe), but now I try to run the same software from a Raspberry Pi 3 with Raspbian Jessie and cannot seem to write or read.
The following minimal example works on Windows 7:
import os
os.environ['PYUSB_DEBUG'] = 'debug'
import usb.core
print "usb.core file:", usb.core.__file__
# get device
dev = usb.core.find(idVendor=0x0456, idProduct=0xEE25)
if dev is None:
raise ValueError("Device not found")
dev.set_configuration()
# get the firmware version
print "Write: ", dev.write(0x01, [0x00])
print "Read: ", dev.read(0x81, 7)
The ouput here is:
usb.core file: C:\Python27\lib\site-packages\usb\core.pyc
Write: 1
Read: array('B', [1, 0])
However, on the Raspberry several problems occur. First, the product ID is 0xEE24 (which I found out through dmesg), and second, the code example above gives
usb.core file: /usr/local/lib/python2.7/dist-packages/usb/core.pyc
Write:
Traceback (most recent call last):
File "usbtesting_minimal_linux.py", line 29, in <module>
print "Write: ", dev.write(0x01, [0x00])
File "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 948, in write
self.__get_timeout(timeout)
File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb1.py", line 824, in bulk_write
timeout)
File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb1.py", line 920, in __write
_check(retval)
File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb1.py", line 595, in _check
raise USBError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBError: [Errno 5] Input/Output Error
I'm executing the script by calling sudo python minimal_example.py, otherwise (as expected) I get usb.core.USBError: [Errno 13] Access denied (insufficient permissions). (For the testing described above, I removed the udev rules I added to allow access to my regular user account, and rebooted and replugged the device afterwards.)
I also noticed that on Windows, Configuration 1 (which is the only configuration) as revealed by adding
cfg = dev.get_active_configuration()
to aforementioned example script, has only one Interface 0, where as on Linux Interface 0 has no endpoints, but there are additional interfaces Interface 0, 1, Interface 0, 2 and Interface 0,3, the first of which is identical to the sole interface shown by Windows.
Detaching kernel drivers as described in this post -- which given my current understanding as a USB novice should not be necessary here -- does not resolve the problem.
I suspect that the issue stems from a difference between the Windows/libusb and Linux implementation/backend of the USB communication (already hinted at by the fact that the productID shown is different for the very same piece of hardware attached), which might require some changes to the way I'm writing to the USB endpoint.
I'm happy to provide more information if needed and welcome all hints and suggestions.
Most likely, this error caused by the firmware is not uploaded. Usually speaking, FX-2 USB controller does not save the firmware.
Although I still cannot communicate with the device on the Raspberry Pi, the Error 5 problem is resolved by explicitly selecting a suitable alternate setting with proper endpoints, e.g.
dev.set_interface_altsetting(interface = 0, alternate_setting = 1)
Then read/write requests no longer fail with Error 5, but with a timeout error (which is Error 110 for libusb1 and None for libusb0).
I now suspect that there is a problem with how the device is detected by the operating system, since not only the productID changes between Windows and Linux, but also wMaxPacketSize for the endpoints I'm interested in is given as 64 bytes on Windows and 512 bytes on Linux.
Once I'm further along in my troubleshooting, I will either open a new question and add the link as a comment to this answer (or post the whole solution here in case I can solve everything right away).

GSM Shield with Raspberry Pi Port Open

I have connected a-gsm shield http://itbrainpower.net/a-gsm/downloadables/a-gsm-series-presentation-v1.01.pdf with Raspberry Pi 3.
I have imported and attempted to execute power on code http://itbrainpower.net/a-gsm/RaspberryPI-gsm-shield-library-powerOnOff-demo-code-a-gsm. However, I am getting the following error message:
sudo ./poweronoff.py
Traceback (most recent call last):
File "./poweronoff.py", line 66, in <module>
agsm.open()
File "/usr/lib/python2.7/dist-packages/serial/serialposix.py", line 271, in open
raise SerialException("Port is already open.")
serial.serialutil.SerialException: Port is already open.
I assume I need to open a different port. If that is the solution, how do I do it. If that is not the solution, what do I need to do to satisfy this error message?
Follow directions in this post https://www.raspberrypi.org/forums/viewtopic.php?uid=195125&f=28&t=165897&start=0.
Basically, "enable_uart=1" should be the last line in '/boot/config.txt' for serial port operations. Reboot the RPi3 and everything should work.

Jupyterhub on Google compute engine

I'm trying to set up a Jupyterhub instance to serve IPython notebooks on a Google Compute Engine. However, when running jupyterhub i am faced with an error regarding sockets:
[E 2015-08-31 10:27:55.617 JupyterHub app:1097]
Traceback (most recent call last):
File "/home/esten/anaconda3/envs/py3k/lib/python3.3/site- packages/jupyterhub/app.py", line 1095, in launch_instance_async
yield self.start()
File "/home/esten/anaconda3/envs/py3k/lib/python3.3/site-packages/jupyterhub/app.py", line 1027, in start
self.http_server.listen(self.hub_port, address=self.hub_ip)
File "/home/esten/anaconda3/envs/py3k/lib/python3.3/site-packages/tornado/tcpserver.py", line 126, in listen
sockets = bind_sockets(port, address=address)
File "/home/esten/anaconda3/envs/py3k/lib/python3.3/site-packages/tornado/netutil.py", line 187, in bind_sockets
sock.bind(sockaddr)
OSError: [Errno 99] Cannot assign requested address
The address/port assigned by the config file is localhost/8081, and binding a socket like below works perfectly fine
import socket
s = socket.socket()
s.bind(("localhost", 8081))
Does jupyterhub look somewhere else for the information or is something done differently when binding the socket through my own code?
This seems to be a problem with GCE not supporting ipv6.
I found this link explaining that enabling ipv6 solved the issue on another machine.
Running using --ip solved the issue:
jupyter notebook --ip="*"