pyvisa / pyvisa-sim

A PyVISA backend that simulates a large part of the "Virtual Instrument Software Architecture" (VISA_)
https://pyvisa-sim.readthedocs.io/en/latest/
MIT License
69 stars 39 forks source link

How to simulate instrument that returns data when inst.read() #38

Closed DavidLutton closed 8 years ago

DavidLutton commented 8 years ago

I have a HP 437B that when instrument.read() returns the measured power value that can be interpreted as a float.

I read the pyvisa-sim definitions guide and did not find where I could add a property that returns on a query-less .read()

My sim HP-437b.yaml and 437B-read.py to demonstrate how it currently works with the expected behaviour commented out on the last line

Can we add this behaviour when there is no query?

MatthieuDartiailh commented 8 years ago

Just to be sure : at any moment if you read the instrument buffer using instrument.read() you get the measured power, without sending any message first ?

So if you do :

instrument.write('*IDN?')
instrument.read() # you get the idn
instrument.read() # you get the measured power
instrument.read() # you get the power again 

you get the results suggested by the comments ?

DavidLutton commented 8 years ago

Yes typically, other than times where the write has not been processed by the instrument before the first read is occurring.

instrument.write('*IDN?')
instrument.read() # you get the measured power
instrument.read() # you get the idn
instrument.read() # you get the power again 
instrument.read() # you get the power again 
instrument.read() # you get the power again 
instrument.read() # you get the power again 

2591 * True copied data back out of spreadsheet and code at bottom of Gist

Delta between runs; yes I was saving the file inside the loop each time

MatthieuDartiailh commented 8 years ago

This a pretty unusual behavior and I do not think that pyvisa-sim currently supports it. (yet)

DavidLutton commented 8 years ago

Good news, tried again with the hardware Don't seem to get the order of response glitch, might of been in a menu when I encountered that

They do work the way I said but also they respond to instrument.query('?') with the measured power I read the 'HB-IP codes summery' list and '?' is not listed

Thanks for your help