From 634e5d0d0647d793b6255a6ebd5bb8fc05d3f509 Mon Sep 17 00:00:00 2001 From: Charles Titus Date: Mon, 19 Feb 2024 13:31:21 -0500 Subject: [PATCH 1/2] Byte order fix added to EpicsSignalBase --- ophyd/signal.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ophyd/signal.py b/ophyd/signal.py index f01180dbd..0cb437506 100644 --- a/ophyd/signal.py +++ b/ophyd/signal.py @@ -915,13 +915,14 @@ def __init__( timeout=DEFAULT_TIMEOUT, write_timeout=DEFAULT_WRITE_TIMEOUT, connection_timeout=DEFAULT_CONNECTION_TIMEOUT, + fix_byteorder=True, **kwargs, ): self._metadata_lock = threading.RLock() self._read_pv = None self._read_pvname = read_pv self._string = bool(string) - + self._fixbyteorder = fix_byteorder self._signal_is_ready = threading.Event() self._first_connection = True @@ -1422,6 +1423,8 @@ def _fix_type(self, value): "Cast the given value according to the data type of this EpicsSignal" if self._string: value = waveform_to_string(value) + if self._fixbyteorder and isinstance(value, np.ndarray) and value.dtype.byteorder == ">": + value = value.byteswap().newbyteorder() return value From 7224881ccf1790c1c8db21acc7810670683ed05f Mon Sep 17 00:00:00 2001 From: Jamie Date: Wed, 10 Apr 2024 13:32:09 -0400 Subject: [PATCH 2/2] STY: Fix lint issue --- ophyd/signal.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ophyd/signal.py b/ophyd/signal.py index 0cb437506..c68e66608 100644 --- a/ophyd/signal.py +++ b/ophyd/signal.py @@ -1423,7 +1423,11 @@ def _fix_type(self, value): "Cast the given value according to the data type of this EpicsSignal" if self._string: value = waveform_to_string(value) - if self._fixbyteorder and isinstance(value, np.ndarray) and value.dtype.byteorder == ">": + if ( + self._fixbyteorder + and isinstance(value, np.ndarray) + and value.dtype.byteorder == ">" + ): value = value.byteswap().newbyteorder() return value