From 79fd0912236cc82a73c1bbaae8c417384d437db6 Mon Sep 17 00:00:00 2001 From: jonyscathe Date: Mon, 9 Oct 2023 18:29:40 +1100 Subject: [PATCH] fix: Handle null term char (#394) * fix: Handle null term char For tcpip connection, handle when termination char is \0 rather than \n or \r. * Add to changelog --------- Co-authored-by: Matthieu Dartiailh --- CHANGES | 3 ++- pyvisa_py/tcpip.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 32bd08da..c2b3ee42 100644 --- a/CHANGES +++ b/CHANGES @@ -7,7 +7,8 @@ PyVISA-py Changelog - addd URL-support to ASLR devices PR #386 - add support for GPIB secondary addresses - fix missing sock.close() in rpc _connect() -- fix HiSLIP message tracking after read timeout #376 +- fix HiSLIP message tracking after read timeout PR #376 +- handle read_termination of null in tcipip PR #394 0.7.0 (05/05/2023) ------------------ diff --git a/pyvisa_py/tcpip.py b/pyvisa_py/tcpip.py index ee153fae..6a6d04dd 100644 --- a/pyvisa_py/tcpip.py +++ b/pyvisa_py/tcpip.py @@ -1146,7 +1146,7 @@ def read(self, count: int) -> Tuple[bytes, StatusCode]: chunk_length = self.max_recv_size term_char, _ = self.get_attribute(ResourceAttribute.termchar) - term_byte = common.int_to_byte(term_char) if term_char else b"" + term_byte = common.int_to_byte(term_char) if term_char is not None else b"" term_char_en, _ = self.get_attribute(ResourceAttribute.termchar_enabled) suppress_end_en, _ = self.get_attribute(ResourceAttribute.suppress_end_enabled)