pyvisa / pyvisa-sim

A PyVISA backend that simulates a large part of the "Virtual Instrument Software Architecture" (VISA_)
https://pyvisa-sim.readthedocs.io/en/latest/
MIT License
69 stars 39 forks source link

Fix `SimVisaLibrary.read` violating `viRead` success code specification #98

Closed gschaffner closed 2 weeks ago

gschaffner commented 5 months ago

hi! this fixes #45.

i believe this implementation is spec. compliant, with one possible exception: there's a case that the spec. doesn't seem to state what should happen in.

Rule 6.1.7 states that when using ASRL with VI_ATTR_ASRL_END_IN = VI_ASRL_END_TERMCHAR, when a termination character is read it should get treated as having an END indicator.

as far as I can tell, however, the spec. does not state what should happen when using ASRL with VI_ATTR_ASRL_END_IN = VI_ASRL_END_LAST_BIT and a character arrives with the matching bit set. should it get treated as END or should it get treated as a termination character? the status code depends on which it gets treated as.

since the only three cases for VI_ATTR_ASRL_END_IN are VI_ASRL_END_NONE (uninteresting), VI_ASRL_END_TERMCHAR, and VI_ASRL_END_LAST_BIT and since Rule 6.1.7 explicitly states that VI_ASRL_END_TERMCHAR causes the character to get treated as having an END indicator, not as a termination character, it seemed to me that it is more more appropriate for VI_ASRL_END_LAST_BIT to also cause the character to get treated as having an END.

either way, this fixes #45 though.

codecov[bot] commented 2 weeks ago

Codecov Report

Attention: Patch coverage is 86.36364% with 6 lines in your changes missing coverage. Please review.

Project coverage is 86.67%. Comparing base (9bed424) to head (bd09835). Report is 14 commits behind head on main.

Files Patch % Lines
pyvisa_sim/sessions/session.py 77.77% 2 Missing and 4 partials :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #98 +/- ## ========================================== + Coverage 86.00% 86.67% +0.66% ========================================== Files 18 18 Lines 1072 1058 -14 Branches 159 156 -3 ========================================== - Hits 922 917 -5 + Misses 115 106 -9 Partials 35 35 ``` | [Flag](https://app.codecov.io/gh/pyvisa/pyvisa-sim/pull/98/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pyvisa) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/pyvisa/pyvisa-sim/pull/98/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pyvisa) | `86.67% <86.36%> (+0.66%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pyvisa#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

MatthieuDartiailh commented 2 weeks ago

Thanks @gschaffner