Skip to content

Commit

Permalink
Merge pull request #35 from dedalgr/patch-11
Browse files Browse the repository at this point in the history
Fix:
  • Loading branch information
well-it-wasnt-me authored Jun 30, 2024
2 parents fd63907 + 18134ed commit 1acce95
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions sas.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,13 @@ def _send_command(

if crc_need:
buf_header.extend(Crc.calculate(bytes(buf_header)))
self.log.debug(buf_header)

self.connection.write([self.poll_address, self.address])

self.connection.flush()
self.connection.parity = serial.PARITY_SPACE
time.sleep(self.wait_for_wake_up)
self.close()
self.connection.parity = serial.PARITY_SPACE
self.open()
self.connection.write((buf_header[1:]))

except Exception as e:
Expand All @@ -202,7 +203,9 @@ def _send_command(
self.log.critical("no sas response %s" % (str(buf_header[1:])))
return None
else:
if int(binascii.hexlify(response)[2:4], 16) != buf_header[1]:
if not response:
raise NoSasConnection
elif int(binascii.hexlify(response)[2:4], 16) != buf_header[1]:
raise BadCommandIsRunning('response %s run %s' % (binascii.hexlify(response), binascii.hexlify(bytearray(buf_header))))

response = Crc.validate(response)
Expand Down

0 comments on commit 1acce95

Please sign in to comment.