Skip to content

Commit 11881a6

Browse files
authored
Enhance CRIProtocolParser with program list handling
Added program_list and program_list_lock to the CRIProtocolParser constructor. Updated parse_message method to handle FileList parameters.
1 parent b27eba5 commit 11881a6

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

cri_lib/cri_protocol_parser.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@
2525
class CRIProtocolParser:
2626
"""Class handling the parsing of CRI messages to the robot state."""
2727

28-
def __init__(self, robot_state: RobotState, robot_state_lock: Lock):
28+
def __init__(self, robot_state: RobotState, robot_state_lock: Lock, program_list : list, program_list_lock: Lock):
2929
self.robot_state = robot_state
3030
self.robot_state_lock = robot_state_lock
31+
self.program_list = program_list
32+
self.program_list_lock = program_list_lock
3133

3234
def parse_message(
3335
self, message: str
@@ -598,6 +600,13 @@ def _parse_info(self, parameters: list[str]) -> str | None:
598600
self.robot_state.motor_temps = temperatures
599601

600602
return "info_motortemp"
603+
elif parameters[0] == "FileList":
604+
with self.program_list_lock:
605+
self.program_list.clear() # direct point to parameters[] will break the shared reference
606+
self.program_list.extend(parameters[2:]) # first element is the target_folder
607+
print(self.program_list)
608+
return "info_flielist"
609+
601610
else:
602611
return None
603612

0 commit comments

Comments
 (0)