Open Zanati123 opened 6 years ago
As fixed with your recent commit "Updated README.md for pyusbiss 0.2.0" in dhhagan/py-opc
The script was updated to:
from usbiss.spi import SPI
import opc
##Build the connector
spi = SPI("/dev/ttyACM0")
##Set the SPI mode and clock speed
spi.mode = 1
spi.max_speed_hz = 500000
alpha = opc.OPCN2(spi)
##Turn on the device
alpha.on()
##Read the histogram
alpha.histogram()
##Turn the device off
alpha.off()
But an error returns as:
>>> Traceback (most recent call last):
File "/home/pi/test1.py", line 11, in <module>
alpha = opc.OPCN2(spi)
File "/home/pi/opc/__init__.py", line 238, in __init__
super(OPCN2, self).__init__(spi_connection, model='N2', **kwargs)
File "/home/pi/opc/__init__.py", line 50, in __init__
assert self.cnxn.mode == 1, "SPI mode must be 1"
AssertionError: SPI mode must be 1
>>>
I set the SPI mode to 1 but it shows an error that i haven't, any suggestions?
Regards, Zanati123
HI, thanks for trying. I have pushed a fix. The repo is undergoing a major change and so not sure how stable it is. If the latest fix works for you then I will release a version 0.2.0.
The stable version is v0.1.2 here https://github.com/DancingQuanta/pyusbiss/releases/tag/v0.1.2 where you use usbiss.USBISS
.
I have made a release 0.2.0
. Please install via pip install pyusbiss
and close this issue if it works for you.
The library have advanced to 0.2.2
.
### Description
Hey Dancing Quanta, Following your patch to pyusbiss, establishing communication to a alphasense OPC is greeted by an error: attributeError: 'module' object has no attribute 'USBISS'.
This is using dhhagan's sample script from py-opc to connect the sensor to Rpi via USB interface, line 5: s_pi = usbiss.USBISS("/dev/ttyACM0", "spi", spimode=1, freq=500000)
Looking into the script of usbiss.py, i am unsure how to adjust to make the class USBISS work. Would you have any advice?
Thank you, Zanati123
### What I Did