-
Notifications
You must be signed in to change notification settings - Fork 30
Support of USB bind identification for iseq power supplies #235
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,7 +9,7 @@ | |
| import ruamel.yaml | ||
|
|
||
|
|
||
| def query_identification(rm, resource, baud_rate, read_termination=None, write_termination=None, timeout=1000 * 5): | ||
| def query_identification(rm, resource, baud_rate, read_termination=None, write_termination=None, timeout=1000 * 5, indentifer_cmd="*IDN?", read_after_query=False): | ||
| """ | ||
| Queries the identification of the instrument connected via USB. | ||
|
|
||
|
|
@@ -31,12 +31,16 @@ def query_identification(rm, resource, baud_rate, read_termination=None, write_t | |
| inst.read_termination = read_termination | ||
| inst.write_termination = write_termination | ||
| try: | ||
| reply = inst.query("*IDN?", delay=0.1) | ||
| reply = inst.query(indentifer_cmd, delay=0.1) | ||
| except pyvisa.VisaIOError: | ||
| # This retries the query a second time, since some devices do not answer the first time. | ||
| # If a second exception arrises, it will be handled in calling function. | ||
| reply = inst.query("*IDN?", delay=0.1) | ||
| return reply | ||
| reply = inst.query(indentifer_cmd, delay=0.1) | ||
|
|
||
| if read_after_query: | ||
| return inst.read() | ||
| else: | ||
| return reply | ||
|
Comment on lines
+40
to
+43
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this needed?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because the SHQ 122m returns as query response the command string as check if the command was executed successfully. To get the return value of an command (or in this case the identification string) one has to additionally perform a read operation. |
||
|
|
||
|
|
||
| def find_usb_binds(rm, log, | ||
|
|
@@ -105,7 +109,10 @@ def find_usb_binds(rm, log, | |
| log.debug(f"Found memorized bind {res}") | ||
| result = memorized_binds[res] | ||
| else: | ||
| result = query_identification(rm, res, instrument['baud_rate'], instrument['read_termination'], instrument['write_termination'], timeout=timeout) | ||
| if instrument["type"].lower() == "iseg_hv": | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe make a global "devices_with_non_default_values" dict, so that it is easier to potentially add more devices there instead of blowing up an
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good idea, will do! |
||
| result = query_identification(rm, res, instrument['baud_rate'], instrument['read_termination'], instrument['write_termination'], timeout=timeout, indentifer_cmd="#", read_after_query=True) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same typo as above |
||
| else: | ||
| result = query_identification(rm, res, instrument['baud_rate'], instrument['read_termination'], instrument['write_termination'], timeout=timeout) | ||
|
|
||
| memorized_binds.append({res, result}) | ||
|
|
||
|
|
@@ -228,6 +235,8 @@ def modify_basil_config(conf, log, skip_binds=[], save_modified=None): | |
| port = None | ||
|
|
||
| instruments.append({ | ||
| "name": tf["name"], | ||
| "type": "", # Standard instruments with *IQN? command | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is happening here exactly? Is this a way to define different devices with non-
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is done to identify serial transfer layers which uses implemented non- TL;DR: The serial transfer layer does not know if it is used for e.g. an SHQ 122M. Therefore this part is needed to identify an instrument correctly. |
||
| "identification": instrument, | ||
| "baud_rate": baud_rate, | ||
| "read_termination": read_termination, | ||
|
|
@@ -236,6 +245,13 @@ def modify_basil_config(conf, log, skip_binds=[], save_modified=None): | |
| }) | ||
|
|
||
| insts_idx_map[instrument.lower().strip()] = i | ||
|
|
||
| for hw_driver in conf["hw_drivers"]: | ||
| interface = hw_driver["interface"] | ||
| for instrument in instruments: | ||
| if instrument["name"].lower().strip() == interface.lower().strip(): | ||
| instrument["type"] = hw_driver["type"].lower() | ||
| break | ||
|
|
||
| found_binds = find_usb_binds(rm, log=log, instruments=instruments, binds_to_skip=skip_binds) | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in
indentifier