Skip to content

Commit 8c19406

Browse files
committed
byteorder parameter must be positional in circuitpython/micropython
1 parent 77f1034 commit 8c19406

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

mmwave_presence.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,8 @@ def read(self):
242242

243243
# determine report mode
244244

245-
packet_len = int.from_bytes(self.port.read(2), byteorder='little')
246-
report_mode = int.from_bytes(self.port.read(1), byteorder='little')
245+
packet_len = int.from_bytes(self.port.read(2), "little")
246+
report_mode = int.from_bytes(self.port.read(1), "little")
247247

248248
# various mangled-read checks
249249
if packet_len == PACKET_LEN_BASIC:
@@ -274,7 +274,7 @@ def read(self):
274274
#print("End-of_Frame marker doesn't match.")
275275
continue
276276

277-
if packet[0].to_bytes() != PACKET_HEAD:
277+
if packet[0].to_bytes(1,"little") != PACKET_HEAD:
278278
#print(f"Packet head {packet[0]} isn't right.")
279279
continue
280280

@@ -302,11 +302,11 @@ def read(self):
302302
# byte -2: "tail" value of 55
303303
# byte -1: "calibration" value of 00
304304

305-
if packet[-2].to_bytes() != PACKET_TAIL:
305+
if packet[-2].to_bytes(1,"little") != PACKET_TAIL:
306306
#print(f"Invalid packet tail value.")
307307
continue
308308

309-
if packet[-1].to_bytes() != PACKET_CALIBRATION:
309+
if packet[-1].to_bytes(1,"little") != PACKET_CALIBRATION:
310310
#print(f"Invalid packet calibration value.")
311311
continue
312312

@@ -323,15 +323,15 @@ def read(self):
323323
# todo: use lower of MAX_LEGIT_DISTANCE and distance resolution * gate limit
324324

325325
if self.motion_detected:
326-
self.motion_target_cm = int.from_bytes(packet[2:4], byteorder='little')
326+
self.motion_target_cm = int.from_bytes(packet[2:4], "little")
327327
self.motion_energy = int(packet[4])
328328
if self.motion_target_cm > MAX_LEGIT_DISTANCE:
329329
continue
330330
if self.motion_energy > MAX_LEGIT_ENERGY:
331331
continue
332332

333333
if self.static_detected:
334-
self.static_target_cm = int.from_bytes(packet[5:7], byteorder='little')
334+
self.static_target_cm = int.from_bytes(packet[5:7], "little")
335335
self.static_energy = int(packet[7])
336336

337337
if self.static_target_cm > MAX_LEGIT_DISTANCE:
@@ -340,7 +340,7 @@ def read(self):
340340
continue
341341

342342
if target_state:
343-
self.detection_cm = int.from_bytes(packet[8:10], byteorder='little')
343+
self.detection_cm = int.from_bytes(packet[8:10], "little")
344344
if self.detection_cm > MAX_LEGIT_DISTANCE:
345345
continue
346346

@@ -422,7 +422,7 @@ def _send(self,command_data_bytes):
422422
#print("Didn't find response header.")
423423
continue
424424

425-
packet_len = int.from_bytes(self.port.read(2), byteorder='little')
425+
packet_len = int.from_bytes(self.port.read(2), "little")
426426

427427
# It would be more robust to check for the exact expected length
428428
# for each particular command, but gets clunky. So, at least make
@@ -512,7 +512,7 @@ def _scan_for_header(self,header):
512512
buffer.append(self.port.read(1))
513513
if not buffer[-1]: # timeout
514514
break
515-
if buffer == [x.to_bytes() for x in header]:
515+
if buffer == [x.to_bytes(1,"little") for x in header]:
516516
return True
517517
self.serial_failures += 1
518518
return False
@@ -584,7 +584,7 @@ def read_config(self):
584584

585585

586586
# then last 2 are little-endian presence timeout
587-
presence_timeout = int.from_bytes(result[22:], byteorder='little')
587+
presence_timeout = int.from_bytes(result[22:], "little")
588588
if presence_timeout > MAX_LEGIT_PRESENCE_TIMEOUT:
589589
continue
590590
self.presence_timeout = presence_timeout

0 commit comments

Comments
 (0)