From 29f66af5155d2aabee6f64b0805671f56b9f0b06 Mon Sep 17 00:00:00 2001 From: Danny Hajicek Date: Thu, 3 Apr 2025 13:17:18 -0700 Subject: [PATCH] Don't catch KeyboardInterrupt during blocking IO read. Minor cleanup of example slave.py to match LIN IDs being sent by example master.py --- examples/slave.py | 4 ++-- plin/device.py | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/slave.py b/examples/slave.py index f289bb5..0a0166d 100755 --- a/examples/slave.py +++ b/examples/slave.py @@ -10,10 +10,10 @@ def main(): slave.start(PLINMode.SLAVE) slave.set_id_filter(bytearray([0xff] * 8)) - slave.set_frame_entry(id=0x22, direction=PLINFrameDirection.PUBLISHER, + slave.set_frame_entry(id=0x02, direction=PLINFrameDirection.PUBLISHER, checksum_type=PLINFrameChecksumType.ENHANCED, data=bytearray([0xff] * 3)) - slave.set_response_remap({0x21: 0x22}) + slave.set_response_remap({0x01: 0x02}) result = slave.get_response_remap(visual_output=True) print(result) diff --git a/plin/device.py b/plin/device.py index df5f88b..774ff0f 100644 --- a/plin/device.py +++ b/plin/device.py @@ -527,6 +527,8 @@ def read(self, block=True) -> Union[PLINMessage, None]: # If bytes read was invalid. if bytes(message.data) == PLIN_EMPTY_DATA: message = None + except KeyboardInterrupt: + raise KeyboardInterrupt except: message = None os.set_blocking(self.fd, blocking)