python-ivi / python-usbtmc

Provides a USBTMC driver for controlling instruments over USB
MIT License
160 stars 68 forks source link

Overflow during instrument initialization Chroma Power supply #34

Open spsmspsm opened 7 years ago

spsmspsm commented 7 years ago

Hi,

I am trying to run a simple example, but even if the device is enumerated properly with:

>>> usbtmc.list_devices()
[<DEVICE ID 1698:0837 on Bus 003 Address 005>]

The initialization code fails with an overflow.

  File "./chroma.py", line 7, in <module>
    supply = ivi.chroma.chroma62012p8060('USB::5784::2103::009000000571::INSTR')
  File "/usr/local/lib/python3.5/dist-packages/ivi/chroma/chroma62012p8060.py", line 35, in __init__
    super(chroma62012p8060, self).__init__(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/ivi/chroma/chroma62000p.py", line 37, in __init__
    super(chroma62000p, self).__init__(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/ivi/chroma/chromaBaseDCPwr.py", line 43, in __init__
    super(chromaBaseDCPwr, self).__init__(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/ivi/scpi/dcpwr.py", line 48, in __init__
    super(Base, self).__init__(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/ivi/extra/common.py", line 33, in __init__
    super(SerialNumber, self).__init__(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/ivi/scpi/common.py", line 104, in __init__
    super(SelfTest, self).__init__(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/ivi/dcpwr.py", line 56, in __init__
    super(Base, self).__init__(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/ivi/ivi.py", line 1691, in __init__
    self.initialize(resource, id_query, reset, **kw)
  File "/usr/local/lib/python3.5/dist-packages/ivi/scpi/dcpwr.py", line 89, in _initialize
    self._clear()
  File "/usr/local/lib/python3.5/dist-packages/ivi/ivi.py", line 2000, in _clear
    return self._interface.clear()
  File "/usr/local/lib/python3.5/dist-packages/python_usbtmc-0.8-py3.5.egg/usbtmc/usbtmc.py", line 690, in clear
  File "/usr/local/lib/python3.5/dist-packages/python_usbtmc-0.8-py3.5.egg/usbtmc/usbtmc.py", line 349, in open
  File "/usr/local/lib/python3.5/dist-packages/python_usbtmc-0.8-py3.5.egg/usbtmc/usbtmc.py", line 699, in clear
  File "/usr/local/lib/python3.5/dist-packages/usb/core.py", line 1043, in ctrl_transfer
    self.__get_timeout(timeout))
  File "/usr/local/lib/python3.5/dist-packages/usb/backend/libusb1.py", line 883, in ctrl_transfer
    timeout))
  File "/usr/local/lib/python3.5/dist-packages/usb/backend/libusb1.py", line 595, in _check
    raise USBError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBError: [Errno 75] Overflow

I Added some printout of the ctrl_transfers as they go, it is the last one that produces the overflow:

 PatchFile "/usr/local/lib/python3.5/dist-packages/usb/backend/libusb1.py", line 883, in ctrl_transfer

   print ("SPS",                        dev_handle.handle,
                                        bmRequestType,
                                        bRequest,
                                        wValue,
                                        wIndex,
                                        cast(addr, POINTER(c_ubyte)),
                                        length,
                                        timeout)

SPS c_void_p(49390048) 128 6 768 0 <pyvisa.ctwrapper.types.LP_c_ubyte object at 0x7fd9effa0f28> 254 1000
4
SPS c_void_p(49390048) 128 6 771 1033 <pyvisa.ctwrapper.types.LP_c_ubyte object at 0x7fd9effa0f28> 255 1000
26
**SPS c_void_p(49390048) 161 5 0 0 <pyvisa.ctwrapper.types.LP_c_ubyte object at 0x7fd9effa0f28> 1 5000
-8**

Thanks in advance

alexforencich commented 7 years ago

Can you connect directly and send commands like this?

instr = usbtmc.Instrument('USB::5784::2103::009000000571::INSTR')
print(instr.ask("*IDN?"))

The only thing that I can think of is the power supply may not implement the clear command correctly.

spsmspsm commented 7 years ago

Hi,

Thanks for your answer, this is what I get. To me this looks like an overflow when handling a response

Thanks in advance

import usbtmc instr = usbtmc.Instrument('USB::5784::2103::009000000571::INSTR') print(instr.ask("*IDN?")) Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python3.5/dist-packages/python_usbtmc-0.8-py3.5.egg/usbtmc/usbtmc.py", line 629, in ask File "/usr/local/lib/python3.5/dist-packages/python_usbtmc-0.8-py3.5.egg/usbtmc/usbtmc.py", line 609, in write File "/usr/local/lib/python3.5/dist-packages/python_usbtmc-0.8-py3.5.egg/usbtmc/usbtmc.py", line 475, in write_raw File "/usr/local/lib/python3.5/dist-packages/python_usbtmc-0.8-py3.5.egg/usbtmc/usbtmc.py", line 349, in open File "/usr/local/lib/python3.5/dist-packages/python_usbtmc-0.8-py3.5.egg/usbtmc/usbtmc.py", line 699, in clear File "/usr/local/lib/python3.5/dist-packages/usb/core.py", line 1043, in ctrl_transfer self.__get_timeout(timeout)) File "/usr/local/lib/python3.5/dist-packages/usb/backend/libusb1.py", line 883, in ctrl_transfer timeout)) File "/usr/local/lib/python3.5/dist-packages/usb/backend/libusb1.py", line 595, in _check raise USBError(_strerror(ret), ret, _libusb_errno[ret]) usb.core.USBError: [Errno 75] Overflow

On Thu, Aug 10, 2017 at 12:12 AM, Alex Forencich notifications@github.com wrote:

Can you connect directly and send commands like this?

instr = usbtmc.Instrument('USB::5784::2103::009000000571::INSTR') print(instr.ask("*IDN?"))

The only thing that I can think of is the power supply may not implement the clear command correctly.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/python-ivi/python-usbtmc/issues/34#issuecomment-321395874, or mute the thread https://github.com/notifications/unsubscribe-auth/AcxqLS58xHSmd_dECgML1JbxsWBfDL7xks5sWi7MgaJpZM4OYA1g .

spsmspsm commented 7 years ago

I tried some modification to the libusb library to get a bit further, but something else must be wrong. I have marked my modifications in BOLD. Basically, the overflow happens when the low level routines check the length field, increasing the data from 0x0001 into [0x0, 0x1], or incresing the length by 1 removes the first overflow, but then the failure occurs when waiting for the response to the IDN command. Basically we get a timeout.

@methodtrace(_logger) def ctrl_transfer(self, dev_handle, bmRequestType, bRequest, wValue, wIndex, data, timeout): addr, length = data.buffer_info() length *= data.itemsize

0 0 CTRL <usb.backend.libusb1._LibUSB object at 0x7f697030d0b8> <usb.backend.libusb1._DeviceHandle object at 0x7f697030d518> 128 6 768 0 array('B', [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) 1000 CTRL a 18822416 254 4 4 CTRL <usb.backend.libusb1._LibUSB object at 0x7f697030d0b8> <usb.backend.libusb1._DeviceHandle object at 0x7f697030d518> 128 6 771 1033 array('B', [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) 1000 CTRL a 18966592 255 26 26 0 0 0 0 0 0 0 0 CTRL <usb.backend.libusb1._LibUSB object at 0x7f697030d0b8> <usb.backend.libusb1._DeviceHandle object at 0x7f697030d518> 161 5 0 0 array('B', [0]) 5000 CTRL a 18691216 1 2 2 CTRL <usb.backend.libusb1._LibUSB object at 0x7f697030d0b8> <usb.backend.libusb1._DeviceHandle object at 0x7f697030d518> 161 6 0 0 array('B', [0, 0]) 5000 CTRL a 18691216 2 2 2 0 CTRL <usb.backend.libusb1._LibUSB object at 0x7f697030d0b8> <usb.backend.libusb1._DeviceHandle object at 0x7f697030d518> 161 7 0 0 array('B', [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) 5000 CTRL a 18630384 24 24 24 0 0 0 -7 CTRL <usb.backend.libusb1._LibUSB object at 0x7f697030d0b8> <usb.backend.libusb1._DeviceHandle object at 0x7f697030d518> 162 1 1 2 array('B', [0, 0]) 5000 CTRL a 18691280 2 2 2 Traceback (most recent call last): File "./testusb.py", line 5, in print(instr.ask("*IDN?")) File "/usr/local/lib/python3.5/dist-packages/python_usbtmc-0.8-py3.5.egg/usbtmc/usbtmc.py", line 629, in ask

On Fri, Aug 11, 2017 at 10:21 AM, Santiago Palomino Sanchez-Manjavacas < spssps@gmail.com> wrote:

Hi,

Thanks for your answer, this is what I get. To me this looks like an overflow when handling a response

Thanks in advance

import usbtmc instr = usbtmc.Instrument('USB::5784::2103::009000000571::INSTR') print(instr.ask("*IDN?")) Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python3.5/dist-packages/python_usbtmc-0.8-py3.5.egg/usbtmc/usbtmc.py", line 629, in ask File "/usr/local/lib/python3.5/dist-packages/python_usbtmc-0.8-py3.5.egg/usbtmc/usbtmc.py", line 609, in write File "/usr/local/lib/python3.5/dist-packages/python_usbtmc-0.8-py3.5.egg/usbtmc/usbtmc.py", line 475, in write_raw File "/usr/local/lib/python3.5/dist-packages/python_usbtmc-0.8-py3.5.egg/usbtmc/usbtmc.py", line 349, in open File "/usr/local/lib/python3.5/dist-packages/python_usbtmc-0.8-py3.5.egg/usbtmc/usbtmc.py", line 699, in clear File "/usr/local/lib/python3.5/dist-packages/usb/core.py", line 1043, in ctrl_transfer self.__get_timeout(timeout)) File "/usr/local/lib/python3.5/dist-packages/usb/backend/libusb1.py", line 883, in ctrl_transfer timeout)) File "/usr/local/lib/python3.5/dist-packages/usb/backend/libusb1.py", line 595, in _check raise USBError(_strerror(ret), ret, _libusb_errno[ret]) usb.core.USBError: [Errno 75] Overflow

On Thu, Aug 10, 2017 at 12:12 AM, Alex Forencich <notifications@github.com

wrote:

Can you connect directly and send commands like this?

instr = usbtmc.Instrument('USB::5784::2103::009000000571::INSTR') print(instr.ask("*IDN?"))

The only thing that I can think of is the power supply may not implement the clear command correctly.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/python-ivi/python-usbtmc/issues/34#issuecomment-321395874, or mute the thread https://github.com/notifications/unsubscribe-auth/AcxqLS58xHSmd_dECgML1JbxsWBfDL7xks5sWi7MgaJpZM4OYA1g .