-
-
Notifications
You must be signed in to change notification settings - Fork 88
Open
Labels
Description
We have Seabreeze v2.10.0 running on a Raspberry pi 5 with an OceanFX Spectrometer, all is working great except spec.close(). On a windows based machine this works flawlessly to close a spectrometer after use and prevent a connection issue. The same Code running on a Pi5 will not close properly and cause issues when trying to reconnect. The following code will work every time on windows machine, but only once on a Pi5 and will not connect on subsequent runs. Do you have any thoughts?
from seabreeze.spectrometers import Spectrometer, list_devices
def get_spectrometer_serial_number():
# List all connected devices
devices = list_devices()
print("Devices found:", devices)
if not devices:
print("No spectrometers found.")
return None
# Connect to the first available spectrometer
spec = Spectrometer(devices[0])
# Get and print serial number
serial_number = spec.serial_number
print(f"Spectrometer Serial Number: {serial_number}")
# Close the device
spec.close()
print("Spectrometer connection closed.")
# Try accessing the spectrometer to confirm it's closed
try:
_ = spec.serial_number
print("ERROR: Spectrometer is still accessible after closing.")
except Exception as e:
print("Confirmed closed: accessing spectrometer raises an error.")
print("Error message:", str(e))
return serial_number
# Run the function
if __name__ == "__main__":
get_spectrometer_serial_number()