Month: May 2014
USB parallel ports under Python on Ubuntu
I have this PCB designed to control four flame effects. Instead of running it on the Arduino, I’m doing an FFT on a laptop and trying to control the solenoid drivers through a USB parallel port adapter on the laptop.
Ubuntu recognizes the USB parallel port adapter, and gives me a port in /dev/usb/lp0
. I don’t have permissions to access it, because its user and group are root and lp, and I’m neither of those. The specific error is:
>>> p = parallel.Parallel('/dev/usb/lp0')
Traceback (most recent call last):
File "
File "/usr/lib/python2.7/dist-packages/parallel/parallelppdev.py", line 187, in __init__
self._fd = os.open(self.device, os.O_RDWR)
OSError: [Errno 13] Permission denied: '/dev/usb/lp0'
sudo chmod o+rw /dev/usb/lp0
doesn’t get me any closer, because whatever python-parallel does under the hood is not a legit operation on that dev entry.
>>> p = parallel.Parallel("/dev/usb/lp0")
Traceback (most recent call last):
File "
File "/usr/lib/python2.7/dist-packages/parallel/parallelppdev.py", line 189, in __init__
self.PPEXCL()
File "/usr/lib/python2.7/dist-packages/parallel/parallelppdev.py", line 241, in PPEXCL
fcntl.ioctl(self._fd, PPEXCL)
IOError: [Errno 25] Inappropriate ioctl for device
The /dev/usb/lp0
device entry appears to be created by the usblp module. I have a suspicion that what’s going on here is that the device entry created by usblp isn’t claimable the way one created by ppdev would be.
Using rmmod to get rid of usblp doesn’t work, it just gets restarted when I re-insert the USB connector for the adapter. Blacklisting it in /etc/modprobe.d/blacklist.conf just means that the /dev entry doesn’t get created, not that ppdev takes over.
Most reports online also indicate that USB parallel ports don’t really act like parallel ports, but only work for connecting parallel printers. Since I’ve already wasted enough time on this, it’s time to go with plan B. I’m going to fully populate the board, so that it has an Arduino on it, and then interface to that using serial commands and possibly Processing or OpenFrameworks.
Recent Comments