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

Support partial usbtmc reads and request the size amount of bytes from the device #470

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

Conversation

Jimmyvandenbergh
Copy link
Contributor

@Jimmyvandenbergh Jimmyvandenbergh commented Nov 22, 2024

another update for reading the data back from the device. this enhances the PR #465

changes explained below:

  • req = BulkInMessage.build_array(self._btag, size, None) we want to request the amount of bytes from the device which user specifies. therefore the header may specify more bytes then in a single transaction wMaxPacketSize can be transmitted. the device may response with less bytes.
  • above is also needed when you want to support IEEE 488.2 arbitrary block reads. this normally will read 2 bytes # then your read the number of bytes from the device which holds the exact amount of bytes the data package may hold. this to claim memory on the host for large data packets. see below image:

image

  • resp = raw_read(self.usb_recv_ep.wMaxPacketSize) you may request wMaxPacketSize but the device may send less bytes than requested

  • fix the indentation of the received_message.extend(received_transfer[: response.transfer_size]) this should always remove the alignment bytes instead of only on EOM

  • updated the code to request x amount of wMaxPacketSize to be read instead of wMaxPacketSize this to improve readout speeds.

  • 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

…t IEEE 488.2 arbitrary block reads fixes the requested data to be send in the header instead of recv_chunk.
Copy link

codecov bot commented Nov 22, 2024

Codecov Report

Attention: Patch coverage is 0% with 16 lines in your changes missing coverage. Please review.

Project coverage is 24.42%. Comparing base (4a77dd0) to head (4286e56).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
pyvisa_py/protocols/usbtmc.py 0.00% 16 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #470      +/-   ##
==========================================
- Coverage   24.46%   24.42%   -0.04%     
==========================================
  Files          23       23              
  Lines        3487     3492       +5     
  Branches      398      400       +2     
==========================================
  Hits          853      853              
- Misses       2629     2634       +5     
  Partials        5        5              
Flag Coverage Δ
unittests 24.42% <0.00%> (-0.04%) ⬇️

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

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

@Jimmyvandenbergh
Copy link
Contributor Author

Speed performance for a command that send a large amount of data back:
backend:

  • NI-VISA: ~2.406 seconds
  • pyvisa-py small chunks: ~3.275 seconds current implementation in 0.7.3 (and pre large chunk implementation)
  • pyvisa-py large chunks: ~2.413 seconds

@Jimmyvandenbergh
Copy link
Contributor Author

I think, at least, following issues are impacted and should benefit from this PR.

  • this should solve issues when reading data from instruments occur after updating to 0.7.2 or later
  • reading binary data when data may be larger than 1 message or does not complete in the first read() (transfer size is not met) of the device

#472
#468
#463
#436
#422
#420
#414
#318

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.

1 participant