Very cool!
I was reminded that someone wrote a python interface to the UGSimple: https://github.com/haata/ugsimple-usb-gpib
I thought I'd see if I could get it working on windows.
Unfortunately, it seems that getting libusb to work from python on windows is a total nightmare (I'm a developer and I can't figure it out).
I literally just wasted all evening on this: https://github.com/pyusb/pyusb/issues/120#issuecomment-385225830
I think I fixed the python lib for UGSimple interface. I published the PR on the main project (
https://github.com/haata/ugsimple-usb-gpib/pull/7). The maintainer looks to be inactive on it (even though he's active on other projects) so not sure when it will get merged.
But here is the link to the branch on my fork if you want to clone it and use it:
https://github.com/sirmo/ugsimple-usb-gpib/tree/fixes1Basically I found two issues with it. Python's usb.core (at least on raspberry pi) is a bit flaky and it can silently time out.
The other issues is that the
read() method can desync from the USB buffer. The original code is pretty convoluted at least for me, I am really not sure what the original author was trying to accomplish with it. So instead of gutting all his code I just added a new method
ask().
Which handles both writing of the command to the instrument and reading the result. It even has error checking built in, so if flaky USB subsystem rears its ugly head it will check the result and re run the command.
You can do things like
ask(instrument_address, "some command?", method="retry", delimiter="\r\n") and it will retry until it gets a result which ends with "\r\n" (which is the case for my 3458a). This is the default behaviour so you don't have to specify method and delimiter if you want this.
Or you can do
ask(instrument_address, "some command?", method="quorum") and it will run 10 times by default and pick the result which returned most times. This is not useful for measurements (since those fluctuate) but I've used it for making sure my NVRAM backup from 3458a was correct.
Anyways, why UGSimple? Because it's $30. It works. I can wire half a dozen GPIB interfaces to a raspberry pi with a wifi adapter and have a whole rack of GPIB instruments controlled remotely via a REST interface. It's awesome.
p.s I also included a 3458a NVRAM backup script as an example. The original script was written for Prologix library which also has the
ask() method which is kind of the reason I added it to the UGSimple to make cross porting scripts between these popular GPIB interfaces easier.