PyVISA-sim 0.1 is released

157 views
Skip to first unread message

Hernan Grecco

unread,
Feb 12, 2015, 12:57:58 PM2/12/15
to la...@googlegroups.com
Hi,

I have just released PyVISA-sim 0.1. PyVISA-sim is a backend for PyVISA. It allows you to simulate devices and therefore test your applications without having real instruments connected.

While there still a lot of features to add, this early release already allows you to:
- play around with a simulated device.
- write your own simulated device in YAML files. 
- simulated devices can include commands and properties which are automatically generated from the YAML file.
- Properties can have some basic validation rules.

Install it using:

    pip install -U pyvisa-sim


Alex Forencich

unread,
Feb 13, 2015, 3:03:31 AM2/13/15
to la...@googlegroups.com
Is pyvisa-sim supposed to include a collection of simulated instruments for testing purposes?  Or are the actual definitions supposed to be provided separately? 

Also, I have not looked at it in too much detail, but can it support multiple channels with a separate select command (as opposed to a prefix)?

Alex Forencich
--
You received this message because you are subscribed to the Google Groups "LabPy: Instrumentation in Python" group.
To unsubscribe from this group and stop receiving emails from it, send an email to labpy+un...@googlegroups.com.
To post to this group, send email to la...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/labpy/e7ed9800-03ce-45ea-a91b-4abde30aaae6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Matthieu Dartiailh

unread,
Feb 13, 2015, 4:21:58 AM2/13/15
to la...@googlegroups.com
The way to add channel is being discussed in https://github.com/hgrecco/pyvisa-sim/issues/9. This is definitively something that should be supported.
We could consider having a repo in lapby providing simulated instruments for testing purposes and use pyvisa-sim for the ones relying on the visa protocol. That is something we will have to discuss.

Matthieu Dartiailh

Hernan Grecco

unread,
Feb 13, 2015, 6:55:55 AM2/13/15
to Matthieu Dartiailh, la...@googlegroups.com
Hi Alex,

Regarding the simulated instruments, my idea is to provide a comprehensive set of instruments included with pyvisa-sim. We could include an ad-hoc repo in LabPy but I think it would be better for end users to bundle them.

It would be great if people start contributing devices. That is why I wanted to release pyvisa-sim soon so that people can contribute instruments before version 0.2 if they want.

It is very easy to create a definition file and the cool thing is that you can split the device definitions from the binding to resource names. That is why you could have definitions files bundled with pyvisa-sim and then allow people to write their own files just linking to them. (This is not explained yet in the docs)

Regarding the channels, it will come for version 0.2. Please use the tracker for specific suggestions.

cheers,

Hernán

--
You received this message because you are subscribed to the Google Groups "LabPy: Instrumentation in Python" group.
To unsubscribe from this group and stop receiving emails from it, send an email to labpy+unsubscribe@googlegroups.com.

To post to this group, send email to la...@googlegroups.com.

Alex Forencich

unread,
Feb 13, 2015, 6:01:42 PM2/13/15
to la...@googlegroups.com, m.dar...@gmail.com
I would love to contribute some devices, but at the moment it's not completely clear how they fit into the repo.  Can you provide some examples so there is something to build off of? 

Alex Forencich


On Friday, February 13, 2015 at 3:55:55 AM UTC-8, Hernan Grecco wrote:
Hi Alex,

Regarding the simulated instruments, my idea is to provide a comprehensive set of instruments included with pyvisa-sim. We could include an ad-hoc repo in LabPy but I think it would be better for end users to bundle them.

It would be great if people start contributing devices. That is why I wanted to release pyvisa-sim soon so that people can contribute instruments before version 0.2 if they want.

It is very easy to create a definition file and the cool thing is that you can split the device definitions from the binding to resource names. That is why you could have definitions files bundled with pyvisa-sim and then allow people to write their own files just linking to them. (This is not explained yet in the docs)

Regarding the channels, it will come for version 0.2. Please use the tracker for specific suggestions.

cheers,

Hernán

On Fri Feb 13 2015 at 6:21:59 AM Matthieu Dartiailh <m.dar...@gmail.com> wrote:
The way to add channel is being discussed in https://github.com/hgrecco/pyvisa-sim/issues/9. This is definitively something that should be supported.
We could consider having a repo in lapby providing simulated instruments for testing purposes and use pyvisa-sim for the ones relying on the visa protocol. That is something we will have to discuss.

Matthieu Dartiailh

--
You received this message because you are subscribed to the Google Groups "LabPy: Instrumentation in Python" group.
To unsubscribe from this group and stop receiving emails from it, send an email to labpy+un...@googlegroups.com.

Hernan Grecco

unread,
Feb 13, 2015, 6:26:24 PM2/13/15
to Alex Forencich, la...@googlegroups.com, m.dar...@gmail.com
Hi Alex,

It would be great if you can contribute! Not only instruments but I am sure that as soon as we start writing more of them, we will realize we miss some important aspects in the simulator architecture. There are things that we already know that we miss. For example channels, or and error register or how to send an ASRL BREAK among others. Discussion about implementing them will be appreciated.

You will find a description of the YAML file here: 


Please notice that a YAML file can contain one or more devices. So we could have one `agilent.yaml` with many instruments.

What is not yet described is how to bind the instruments that you define. But is very easy you just write in the file:

resources:
    <resource_name>:
        device: <device name>

Where <resource_name> is for example ASRL1::INSTR and <device_name> is the name of the device within the devices dictionary in the same file.

The cool thing is you an link things from different files. I will write about this in the docs and let you know.

The idea is to create a folder in `pyvisa-sim` called definitions and put all YAML files there.

best,

Hernan




Alex Forencich

unread,
Feb 13, 2015, 6:50:20 PM2/13/15
to la...@googlegroups.com
I see.  Well, I'm a guy that likes to work off of an example, so if you can just throw together a bit of example code for that stuff then I can see what I can do about implementing a few things.  I'm wondering if the best setup would be to have one file per instrument and a folder for each manufacturer, and then have files to aggregate everything.  Sort of like how it's done in python-ivi, except with the yaml files instead of python.  Also, is it possible to extend a simulated instrument and add/modify properties without copying over the whole definition?  This would be another very useful feature for supporting a whole series of similar instruments. 

One thing that might be interesting to add as well is a tool that lets you send the same command to two different instances and then compare the result.  This could be useful for verifying simulated instruments against real instruments.  pyvisa-sim can also be leveraged to write tests against drivers to make sure that they are sending the correct commands and then use something like travis-ci to test everything. 

Also, is there any reason not to move pyvisa et al. over to the new labpy group as well and keep all of this stuff under one roof?

Alex Forencich

Matthieu Dartiailh

unread,
Mar 24, 2015, 5:24:01 AM3/24/15
to la...@googlegroups.com
Hi all,

I have just released PyCLibrary 0.1.0. PyCLibrary is a C header parser and C binding generator. It simply parse the header file of the library you need to inter-operate with and can from there build a wrapper for you (for the time being using ctypes but other backends could be incorporated). That way you avoid copying manually all the constants and the function signatures.
It would be very handy for instruments using a DLL.

You can find the docs at http://pyclibrary.readthedocs.org/en/latest/ and install using pip.

Best

Matthieu Dartiailh
--
You received this message because you are subscribed to the Google Groups "LabPy: Instrumentation in Python" group.
To unsubscribe from this group and stop receiving emails from it, send an email to labpy+un...@googlegroups.com.
To post to this group, send email to la...@googlegroups.com.
Message has been deleted

Jeff Barnes

unread,
Mar 26, 2015, 1:28:37 PM3/26/15
to la...@googlegroups.com, m.dar...@gmail.com
Hi Alex,

I also work most efficiently when provided with even a very simple example. Here is what I came up with. One caveat, it doesn't quite work. Instead of getting back a mock idn string it reaches my (defined) errror handler in the yaml file. Anyhow with that in mind, here is my idea of a very simple example.

simple.yaml:
spec: "1.0"
devices:
  device 1:
    eom:
      ASRL INSTR:
        q: "\r\n"
        r: "\n"
    error: ERROR Query not found
    dialogues:
      - q: "?IDN"
        r: "SCPI,MOCK,VERSION_1.0"
resources:
  ASRL1::INSTR:
    device: device 1

simple_pyvisa.py:
import visa
# rm = visa.ResourceManager()
# Use PyVisa-SIM to mock out SCPI test instrument communications
rm = visa.ResourceManager("simple.yaml@sim")

print(rm)
resourceList = rm.list_resources()
if len(resourceList) == 0:
   print "No available resources"
else:
   print "Resource List:"
   for resource in resourceList:
      print "\t" + resource
   inst = rm.open_resource('ASRL1::INSTR', read_termination='\n')
   print(inst.query("*IDN?"))

And here is the output:

Resource Manager of Visa Library at simple.yaml
Resource List:
        ASRL1::INSTR
ERROR Query not found
 
With such a simple example I'm sure I"m making a simple mistake so if anyone can touch this up and make it into a working, simple example I'd really appreciate it and it will probably light a fire under me to expand this into something more useful.

Best Regards,

Jeff

Hernan Grecco

unread,
Mar 26, 2015, 1:59:57 PM3/26/15
to Jeff Barnes, la...@googlegroups.com, m.dar...@gmail.com
Hi Jeff,

From the first commit, there is an example provided with the package. See here


The error is because you specified the query as "?IDN" but you are querying "*IDN?"

Hernan

Reply all
Reply to author
Forward
0 new messages