Skip to content

Gpib enums#600

Closed
DavidCPlatt wants to merge 5 commits into
pyvisa:mainfrom
DavidCPlatt:gpib-enums
Closed

Gpib enums#600
DavidCPlatt wants to merge 5 commits into
pyvisa:mainfrom
DavidCPlatt:gpib-enums

Conversation

@DavidCPlatt

Copy link
Copy Markdown
Contributor

Clean up the GPIB code, by using symbolic constants (IntEnums) when calling the libgpib APIs, rather than bare integers.

Rather than trying to include the API constants directly out of gpib_ctypes (which would have introduced a strict dependency that doesn't seem to exist today) I copied and modified the constant definitions from that file, creating "gpib_constants.py". The new constant definitions take the form of an individual IntEnum class per API-call, with the class name corresponding to the API call (or the returned-value interpretation) and the class member names matching the names used in gpib_ctypes. This constants file is now imported by gpib.py.

In gpib.py, all of the bare-integer value uses (I think) are replaced by the corresponding symbol, and old commentary explaining the interpretation of the bare-integer values is removed as redundant.

Tested with my Xyphro adapter and HP2903B. No errors encountered.

This deserves a careful set of eyeball checks before merging! I have reviewed it a couple of times myself and think I've got all of the bare-integer-to-symbol correspondences correct, but you know how much an author's own code reviews are worth :-)

  • Closes # (insert issue number if relevant)
  • Executed black . && isort -c . && flake8 with no errors
  • The change is fully covered by automated unit tests
  • Documented in docs/ as appropriate
  • Added an entry to the CHANGES file

Dave Platt and others added 5 commits June 26, 2026 11:59
Add code in GPIBsession _get_attribute and _set_attribute to map
the TERMCHAR and TERMCHAR_EN attributes into the proper GPIB
configuration settings.

This allows GPIB reads to work correctly, when directed at
older GPIB devices which do not signal EOI at the end of their
talk output, but depend on EOS character matching.
Create a file of symbolic constants (IntEnum classes)
for the various libgpib interface calls.  Use these
symbols rather than hard-coded integers.  Remove
now-extraneous commentary about what the hard-coded
integers mean.
@codecov

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 77.88945% with 44 lines in your changes missing coverage. Please review.
✅ Project coverage is 41.02%. Comparing base (28b0e88) to head (499ca70).

Files with missing lines Patch % Lines
pyvisa_py/gpib.py 2.22% 44 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #600      +/-   ##
==========================================
+ Coverage   39.18%   41.02%   +1.83%     
==========================================
  Files          27       28       +1     
  Lines        5022     5175     +153     
  Branches      518      517       -1     
==========================================
+ Hits         1968     2123     +155     
+ Misses       3028     3026       -2     
  Partials       26       26              
Flag Coverage Δ
unittests 41.02% <77.88%> (+1.83%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@DavidCPlatt

Copy link
Copy Markdown
Contributor Author

Ugh. This seems to have picked up some unnecessary commits, from my local merges and rebases. I'm going to abandon it, and cherry-pick the change into a fresh tree.

@MatthieuDartiailh

Copy link
Copy Markdown
Member

Thanks for doing that !!!

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

Successfully merging this pull request may close these issues.

2 participants