Closed benjaminesse closed 7 years ago
Hi @benjaminesse,
sorry for the long delay. What happens when you run your python code as root with a spectrometer attached?
-Andreas
Hi,
That works fine, it finds the spectrometer with no problems. Is there a way around running it from root every time? I'm not too familiar with Linux, I have used it sporadically but most of my development has been in windows, so apologies if I'm missing something!
Cheers,
Ben
See if your user is in the "plugdev" group: see which groups your linux user belongs to
And create the "plugdev" group and add your user to it if necessary: add a user to a group
-Andreas
Hey wait...i have the exact same problem ....i did not understand how benjamin solved his problem ...please help me solve it ...... and AP ....when i write groups in my pi user name it returns plugdev
your udev rules are installed correctly if there is a new symlink created in /dev
after you plug in your spectrometer. This symlink (if you have a USB2000 spectrometer, for example: /dev/usb2000-12345
, where 12345 is some number or string) should be owned by the plugdev group.
Hi,
I reloaded the udev rules fine with the update you referenced above, but I still can't connect without running the code from root.
I checked /dev and couldn't find a symlink (I'm running a Flame so I'm assuming it will be of the form "FLM-12345")
Thanks again
I think the flame should show up as a usb2000plus-
what's the output of lsusb when spectrometer is connected?
There is no USB symlink either. The output of lssub is:
Bus 001 Device 006: ID 2457:101e
Bus 001 Device 005: ID 03f0:034a Hewlett-Packard
Bus 001 Device 004: ID 0461:4d22 Primax Electronics, Ltd
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
so the udev rule for the USB2000plus will match. (The flame acts like a USB2000+ on the driver side)
ATTR{idVendor}=="2457", ATTR{idProduct}=="101e", SYMLINK+="usb2000+-%n", GROUP="plugdev"
when your spectrometer is plugged in what does the following command return:
ls /dev/usb*
It returns
ls: cannot access /dev/usb*: No such file or directory
and
ls /etc/udev/rules.d/
10-oceanoptics.rules 99-com.rules
Hmm, this is most likely due to your udev version. Try using an older version of the rules from here
download the file linked to above and overwrite the file /etc/udev/rules.d/10-oceanoptics.rules
on your rpi.
make sure that when you type cat /etc/udev/rules.d/10-oceanoptics.rules
it says ATTRS everywhere and not ATTR (as it does in the newer version of that file)
after that reboot your rpi.
If this doesn't help, I can't really provide further help. It's best if you google how to debug udev rules and try to figure out why the provided rules don't match. It's not complicated to do that. You'll find a tutorial easily. Good luck!
Nope, still got the same problem. I'll look into the udev rules then, thanks for your help!
Np.
one more quick thing to try: use the newer file again (the one with ATTR) and delete line 4, the one that starts with SUBSYSTEM... save it. reboot.
If that didn't help, and you figure out what's wrong, it would be great if you could report back! Good luck!
when i try to run sudo python ......i cannot import this "import seabreeze.spectrometers as sb" .....says no such module
@benjaminesse
run lsusb
it returns something like:
Bus 001 Device 006: ID 2457:101e
Bus 001 Device 005: ID 03f0:034a Hewlett-Packard
Bus 001 Device 004: ID 0461:4d22 Primax Electronics, Ltd
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
2457:101e
is your spectrometer. Remember Bus 001 and Device 006. and use these numbers in the following command:
udevadm info --attribute-walk --name=/dev/bus/usb/001/006
post the output here.
in my case the above command returns this
Udevadm info starts with the device specified by the devpath and then walks up the chain of parent devices. It prints for every device found, all possible attributes in the udev rules key format. A rule to match, can be composed by the attributes of the device and the attributes from one single parent device.
looking at device '/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.5': KERNEL=="1-1.5" SUBSYSTEM=="usb" DRIVER=="usb" ATTR{bDeviceClass}=="00" ATTR{manufacturer}=="USB4000 3.00.03" ATTR{bmAttributes}=="80" ATTR{bConfigurationValue}=="1" ATTR{version}==" 2.00" ATTR{devnum}=="6" ATTR{bMaxPower}=="400mA" ATTR{idProduct}=="1022" ATTR{avoid_reset_quirk}=="0" ATTR{urbnum}=="9" ATTR{bDeviceSubClass}=="00" ATTR{maxchild}=="0" ATTR{bcdDevice}=="0002" ATTR{bMaxPacketSize0}=="64" ATTR{idVendor}=="2457" ATTR{product}=="Ocean Optics USB4000" ATTR{speed}=="480" ATTR{removable}=="removable" ATTR{ltm_capable}=="no" ATTR{bNumConfigurations}=="1" ATTR{busnum}=="1" ATTR{authorized}=="1" ATTR{quirks}=="0x0" ATTR{configuration}=="" ATTR{devpath}=="1.5" ATTR{bDeviceProtocol}=="00" ATTR{bNumInterfaces}==" 1"
looking at parent device '/devices/platform/soc/3f980000.usb/usb1/1-1': KERNELS=="1-1" SUBSYSTEMS=="usb" DRIVERS=="usb" ATTRS{bDeviceClass}=="09" ATTRS{bmAttributes}=="e0" ATTRS{bConfigurationValue}=="1" ATTRS{version}==" 2.00" ATTRS{devnum}=="2" ATTRS{bMaxPower}=="2mA" ATTRS{idProduct}=="9514" ATTRS{avoid_reset_quirk}=="0" ATTRS{urbnum}=="69" ATTRS{bDeviceSubClass}=="00" ATTRS{maxchild}=="5" ATTRS{bcdDevice}=="0200" ATTRS{bMaxPacketSize0}=="64" ATTRS{idVendor}=="0424" ATTRS{speed}=="480" ATTRS{removable}=="unknown" ATTRS{ltm_capable}=="no" ATTRS{bNumConfigurations}=="1" ATTRS{busnum}=="1" ATTRS{authorized}=="1" ATTRS{quirks}=="0x0" ATTRS{configuration}=="" ATTRS{devpath}=="1" ATTRS{bDeviceProtocol}=="02" ATTRS{bNumInterfaces}==" 1"
looking at parent device '/devices/platform/soc/3f980000.usb/usb1': KERNELS=="usb1" SUBSYSTEMS=="usb" DRIVERS=="usb" ATTRS{bDeviceClass}=="09" ATTRS{manufacturer}=="Linux 4.9.35-v7+ dwc_otg_hcd" ATTRS{bmAttributes}=="e0" ATTRS{bConfigurationValue}=="1" ATTRS{version}==" 2.00" ATTRS{devnum}=="1" ATTRS{bMaxPower}=="0mA" ATTRS{idProduct}=="0002" ATTRS{avoid_reset_quirk}=="0" ATTRS{urbnum}=="25" ATTRS{bDeviceSubClass}=="00" ATTRS{maxchild}=="1" ATTRS{bcdDevice}=="0409" ATTRS{bMaxPacketSize0}=="64" ATTRS{idVendor}=="1d6b" ATTRS{product}=="DWC OTG Controller" ATTRS{speed}=="480" ATTRS{authorized_default}=="1" ATTRS{interface_authorized_default}=="1" ATTRS{removable}=="unknown" ATTRS{ltm_capable}=="no" ATTRS{serial}=="3f980000.usb" ATTRS{bNumConfigurations}=="1" ATTRS{busnum}=="1" ATTRS{authorized}=="1" ATTRS{quirks}=="0x0" ATTRS{configuration}=="" ATTRS{devpath}=="0" ATTRS{bDeviceProtocol}=="01" ATTRS{bNumInterfaces}==" 1"
looking at parent device '/devices/platform/soc/3f980000.usb': KERNELS=="3f980000.usb" SUBSYSTEMS=="platform" DRIVERS=="dwc_otg" ATTRS{wr_reg_test}=="Time to write GNPTXFSIZ reg 10000000 times: 730 msecs ( 73 jiffies)" ATTRS{grxfsiz}=="GRXFSIZ = 0x00000306" ATTRS{srpcapable}=="SRPCapable = 0x1" ATTRS{buspower}=="Bus Power = 0x1" ATTRS{bussuspend}=="Bus Suspend = 0x0" ATTRS{hptxfsiz}=="HPTXFSIZ = 0x02000406" ATTRS{hnp}=="HstNegScs = 0x0" ATTRS{mode}=="Mode = 0x1" ATTRS{mode_ch_tim_en}=="Mode Change Ready Timer Enable = 0x0" ATTRS{hsic_connect}=="HSIC Connect = 0x1" ATTRS{gsnpsid}=="GSNPSID = 0x4f54280a" ATTRS{driver_override}=="(null)" ATTRS{hcd_frrem}=="HCD Dump Frame Remaining" ATTRS{gotgctl}=="GOTGCTL = 0x001c0001" ATTRS{gpvndctl}=="GPVNDCTL = 0x00000000" ATTRS{hnpcapable}=="HNPCapable = 0x1" ATTRS{spramdump}=="SPRAM Dump" ATTRS{regoffset}=="0xffffffff" ATTRS{gnptxfsiz}=="GNPTXFSIZ = 0x01000306" ATTRS{guid}=="GUID = 0x2708a000" ATTRS{regdump}=="Register Dump" ATTRS{hprt0}=="HPRT0 = 0x00001005" ATTRS{hcddump}=="HCD Dump" ATTRS{rem_wakeup_pwrdn}=="" ATTRS{regvalue}=="invalid offset" ATTRS{gusbcfg}=="GUSBCFG = 0x20001700" ATTRS{fr_interval}=="Frame Interval = 0x1d4b" ATTRS{busconnected}=="Bus Connected = 0x1" ATTRS{remote_wakeup}=="Remote Wakeup Sig = 0 Enabled = 0 LPM Remote Wakeup = 0" ATTRS{devspeed}=="Device Speed = 0x0" ATTRS{rd_reg_test}=="Time to read GNPTXFSIZ reg 10000000 times: 1410 msecs ( 141 jiffies)" ATTRS{enumspeed}=="Device Enumeration Speed = 0x1" ATTRS{inv_sel_hsic}=="Invert Select HSIC = 0x0" ATTRS{ggpio}=="GGPIO = 0x00000000" ATTRS{srp}=="SesReqScs = 0x1"
looking at parent device '/devices/platform/soc': KERNELS=="soc" SUBSYSTEMS=="platform" DRIVERS=="" ATTRS{driver_override}=="(null)"
looking at parent device '/devices/platform': KERNELS=="platform" SUBSYSTEMS=="" DRIVERS==""
@benjaminesse any update on how did you run python as sudo and still call those dependencies?
Hi @soumendras, from that tutorial (and anyone correct me if I am wrong) when you run python from root the normal version associated that is used when you use the command
python hello.py
is not necessarily the same, so any libraries you have installed (such as the python-seabreeze) aren't installed in that version. I got around this by putting
#!PATHTOPYTHON
as the first line in the program replacing the PATHTOPYTHON with the actual path eg
#!/home/pi/berryconda3/bin/python3.6
for me. You then run it from root by typing
sudo ./hello.py
in the command line.
@ap-- I tried your suggestion of removing the lines and it worked, I now have no issues getting the program to detect the spectrometer, thank you! The output of the command you posted 2 comments back is:
Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.
looking at device '/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.5':
KERNEL=="1-1.5"
SUBSYSTEM=="usb"
DRIVER=="usb"
ATTR{bDeviceSubClass}=="00"
ATTR{bDeviceProtocol}=="00"
ATTR{devpath}=="1.5"
ATTR{idVendor}=="2457"
ATTR{speed}=="480"
ATTR{bNumInterfaces}==" 1"
ATTR{bConfigurationValue}=="1"
ATTR{bMaxPacketSize0}=="64"
ATTR{busnum}=="1"
ATTR{devnum}=="7"
ATTR{configuration}==""
ATTR{bMaxPower}=="400mA"
ATTR{authorized}=="1"
ATTR{bmAttributes}=="80"
ATTR{bNumConfigurations}=="1"
ATTR{maxchild}=="0"
ATTR{bcdDevice}=="0002"
ATTR{avoid_reset_quirk}=="0"
ATTR{quirks}=="0x0"
ATTR{version}==" 2.00"
ATTR{urbnum}=="64"
ATTR{ltm_capable}=="no"
ATTR{manufacturer}=="Flame-S 4.01.0 "
ATTR{removable}=="removable"
ATTR{idProduct}=="101e"
ATTR{bDeviceClass}=="00"
ATTR{product}=="Ocean Optics Flame-S"
looking at parent device '/devices/platform/soc/3f980000.usb/usb1/1-1':
KERNELS=="1-1"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{bDeviceSubClass}=="00"
ATTRS{bDeviceProtocol}=="02"
ATTRS{devpath}=="1"
ATTRS{idVendor}=="0424"
ATTRS{speed}=="480"
ATTRS{bNumInterfaces}==" 1"
ATTRS{bConfigurationValue}=="1"
ATTRS{bMaxPacketSize0}=="64"
ATTRS{busnum}=="1"
ATTRS{devnum}=="2"
ATTRS{configuration}==""
ATTRS{bMaxPower}=="2mA"
ATTRS{authorized}=="1"
ATTRS{bmAttributes}=="e0"
ATTRS{bNumConfigurations}=="1"
ATTRS{maxchild}=="5"
ATTRS{bcdDevice}=="0200"
ATTRS{avoid_reset_quirk}=="0"
ATTRS{quirks}=="0x0"
ATTRS{version}==" 2.00"
ATTRS{urbnum}=="112"
ATTRS{ltm_capable}=="no"
ATTRS{removable}=="unknown"
ATTRS{idProduct}=="9514"
ATTRS{bDeviceClass}=="09"
looking at parent device '/devices/platform/soc/3f980000.usb/usb1':
KERNELS=="usb1"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{bDeviceSubClass}=="00"
ATTRS{bDeviceProtocol}=="01"
ATTRS{devpath}=="0"
ATTRS{idVendor}=="1d6b"
ATTRS{speed}=="480"
ATTRS{bNumInterfaces}==" 1"
ATTRS{bConfigurationValue}=="1"
ATTRS{bMaxPacketSize0}=="64"
ATTRS{authorized_default}=="1"
ATTRS{busnum}=="1"
ATTRS{devnum}=="1"
ATTRS{configuration}==""
ATTRS{bMaxPower}=="0mA"
ATTRS{authorized}=="1"
ATTRS{bmAttributes}=="e0"
ATTRS{bNumConfigurations}=="1"
ATTRS{maxchild}=="1"
ATTRS{interface_authorized_default}=="1"
ATTRS{bcdDevice}=="0404"
ATTRS{avoid_reset_quirk}=="0"
ATTRS{quirks}=="0x0"
ATTRS{serial}=="3f980000.usb"
ATTRS{version}==" 2.00"
ATTRS{urbnum}=="25"
ATTRS{ltm_capable}=="no"
ATTRS{manufacturer}=="Linux 4.4.34-v7+ dwc_otg_hcd"
ATTRS{removable}=="unknown"
ATTRS{idProduct}=="0002"
ATTRS{bDeviceClass}=="09"
ATTRS{product}=="DWC OTG Controller"
looking at parent device '/devices/platform/soc/3f980000.usb':
KERNELS=="3f980000.usb"
SUBSYSTEMS=="platform"
DRIVERS=="dwc_otg"
ATTRS{hnp}=="HstNegScs = 0x0"
ATTRS{srp}=="SesReqScs = 0x1"
ATTRS{regvalue}=="invalid offset"
ATTRS{hsic_connect}=="HSIC Connect = 0x1"
ATTRS{guid}=="GUID = 0x2708a000"
ATTRS{mode}=="Mode = 0x1"
ATTRS{srpcapable}=="SRPCapable = 0x1"
ATTRS{regdump}=="Register Dump"
ATTRS{gpvndctl}=="GPVNDCTL = 0x00000000"
ATTRS{ggpio}=="GGPIO = 0x00000000"
ATTRS{hprt0}=="HPRT0 = 0x00001005"
ATTRS{wr_reg_test}=="Time to write GNPTXFSIZ reg 10000000 times: 370 msecs (37 jiffies)"
ATTRS{driver_override}=="(null)"
ATTRS{hcd_frrem}=="HCD Dump Frame Remaining"
ATTRS{mode_ch_tim_en}=="Mode Change Ready Timer Enable = 0x0"
ATTRS{gnptxfsiz}=="GNPTXFSIZ = 0x01000306"
ATTRS{remote_wakeup}=="Remote Wakeup Sig = 0 Enabled = 0 LPM Remote Wakeup = 0"
ATTRS{busconnected}=="Bus Connected = 0x1"
ATTRS{hcddump}=="HCD Dump"
ATTRS{gotgctl}=="GOTGCTL = 0x001c0001"
ATTRS{spramdump}=="SPRAM Dump"
ATTRS{grxfsiz}=="GRXFSIZ = 0x00000306"
ATTRS{gsnpsid}=="GSNPSID = 0x4f54280a"
ATTRS{gusbcfg}=="GUSBCFG = 0x20001700"
ATTRS{hptxfsiz}=="HPTXFSIZ = 0x02000406"
ATTRS{devspeed}=="Device Speed = 0x0"
ATTRS{fr_interval}=="Frame Interval = 0x1d4c"
ATTRS{rem_wakeup_pwrdn}==""
ATTRS{bussuspend}=="Bus Suspend = 0x0"
ATTRS{buspower}=="Bus Power = 0x1"
ATTRS{hnpcapable}=="HNPCapable = 0x1"
ATTRS{rd_reg_test}=="Time to read GNPTXFSIZ reg 10000000 times: 940 msecs (94 jiffies)"
ATTRS{enumspeed}=="Device Enumeration Speed = 0x1"
ATTRS{inv_sel_hsic}=="Invert Select HSIC = 0x0"
ATTRS{regoffset}=="0xffffffff"
looking at parent device '/devices/platform/soc':
KERNELS=="soc"
SUBSYSTEMS=="platform"
DRIVERS==""
ATTRS{driver_override}=="(null)"
looking at parent device '/devices/platform':
KERNELS=="platform"
SUBSYSTEMS==""
DRIVERS==""
@benjaminesse awesome! I'll fix this at some point in the future, until then we'll leave this open for people who run into the udev issue.
Note to self: udev SUBSYSTEM needs to match against "usb" not "usb_device" on raspbian jessie ?!?
if you're on raspbian and you have this issue open the 10-oceanoptics.rules file and replace "usb_device" with "usb" in line 4.
I had the same problem as this, but my rpi3 does not even recognize the spectrometer when connected, in the lsusb command it is also not listed. I followed all these steps and the tutorial and nothing has changed, what do I do? The model of the spectrometer is the USB2000 +
if you're raspbian and you have this issue open the 10-oceanoptics.rules https://github.com/ap--/python-seabreeze/blob/master/misc/10-oceanoptics.rules#L4 file and replace "usb_device" with "usb" in line 4.
This is what you might be missing. Did u do this? *****Quitters never win, Winners never quit**
SOUMENDRA SINGH SCIENTIST, CENTER FOR ASTROPARTICLE PHYSICS & SPACE SCIENCE BOSE INSTITUTE BLOCK EN, SECTOR-V SALT LAKE CITY, KOLKATA-91
+919432926954 +919433339275
On Wed, 12 Jun, 2019, 11:31 PM Gabriel Cruz, notifications@github.com wrote:
I had the same problem as this, but my rpi3 does not even recognize the spectrometer when connected, in the lsusb command it is also not listed. I followed all these steps and the tutorial and nothing has changed, what do I do? The model of the spectrometer is the USB2000 +
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ap--/python-seabreeze/issues/51?email_source=notifications&email_token=AHIGJ7XTIIHFZW2BDKYFVTLP2E2XNA5CNFSM4DSLAN62YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXRJMLQ#issuecomment-501388846, or mute the thread https://github.com/notifications/unsubscribe-auth/AHIGJ7U5JZA4D4BWN3OZPYTP2E2XNANCNFSM4DSLAN6Q .
Yes, I did it, it's like this: SUBSYSTEM!="usb", ACTION!="add", GOTO="oceanoptics_rules_end". Is that correct?
It is like, backspace from e of device to underscore. Just look for usb_device in the whole document and replace it by usb.
On Thu, 13 Jun, 2019, 12:02 AM Gabriel Cruz, notifications@github.com wrote:
Yes, I did it, it's like this: SUBSYSTEM!="usb", ACTION!="add", GOTO="oceanoptics_rules_end". Is that correct?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ap--/python-seabreeze/issues/51?email_source=notifications&email_token=AHIGJ7RRSB2QOAVJQZX2OWDP2E6LDA5CNFSM4DSLAN62YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXRMHRY#issuecomment-501400519, or mute the thread https://github.com/notifications/unsubscribe-auth/AHIGJ7SXR2AY276DY3EHBDLP2E6LDANCNFSM4DSLAN6Q .
I searched the document, but there was no other line containing "usb_device"
Are you sure u r calling the right python. Remember python and sudo python will be calling different versions. Make sure u call the one where u installed miniconda.
On Mon, 17 Jun, 2019, 5:34 PM Gabriel Cruz, notifications@github.com wrote:
I searched the document, but there was no other line containing "usb_device"
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ap--/python-seabreeze/issues/51?email_source=notifications&email_token=AHIGJ7TNQYM3SIPEBLW3Z2TP254UVA5CNFSM4DSLAN62YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODX26N5Y#issuecomment-502654711, or mute the thread https://github.com/notifications/unsubscribe-auth/AHIGJ7QIBONI73WDGUMNI4DP254UVANCNFSM4DSLAN6Q .
I'm not sure what version of python I've installed berryconda, but I'll install it all again to make sure. Apparently the pyseabreeze is installed correctly because when I run the code to look for the device it returns only empty ([]) and throws no exceptions
spectrometer and system information
current problem
Installation of python-seabreeze is fine, but when I try to reset the rules in /etc/udev/rules.d/ by running:
it returns
After googling I haven't found much to help, I am new to the Raspberry Pi. I have tried
which executes with no error but doesn't allow the spectrometer to be detected.
I have tried several reboots and unplugs/replugs of the spectrometer.
steps to reproduce
Step by step instructions to reproduce the error. The more detailed the better, but please use some common sense:
In python, running
returns
with no spectrometers attached (as expected) and
with the USB2000+ connected.
Any light you can shed would be gratefully received.
Many thanks!