Skip to content

Commit f0d39d3

Browse files
committed
Protect dictionary access in log_indState
1 parent a4835d0 commit f0d39d3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/main/python/main/ayab/engine/control.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,13 +186,13 @@ def __log_indState(self, msg: bytes) -> None:
186186
state = msg[2]
187187
hallLeft = struct.unpack(">H", msg[3:5])[0]
188188
hallRight = struct.unpack(">H", msg[5:7])[0]
189-
carriage = carriageMap[msg[7]]
189+
carriage = carriageMap.get(msg[7], f"0x{msg[7]:02x}?")
190190
position = msg[8]
191-
direction = directionMap[msg[9]]
191+
direction = directionMap.get(msg[9], f"0x{msg[9]:02x}?")
192192

193193
try: # AyabAsync supplies additional parameters
194-
hallActive = machineSideMap[msg[10]]
195-
beltShift = beltShiftMap[msg[11]]
194+
hallActive = machineSideMap.get(msg[10], f"0x{msg[10]:02x}?")
195+
beltShift = beltShiftMap.get(msg[11], f"0x{msg[11]:02x}?")
196196
self.logger.info(
197197
f"IndState: {error:1d} {state:1d} {position:3d}"
198198
f" {carriage:5s} ({beltShift:11s},{direction:5s})"

0 commit comments

Comments
 (0)