Skip to content

Commit

Permalink
Usb attr fixes (#399)
Browse files Browse the repository at this point in the history
* usb: add missing attributes to usb resources

* update pyproject.toml and cis

* usb: fix silly mistake

* usb: more fixes

* update CHANGES
  • Loading branch information
MatthieuDartiailh authored Oct 26, 2023
1 parent a922159 commit 37c0362
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
Expand Down
3 changes: 2 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ PyVISA-py Changelog
0.7.1 (unreleased)
------------------

- addd URL-support to ASLR devices PR #386
- add URL-support to ASLR devices PR #386
- add support for GPIB secondary addresses
- fix missing sock.close() in rpc _connect()
- Adjusted how `iter_bytes` works to be more accurate to the VISA spec and removed
it from the `serial` module (it can still be found in `common`)
- fix HiSLIP message tracking after read timeout PR #376
- handle read_termination of null in tcipip PR #394
- fix tcpip keepalive PR #396
- store more attributes for USB resources PR #399

0.7.0 (05/05/2023)
------------------
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
dependencies = [
"pyvisa>=1.13.0",
"typing_extensions",
"importlib-metadata; python_version<'3.8'",
]
dynamic=["version"]

Expand Down
26 changes: 22 additions & 4 deletions pyvisa_py/usb.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,31 @@ def after_parsing(self) -> None:
self.parsed.serial_number,
)

for name in ("SEND_END_EN", "SUPPRESS_END_EN", "TERMCHAR", "TERMCHAR_EN"):
self.attrs.update(
{
ResourceAttribute.manufacturer_id: int(self.parsed.manufacturer_id, 0),
ResourceAttribute.model_code: int(self.parsed.model_code, 0),
ResourceAttribute.usb_serial_number: self.parsed.serial_number,
ResourceAttribute.usb_interface_number: int(
self.parsed.usb_interface_number
),
}
)

for name, attr in (
("SEND_END_EN", ResourceAttribute.send_end_enabled),
("SUPPRESS_END_EN", ResourceAttribute.suppress_end_enabled),
("TERMCHAR", ResourceAttribute.termchar),
("TERMCHAR_EN", ResourceAttribute.termchar_enabled),
):
attribute = getattr(constants, "VI_ATTR_" + name)
self.attrs[attribute] = attributes.AttributesByID[attribute].default
self.attrs[attr] = attributes.AttributesByID[attribute].default

# Force setting the timeout to get the proper value
attribute = constants.VI_ATTR_TMO_VALUE
self.set_attribute(attribute, attributes.AttributesByID[attribute].default)
self.set_attribute(
ResourceAttribute.timeout_value,
attributes.AttributesByID[attribute].default,
)

def _get_timeout(self, attribute: ResourceAttribute) -> Tuple[int, StatusCode]:
if self.interface:
Expand Down

0 comments on commit 37c0362

Please sign in to comment.