Skip to content

[BUG]: PyVisa attempts to decode as UTF-8 when pulling binary data via curve.query from DPO70KSX #447

@andrewhof

Description

@andrewhof

Description of the bug

I have a DPO77002SX scope, set with a binary data encoding. When I attempt to pull data from the scope via curve, it throws a UnicodeDecodeError.

Looking at the trace, it looks as if read with encoding is used for this command, where likely read_raw should be preferred.

Steps To Reproduce

dm = DeviceManager(verbose = True)
2025-06-03 13:29:19.878971 - Opening DeviceManager
scope : DPO70KSX = dm.add_scope(IPADDRESS)
2025-06-03 13:29:59.132655 - Creating Connection to SCOPE 1
2025-06-03 13:29:59.306620 - (SCOPE) Query >> '*IDN?'
2025-06-03 13:29:59.311661 - Response from '*IDN?' >> 'TEKTRONIX,DPO77002SX,B300040,CF:91.1CT FV:10.14.0 Build 15'
scope.commands.data.encdg.query()
2025-06-03 13:31:35.774415 - (SCOPE 1) Query >> 'DATa:ENCdg?'
2025-06-03 13:31:35.797447 - Response from 'DATa:ENCdg?' >> 'RIBINARY'
'RIBINARY'
data = scope.commands.curve.query()
2025-06-03 13:32:06.715141 - (SCOPE 1) Query >> 'CURVe?'
2025-06-03 13:32:06.812698 - UNCAUGHT EXCEPTION!!!
Traceback (most recent call last):
File "", line 1, in
File "C:\sw\automatedtest.venv\lib\site-packages\tm_devices\commands\helpers\scpi_commands.py", line 60, in query
return self._device.query(self._cmd_syntax + "?") # type: ignore[union-attr]
File "C:\sw\automatedtest.venv\lib\site-packages\tm_devices\driver_mixins\device_control\pi_control.py", line 347, in query
response = self._visa_resource.query(query).strip()
File "C:\sw\automatedtest.venv\lib\site-packages\pyvisa\resources\messagebased.py", line 690, in query
return self.read()
File "C:\sw\automatedtest.venv\lib\site-packages\pyvisa\resources\messagebased.py", line 519, in read
message = self._read_raw().decode(enco)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xef in position 12: invalid continuation byte

Environment Information

No response

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    SCPIStandard Commands for Programmable InstrumentsbugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions