diff --git a/access_control_python/__pycache__/access_control.cpython-311.pyc b/access_control_python/__pycache__/access_control.cpython-311.pyc index e98237c..b0c12f7 100644 Binary files a/access_control_python/__pycache__/access_control.cpython-311.pyc and b/access_control_python/__pycache__/access_control.cpython-311.pyc differ diff --git a/access_control_python/access_control.py b/access_control_python/access_control.py index 87ae367..06e2421 100644 --- a/access_control_python/access_control.py +++ b/access_control_python/access_control.py @@ -6,11 +6,13 @@ class access_control: serial_adapter: serial.Serial def __init__(self, serial_port: str): self.serial_adapter = serial.Serial(serial_port,baudrate=115200) - Thread(target=self.read_serial).start() + #Thread(target=self.read_serial).start() def read_serial(self): while True: - if self.serial_adapter.in_waiting: - data = self.serial_adapter.read(1) + if True: + print("Reading Serial") + data = self.serial_adapter.read_until(0xFF) + print(data) #data = data.decode("ascii").removesuffix("\r\n") self._read_buffer.append(data) def light_on(self): @@ -25,4 +27,8 @@ class access_control: packet.append(0x00) packet.append(0xFF) self.serial_adapter.write(packet) - \ No newline at end of file + def request_door_state(self): + packet = bytearray() + packet.append(0x01) + packet.append(0xFF) + self.serial_adapter.write(packet) \ No newline at end of file diff --git a/access_control_python/main.py b/access_control_python/main.py index 2a5ab37..3a67ecf 100644 --- a/access_control_python/main.py +++ b/access_control_python/main.py @@ -2,8 +2,9 @@ from access_control import access_control import time stm32 = access_control("COM7") +time.sleep(1) while True: - stm32.light_on() - time.sleep(1) - stm32.light_off() - time.sleep(1) \ No newline at end of file + stm32.request_door_state() + kkc =stm32.serial_adapter.read(2) + print(kkc) + time.sleep(0.5) \ No newline at end of file diff --git a/access_control_stm32/.cproject b/access_control_stm32/.cproject index c69e6a6..08b68cc 100644 --- a/access_control_stm32/.cproject +++ b/access_control_stm32/.cproject @@ -104,7 +104,7 @@