8000 Add support for extended block lengths by spevs · Pull Request #914 · pyvisa/pyvisa · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add support for extended block lengths #914

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

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

spevs
Copy link
@spevs spevs commented May 23, 2025

This PR adds the following:

  • parse_ieee_block_header now supports decoding blocks ≥ 1 GB using hexadecimal length digit (Tektronix/LeCroy)
  • New function parse_rs_block_header supports decoding blocks ≥ 1 GB using parentheses-delimited length (Rohde & Schwarz)
  • New header_fmt = "rs" option added to read/query_binary_values(). Internally this first calls the function parse_ieee_or_rs_block_header, which detects whether the block length begins with a parentheses and then calls the ieee or rs parser as appropriate. This implementation is used because R&S only uses this format when the block length exceeds 1 GB, so it's best to use automatic detection rather than need to have the user explicitly know whether it is using the parentheses format or not
  • Exposes the length_before_block and raise_on_late_block options to the user interface of read/query_binary_values(), to allow user to set these values. Previously these were not accessible by the user, and always set to 25 and False. Some Tektronix scopes can return trace metadata in ASCII in front of the block data (before the block header) so a late block header >25 bytes can be expected, but previously it will always raise a warning :
UserWarning: The beginning of the block has been found at 156 which is an unexpectedly large value. The actual block may have been missing a beginning marker but the block contained one:
bytearray(b'1;8;BINARY;RI;MSB;"Ch1, DC coupling, 1.000V/div, 200.0us/div, 400000 points, Sample mode";1000;Y;"s";5.0000E-9;0.0000;124880;"V";40.0000E-3;1.0000;0.0000;1;#41000@AA?@?A?@@AB?A@C@A@')

In future it will be useful to add some way of retrieving this message in front of the block header (currently it is thrown away) but that is not included in this PR.

As a note, since the header_fmt = rs option in this implementation will interpret both IEEE (including the hex digit extension) and RS formatted blocks, it is somewhat "universal" for definite-length blocks, but doesn't detect indefinite length blocks if they happen to start with "(". The R&S format is only used for definite length blocks so I didn't think this would be a concern. But the user should be careful not to specify header_fmt = rs if an indefinite block is expected.

For the hex extension, I added a check to make sure the block length makes sense if the digit is 0xA to detect if an HP block is being decoded with the IEEE parser (the block length should be much more than 64K if there are 0xA = 10 digits, if it's not then it must have been an HP block, and an exception is raised with a descriptive message). But I don't have a way of testing this since I don't have any instruments that return blocks in HP format.

I tested that the R&S block decoding works, and the regular IEEE block decoding also still works.

  • Closes Support for extended block lengths #911
  • Executed ruff check . && ruff format -c . --check with no errors
  • The change is fully covered by automated unit tests
  • Documented in docs/ as appropriate
  • Added an entry to the CHANGES file

@spevs
Copy link
Author
spevs commented May 24, 2025

Initial PR also broke IEEE block writes, which I'd forgotten I modified in the beginning. I added a new commit that fixes and added support for the header length going into hexadecimal when block is ≥1 GB for block writes. Tested normal functionality works by uploading an arb to my waveform generator, but I don't have anything with enough memory to test the hexadecimal digit.

@spevs
Copy link
Author
spevs commented May 31, 2025

I've added support for writes in the R&S format using header_fmt = 'rs'.

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.

Support for extended block lengths
1 participant
0