Skip to content

Commit

Permalink
[squash] make yapf happy
Browse files Browse the repository at this point in the history
  • Loading branch information
wsxrdv committed Dec 1, 2023
1 parent 3613802 commit 8c48d62
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions scaaml/capture/scope/lecroy/lecroy_communication.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,10 @@ def get_waveform(self, channel: LECROY_CHANNEL_NAME_T) -> LecroyWaveform:
return LecroyWaveform(raw_data)

@make_custom_exception
def query_binary_values(self, message: str, datatype="B", container=None) -> bytearray:
def query_binary_values(self,
message: str,
datatype="B",
container=None) -> bytearray:
"""Query binary data.
Args:
Expand All @@ -279,7 +282,6 @@ def query_binary_values(self, message: str, datatype="B", container=None) -> byt
# Receive and decode answer
return self._get_raw_response()


def _format_command(self, command: str) -> bytearray:
"""Method formatting leCroy command.
Expand All @@ -292,12 +294,11 @@ def _format_command(self, command: str) -> bytearray:
# Compute header for the current command, header:
# operation = DATA | EOI
command_header = pack(self._s_leCroyCommandHeader, 129, 1, 1, 0,
len(command))
len(command))

formatted_command = command_header + command.encode("ascii")
return formatted_command


def _get_raw_response(self) -> bytearray:
"""Get raw response from the socket.
Expand All @@ -313,11 +314,12 @@ def _get_raw_response(self) -> bytearray:
header += self._socket.recv(8 - len(header))

# Parse formated response
(operation,
header_version, # unused
sequence_number, # unused
spare, # unused
v_nbTotalBytes) = unpack(self._s_leCroyCommandHeader, header)
(
operation,
header_version, # unused
sequence_number, # unused
spare, # unused
v_nbTotalBytes) = unpack(self._s_leCroyCommandHeader, header)

# Delete unused values
del header_version
Expand All @@ -329,7 +331,8 @@ def _get_raw_response(self) -> bytearray:

# Loop until we get all data
while (len(buffer) < v_nbTotalBytes):
buffer += self._socket.recv(min(v_nbTotalBytes - len(buffer), 8_192))
buffer += self._socket.recv(
min(v_nbTotalBytes - len(buffer), 8_192))

# Accumulate final response
response += buffer
Expand Down

0 comments on commit 8c48d62

Please sign in to comment.