From 2ed1d1823bd36e382254bfe1e7c8b3fdbd41faf4 Mon Sep 17 00:00:00 2001 From: Jerry Needell Date: Thu, 27 Feb 2020 10:34:36 -0500 Subject: [PATCH] fix struct unpack issue --- adafruit_bluefruitspi.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/adafruit_bluefruitspi.py b/adafruit_bluefruitspi.py index 7e7a071..3f13ef5 100644 --- a/adafruit_bluefruitspi.py +++ b/adafruit_bluefruitspi.py @@ -179,7 +179,7 @@ def _cmd(self, cmd): # pylint: disable=too-many-branches spi.readinto(self._buf_rx) # Read the message envelope and contents - msgtype, rspid, rsplen = struct.unpack('>BHB', self._buf_rx) + msgtype, rspid, rsplen = struct.unpack('>BHB', self._buf_rx[0:4]) if rsplen >= 16: rsp += self._buf_rx[4:20] else: @@ -242,8 +242,7 @@ def command(self, string): raise RuntimeError("Error (id:{0})".format(hex(msgid))) if msgtype == _MSG_RESPONSE: return rsp - else: - raise RuntimeError("Unknown response (id:{0})".format(hex(msgid))) + raise RuntimeError("Unknown response (id:{0})".format(hex(msgid))) except RuntimeError as error: raise RuntimeError("AT command failure: " + repr(error))