Skip to content

Fix #500: [BUG]: TSP devices don't check for a write_termination cha#552

Open
suportly wants to merge 1 commit intotektronix:mainfrom
suportly:fix/issue-500
Open

Fix #500: [BUG]: TSP devices don't check for a write_termination cha#552
suportly wants to merge 1 commit intotektronix:mainfrom
suportly:fix/issue-500

Conversation

@suportly
Copy link

@suportly suportly commented Feb 22, 2026

Summary

Addresses: #500

This PR addresses the issue: [BUG]: TSP devices don't check for a write_termination character when loading a script

Analysis

  • Solvability: likely_solvable (confidence: 75%)
  • Complexity: medium
  • Reasoning: The issue has a clear bug description and reproduction steps showing that load_script() doesn't validate write length against the 1000-character limit before adding the write_termination character. The fix likely involves checking script length and splitting into multiple writes if needed, but requires understanding the codebase structure, TSP device protocol details, and existing script-loading implementation to implement correctly.

Changes

src/tm_devices/driver_mixins/device_control/tsp_control.py |  7 +++++--
 tests/sim_devices/smu/smu2601b.yaml                        | 10 ++++++++--
 2 files changed, 13 insertions(+), 4 deletions(-)

Test Results

============================= test session starts ==============================
platform linux -- Python 3.11.11, pytest-9.0.2, pluggy-1.6.0 -- /home/alairjt/.pyenv/versions/3.11.11/bin/python
cachedir: .pytest_cache
rootdir: /tmp/issue-resolver-workspaces/tektronix-tm_devices-b101923d6667
configfile: pyproject.toml
plugins: django-4.9.0, mock-3.14.1, timeout-2.4.0, Faker-38.0.0, cov-6.0.0, asyncio-1.3.0, bdd-8.1.0, anyio-4.10.0, xdist-3.8.0, order-1.3.0
asyncio: mode=Mode.STRICT, debug=False, asyncio_default_fixture_loop_scope=None, asyncio_default_test_loop_scope=function
collecting ... collected 782 items

tests/test_abstract_device_expect_esr.py::test_expect_esr_param_just_esr_arg PASSED [  0%]
tests/test_afgs.py::test_afg3k PASSED                                    [  0%]
tests/test_afgs.py::test_afg31k PASSED                                   [  0%]
tests/test_alias_dict.py::test_alias_dict PASSED                         [  0%]
tests/test_all_device_drivers.py::test_device_driver[AFG-AFG3051-HOSTNAME-None-None-None] PASSED [  0%]
tests/test_all_device_drivers.py::test_device_driver[AFG-AFG3022B-HOSTNAME-None-None-None] PASSED [  0%]
tests/test_all_device_drivers.py::test_device_driver[AFG-AFG3252C-HOSTNAME-10001-SOCKET-None] PASSED [  0%]
tests/test_all_device_drivers.py::test_device_driver[AFG-AFG31021-HOSTNAME-None-None-None] PASSED [  1%]
tests/test_all_device_drivers.py::test_device_driver[AWG-AWG5200OPT50-HOSTNAME-None-None-None] PASSED [  1%]
tests/test_all_device_drivers.py::test_device_driver[AWG-AWG5012-HOSTNAME-None-None-None] PASSED [  1%]
tests/test_all_device_drivers.py::test_device_driver[AWG-AWG5002B-HOSTNAME-None-None-None] PASSED [  1%]
tests/test_all_device_drivers.py::test_device_driver[AWG-AWG5012C-HOSTNAME-None-None-None] PASSED [  1%]
tests/test_all_device_drivers.py::test_device_driver[AWG-AWG7051OPT01-HOSTNAME-None-None-None] PASSED [  1%]
tests/test_all_device_drivers.py::test_device_driver[AWG-AWG7062BOPT02-HOSTNAME-None-None-None] P
... (truncated)

Generated by issue-resolver | Cost: $1.27

…imit

TSP devices have a max write of 1000 characters before a write_termination
must exist. load_script() previously sent the entire script body in a single
write call, which could exceed this limit for large scripts. Now each line
of the script is written separately, ensuring a write_termination character
is sent before the limit is exceeded.

Addresses tektronix#500

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@suportly suportly requested a review from a team as a code owner February 22, 2026 21:42
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@tek-githubbot-1010 tek-githubbot-1010 requested a review from a team February 22, 2026 21:42
@nfelt14
Copy link
Collaborator

nfelt14 commented Feb 23, 2026

@suportly, can you sign the CLA?

self.write(f"loadscript {script_name}\n{script_body}\nendscript")
# Load the script, writing each line separately to avoid exceeding the
# 1000-character write limit of TSP devices.
script_lines = [f"loadscript {script_name}", *script_body.splitlines(), "endscript"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically this still isn't accessing the write termination character from the visa connection. and it would be better to split it up by character count in case that termination character isn't a newline, which can happen with hislip.

@nfelt14
Copy link
Collaborator

nfelt14 commented Feb 24, 2026

@alairjt, is this your PR?

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.

5 participants