| 234 | self.mSerialPort = serial_port |
| 235 | |
| 236 | def handle_line(self, line: str) -> bool: |
| 237 | if not self.mInputSent and self.mSerialPort and self.mTriggerRegex.search(line): |
| 238 | time.sleep(0.1) # Small delay before sending |
| 239 | print( |
| 240 | f"\n{Fore.GREEN}✅ TRIGGER MATCHED: /{self.mTriggerPattern}/{Style.RESET_ALL}" |
| 241 | ) |
| 242 | print( |
| 243 | f"{Fore.GREEN}>>> Sending input: {repr(self.mInputText)}{Style.RESET_ALL}\n" |
| 244 | ) |
| 245 | self.mSerialPort.write((self.mInputText + "\n").encode("utf-8")) |
| 246 | self.mSerialPort.flush() |
| 247 | self.mInputSent = True |
| 248 | return True |
| 249 | |
| 250 | |
| 251 | class SerialMonitor: |