Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FLAMES sporadic data transfer error #129

Open
joellama opened this issue Aug 11, 2021 · 7 comments
Open

FLAMES sporadic data transfer error #129

joellama opened this issue Aug 11, 2021 · 7 comments

Comments

@joellama
Copy link

spectrometer and system information

model: USB2000PLUS
operating system: Ubuntu 20.10
python version: 3.8.5
python-seabreeze version: 1.3.0
installed-via: pip install seabreeze

current problem

I have a script that connects to 3 spectrometers and samples them every second to record the intensities. The problem is that everything works for a given amount of time (sometimes tens of minutes, sometimes hours) and then the code just hangs. On Ctrl+C I get a data transfer error.

minimal code example and error (very helpful if available)

from seabreeze.spectrometers import Spectrometer, list_devices
import time

def get_temperature(spec):
    spec.f.raw_usb_bus_access.raw_usb_write(
        struct.pack('<B', 0x6C), endpoint='primary_out')
    raw_bytes_response = spec.f.raw_usb_bus_access.raw_usb_read(
        endpoint='primary_in')
    temp = 0.003906 * float(struct.unpack("<h", raw_bytes_response[1:3])[0])
    return temp

if __name__ == '__main__':
    blue = Spectrometer.from_serial_number('FLMS18610')
    green = Spectrometer.from_serial_number('FLMS18611')
    red = Spectrometer.from_serial_number('FLMT05929')
    blue_exp_time = 380000
    green_exp_time = 80000
    red_exp_time = 500000
    blue.integration_time_micros(int(blue_exp_time))
    green.integration_time_micros(int(green_exp_time))
    red.integration_time_micros(int(red_exp_time))
    while True:
        blue_wavelengths = blue.wavelengths()
        blue_intensity = blue.intensities(correct_dark_counts=True,
                                          correct_nonlinearity=True)
        blue_temperature = get_temperature(blue)
        green_wavelengths = green.wavelengths()
        green_intensity = green.intensities(correct_dark_counts=True,
                                            correct_nonlinearity=True)
        green_temperature = get_temperature(green)
        red_wavelengths = red.wavelengths()
        red_intensity = red.intensities(correct_dark_counts=True,
                                        correct_nonlinearity=True)
        red_temperature = get_temperature(red)
        # Save the file redacted for brevity
        time.sleep(1)
@ap--
Copy link
Owner

ap-- commented Aug 11, 2021

Hi @joellama,

what does

cat /sys/module/usbcore/parameters/autosuspend

return on your ubuntu 20.10 machine?

Cheers,
Andreas 😃

@joellama
Copy link
Author

joellama commented Aug 11, 2021

Uhoh, I really hope it's not something stupid like that! It says 2? Can't seem to find any documentation on what that actually means.

@ap--
Copy link
Owner

ap-- commented Aug 11, 2021

You mentioned it's sporadic, so my guess would be some weird USB problem...
On linux PCs that are used for scientific measurements I'd generally recommend disabling everything related to power management.

I think usb autosuspend is disabled by adding: usbcore.autosuspend=-1 as a grub boot parameter.
You should be able to verify the setting with the cat command from above.

I hope that helps. If not we'll have to dig a little deeper and try to create a reproducible error case.

@joellama
Copy link
Author

Thanks for this @ap--. I've swapped out the USB cables just to be safe and have set usbcore.autosuspend=-1, I'll let it run for today and tomorrow and see how it goes!

@ap--
Copy link
Owner

ap-- commented Aug 12, 2021

You're welcome 😊
And fingers crossed 🤞 🤞

@joellama
Copy link
Author

Hi @ap--, sadly this didn't help and I'm still getting random dropouts and the code hanging. I'm now trying the windows softare that comes with the spectrographs to see if that can handle running for 12 hours straight.

@ap--
Copy link
Owner

ap-- commented Aug 22, 2021

Hi Joel,

Another thing worth trying would be to run the 3 spectrometers in three different processes. (You could test by running a script continuously with only one spectrometer.)

Did your tests with the default software run for more than 12h?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants