Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: optionally permit topmost SCPI class NAME to emit :NAME instead of NAME + raw sketch #16

Open
jakobi opened this issue Feb 18, 2024 · 3 comments

Comments

@jakobi
Copy link

jakobi commented Feb 18, 2024

Use case: Owon HDS200 series scope meter.

In this SCPI dialect, normal commands and queries usually(?) start with a mandatory ":".

Currently INSTRUMENT.chan.("OFF") sends CHAN OFF to the device. For the Owon to not ignore command, it must begin with a colon: i.e. :CHAN OFF to turn off the signal generator channel.

As expected, INSTRUMENT.:chan("OFF") and variants make Python throw errors, while easy-scpi already properly injects colons deeper in the hierarchy: INSTRUMENT.foo.bar(42) translates to <>FOO<:>BAR 42 (<> marks the spots).

So my issue is just a way to add the missing first colon on (some?) sent commands.

Possible implementation for this:

In the invoking script, permit the use of some horribly long "unique" string such as REPLACEBYCOLON as prefix to <SCPI-CLASS-NAME>.

Then mangle the used top class name of the command before sending by substituting REPLACEBYCOLON with just a colon. A global prefix on sending will probably have to implement exceptions, as e.g. the Owon dialect and esp. the programming guide are a bit - hmmm - funny.

Maybe make REPLACEBYCOLON configurable for the caller, thus that on collision or via eval the user can can change it or turn it off for a bit..

Thx,
Peter

@bicarlsen
Copy link
Owner

I no longer work with SCPI machines, so won't implement it, but am happy to accept a PR.

@jakobi
Copy link
Author

jakobi commented Feb 22, 2024

So adding 2 ways to mangle the top class name: Above scheme, plus a black/whitelist, or maybe just an optionally mangling callback, with a usable predefined example callback using in-instance attributes for above scheme and some black/whitelist and maybe a regex based substitution?

Maje these attributes into the instance that needs mangling, and there's no need for on/off, as I use different instances for different devices. Say, a instance that to mangling for the OWON scopemeter and one without for say a RIGOL scope and a 3rd for talking to a KORAD power supply?

And I can also get a contrib directory (owon use requires using a slightly patched usb2hdi, as I only managed to get tcp sockets to work for it in pyvisa). So a timestamped copy of hid2tcp, with a pair of patches (one minimal, one to better cope with the OWON's sleep habbits, upto yet-to-code infrequent reconnecting attempts)?

I will require a bit of review, otherwise easy-scpi will end up with with a few shiny spots of syntactically correct PYTHON line noise (or whatever PERL's pet name is these days).

Sounds ok?

@bicarlsen
Copy link
Owner

I didn't understand most of what you described. From what I do understand though, you want a way to prefix calls with a colon.

I think it should be fairly simple to add an option on Property that will do this in call, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants