def _request_spectrum(self): """ 0x09 request spectra """ self._dev.write(self._EP1_out, struct.pack('<B', 0x09)) if self._usbcomm == 0x80: #HIGHSPEED ret = [self._dev.read(self._EP2_in, 512) for _ in range(8)] else: # _usbcomm == 0x00 #FULLSPEED ret = [self._dev.read(self._EP2_in, 64) for _ in range(64)] ret = sum(ret[1:], ret[0]) spectrum = struct.unpack('<'+'h'*2048, ret) sync = self._dev.read(self._EP2_in, 1) if sync[0] != 0x69: raise _OOError('request_spectrum: Wrong answer') return spectrum
def _request_spectrum(self): """ 0x09 request spectra """ self._dev.write(self._EP1_out, struct.pack('<B', 0x09)) if self._usbcomm == 0x80: #HIGHSPEED ret = [self._dev.read(self._EP2_in, 512) for _ in range(8)] else: # _usbcomm == 0x00 #FULLSPEED ret = [self._dev.read(self._EP2_in, 64) for _ in range(64)] ret = sum(ret[1:], ret[0]) spectrum = struct.unpack('<' + 'h' * 2048, ret) sync = self._dev.read(self._EP2_in, 1) if sync[0] != 0x69: raise _OOError('request_spectrum: Wrong answer') return spectrum
def __init__(self): self._dev = usb.core.find(idVendor=0x2457, idProduct=0x101E) if self._dev is None: raise _OOError('No OceanOptics USB2000+ spectrometer found!') else: print ('*NOTE*: Currently the first device matching the ' 'Vendor/Product id is used') # This information comes from the OEM-Datasheet # "http://www.oceanoptics.com/technical" # "/engineering/OEM%20Data%20Sheet%20--%20USB2000+.pdf" self._EP1_out = 0x01 self._EP1_in = 0x81 self._EP2_in = 0x82 self._EP6_in = 0x86 self._EP1_in_size = 64 self._EP2_in_size = 512 self._EP6_in_size = 512 # This part makes the initialization a little bit more robust self._dev.set_configuration() self._initialize() #<robust># while True: try: self._usbcomm = self._query_status()['usb_speed'] break except usb.core.USBError: pass while True: try: self._request_spectrum() break except: pass #</robust># self._wl = self._get_wavelength_calibration() self._nl = self._get_nonlinearity_calibration() self._st = self._get_saturation_calibration() self.Serial = self._get_serial()
def __init__(self): self._dev = usb.core.find(idVendor=0x2457, idProduct=0x101E) if self._dev is None: raise _OOError('No OceanOptics USB2000+ spectrometer found!') else: print('*NOTE*: Currently the first device matching the ' 'Vendor/Product id is used') # This information comes from the OEM-Datasheet # "http://www.oceanoptics.com/technical" # "/engineering/OEM%20Data%20Sheet%20--%20USB2000+.pdf" self._EP1_out = 0x01 self._EP1_in = 0x81 self._EP2_in = 0x82 self._EP6_in = 0x86 self._EP1_in_size = 64 self._EP2_in_size = 512 self._EP6_in_size = 512 # This part makes the initialization a little bit more robust self._dev.set_configuration() self._initialize() #<robust># while True: try: self._usbcomm = self._query_status()['usb_speed'] break except usb.core.USBError: pass while True: try: self._request_spectrum() break except: pass #</robust># self._wl = self._get_wavelength_calibration() self._nl = self._get_nonlinearity_calibration() self._st = self._get_saturation_calibration() self.Serial = self._get_serial()
def _get_nonlinearity_calibration(self): if int(self._query_information(14)) != 7: # Don't care about this right now raise _OOError('This spectrometer has less correction factors') return [float(self._query_information(i)) for i in range(6,14)]
def _get_nonlinearity_calibration(self): if int(self._query_information(14)) != 7: # Don't care about this right now raise _OOError('This spectrometer has less correction factors') return [float(self._query_information(i)) for i in range(6, 14)]