haata / ugsimple-usb-gpib

Python libusb UGSimple GPIB Driver
GNU General Public License v3.0
13 stars 4 forks source link

Reading more than one value fails #1

Open dretay opened 9 years ago

dretay commented 9 years ago

Hey Haata,

Thanks for putting in the time to get this project off the ground! I hated having to keep a windows vm around to run lab scripts!

One thing i've noticed is that I don't seem to be able to read more than one value back on a single device. After the first value is read the next value comes back as "None" and crashes the app. I added some logic at GPIB.py:290:

    if not byteData:
        return None

to prevent the app from dying, but that just results in output that looks like this:

drew@drew-CM5571:~/src/ugsimple-usb-gpib$ python3 example.py b'NDCV+000.0846E-3\r' ERROR: '0x 3' does not match expected command '0x 3 ERROR: '0x44' does not match expected command '0x44 ERROR: '0x 3' does not match expected command '0x 3 ERROR: '0x44' does not match expected command '0x44 ERROR: '0x14' does not match expected command '0x14 ERROR: '0x44' does not match expected command '0x44 ERROR: '0x56' does not match expected command '0x56 ERROR: '0x30' does not match expected command '0x30 ERROR: '0x30' does not match expected command '0x30 ERROR: '0x30' does not match expected command '0x30 ERROR: '0x34' does not match expected command '0x34 ERROR: '0x45' does not match expected command '0x45 Traceback (most recent call last):

The first line is a correct reading from my multimeter, and the subsequent readings all look like malformed messages? When using the UGSimple libraries I am able do multiple reads without issue.

I'm not very familiar with pyusb, but is it possible some of these commands are also valid?

haata commented 9 years ago

Haha, not a problem. I've noticed some issues with my Keithley 2001 (SCPI command set) that I haven't been able to make work yet. It seems like I haven't gotten all the state out of the UG Simple device.

I got a basic spec from LQ Electronics (which is where most of the code is based off of). However, I've had to resort to using a USB Traffic Analyzer (http://desowin.org/usbpcap/ works well) to getting things like querying all the devices on the bus. Linux is easy (as usual), https://wiki.wireshark.org/CaptureSetup/USB.

Would you mind getting a .pcap trace of the working and non-working commands? This would help me immensely in debugging.

As far as pyusb goes. It's basically libusb, which is pretty straight-forward to use. I haven't had any issues on the USB side. I'm almost certain I'm doing something incorrectly when formatting the read/write commands to the UGSimple adapter.

dretay commented 9 years ago

Awesome I'll try to get that going this weekend and report back!

dretay commented 9 years ago

Here are two pcap dumps:

"one_shot_dac" is the result of me polling for live values from the multimeter's dac. "buffered_values" is the result of taking 200 readings and storing them in the multimeter's memory, then reading them out one at a time.

one_shot_dac_values pcap buffered_values pcap