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

Usb attr fixes #399

Merged
merged 5 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading