ap-- / python-seabreeze

Python module for OceanOptics spectrometers
https://python-seabreeze.readthedocs.io
MIT License
211 stars 82 forks source link

USB2000 Issue reading intensities #197

Open jjcamus opened 1 year ago

jjcamus commented 1 year ago

spectrometer and system information

current problem

When trying to read the intensities of an USB2000 using pyseabreeze in a Raspberry Pi 4, i get an error from the libusb library "[Errno 5] Input/Output Error"

I already updated the USB2000 FirmWare and check that the reading works using the cseabreeze backend in my windows 10 64 bit (using python 3.9.2 as well and installed via pip), so the spectrometer is not the problem.

The Raspberry detect the USB2000 and can read the wavelengths. Is trying to read the intensities the issue.

Another issue is that in windows using the pyseabreeze backend doesn't detect the spectrometer, but in the raspberry using the cseabreeze backend doesn't detect the spectrometer.

steps to reproduce

After installing the library in the raspberry with pip (piwheels), run:

  1. import seabreeze
  2. seabreeze.use('pyseabreeze')
  3. spec = seabreeze.spectrometers.Spectrometer.from_first_available()
  4. intensities = spec.intensities()

minimal code example and error (very helpful if available)

Traceback (most recent call last):
  File "/home/camus/Documents/testSeaBreez.py", line 24, in <module>
    intensities = spec.intensities()
  File "/home/camus/python-seabreeze/build/lib.linux-armv7l-3.9/seabreeze/spectrometers.py", line 212, in intensities
    out = self._dev.f.spectrometer.get_intensities()
  File "/home/camus/python-seabreeze/build/lib.linux-armv7l-3.9/seabreeze/pyseabreeze/features/spectrometer.py", line 187, in get_intensities
    tmp = self._get_spectrum_raw()
  File "/home/camus/python-seabreeze/build/lib.linux-armv7l-3.9/seabreeze/pyseabreeze/features/spectrometer.py", line 159, in _get_spectrum_raw
    self.protocol.send(0x09)
  File "/home/camus/python-seabreeze/build/lib.linux-armv7l-3.9/seabreeze/pyseabreeze/protocol.py", line 78, in send
    return self.transport.write(data, timeout_ms=timeout_ms)
  File "/home/camus/python-seabreeze/build/lib.linux-armv7l-3.9/seabreeze/pyseabreeze/transport.py", line 184, in write
    return self._device.pyusb_device.write(  # type: ignore
  File "/home/camus/.local/lib/python3.9/site-packages/usb/core.py", line 989, in write
    return fn(
  File "/home/camus/.local/lib/python3.9/site-packages/usb/backend/libusb1.py", line 837, in bulk_write
    return self.__write(self.lib.libusb_bulk_transfer,
  File "/home/camus/.local/lib/python3.9/site-packages/usb/backend/libusb1.py", line 938, in __write
    _check(retval)
  File "/home/camus/.local/lib/python3.9/site-packages/usb/backend/libusb1.py", line 604, in _check
    raise USBError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBError: [Errno 5] Input/Output Error
ap-- commented 1 year ago

Hello @jjcamus

In your description you state that you've installed python-seabreeze from the provided wheels on your rasbian installation, but the traceback suggests you're running from an editable install?

Also: if your spectrometer works on windows via the cseabreeze backend, why not use the same on the raspberry?

Cheers, Andreas :smiley:

PS.: here's a link to the piwheels build for rasberry: https://www.piwheels.org/project/seabreeze/