From 2948d848bd8c39c6005bd0578f62251cf83efd46 Mon Sep 17 00:00:00 2001 From: SKT-Sukatat <82657530+SKT-Sukatat@users.noreply.github.com> Date: Sun, 17 Sep 2023 16:18:33 +0700 Subject: [PATCH] read response --- .../access_control.cpython-311.pyc | Bin 2260 -> 2602 bytes access_control_python/access_control.py | 14 +- access_control_python/main.py | 9 +- access_control_stm32/.cproject | 3 +- access_control_stm32/.mxproject | 16 +- .../com.st.stm32cube.ide.mcu.sfrview.prefs | 2 + .../.settings/stm32cubeide.project.prefs | 2 +- access_control_stm32/Core/Inc/main.h | 2 + access_control_stm32/Core/Src/main.c | 328 +- .../Debug/Core/Src/main.cyclo | 10 +- access_control_stm32/Debug/Core/Src/main.o | Bin 743784 -> 718620 bytes access_control_stm32/Debug/Core/Src/main.su | 10 +- .../Debug/Core/Src/stm32f4xx_hal_msp.o | Bin 715084 -> 715164 bytes .../Debug/Core/Src/stm32f4xx_it.o | Bin 711140 -> 711224 bytes .../Debug/access_control_stm32.elf | Bin 845560 -> 828260 bytes .../Debug/access_control_stm32.list | 6248 ++++++++--------- .../Debug/access_control_stm32.map | 671 +- access_control_stm32/access_control_stm32.ioc | 21 +- 18 files changed, 3629 insertions(+), 3707 deletions(-) create mode 100644 access_control_stm32/.settings/com.st.stm32cube.ide.mcu.sfrview.prefs diff --git a/access_control_python/__pycache__/access_control.cpython-311.pyc b/access_control_python/__pycache__/access_control.cpython-311.pyc index e98237c7060a5c288b9eed8e1c25307646829ab9..b0c12f7b231192eae146d816df699037dadf171b 100644 GIT binary patch delta 906 zcmZuv%}>-o6z^=O-S6G9S*XiLS(J}0huxU4(F8Rn9K?WY0vyx>P1!c2in};1Di{q1 zjoxH4L@yq^3B*MH027V=1G}UN+DPJ+cv+$sPx_`C@c?b}n>W9C@AuxDKDTWvop=+E zM>u$9KZxc7Tua?+p` zh~YvrAjAuMQhU8)upte((okI*`XYC^^6;))+>wjhMnfKT<B=r0H;y!{Lqzzybd*Qid$J7bYmq|OL+5LIKJz_cL zW`Ouri;H^smgyYUO>YW=C`D_+JYs^6=oN98zQZZ{1E1~XON903%acxK^#J^jjRbSi z6O7I>VDTBWMJMoG7Og>ahViVpW1@leQpCKoWZI5qRI5a@9T;rgo! z`J*lhgxZtzg)l}L|;A7C)-C-i-=zkr0x==E5WW9u;}28BYCI|PYFLOp{qEDSff jqtHslvZ$Cu=!K9XwvyAi(D|Z*Am}I@Fz(ke2fo^0IDY6Z delta 821 zcmZva&ubGw6vt=wm$S{UO^jV*A~q!^*+8;V^b|{#f;|~1ir2C=OH7qwCo8c~p{EMs zp0V(!Lu}4gonBD2cmW5>L0J=R#DgvXwY$3EYvq&%g zska3%oY5X(5V;FK+LHejFO*p3=~Y9l+#K<0L#7H0-dufqqiNNh`gYBexMx-t6Uhjl zlB$+tH3Uc(7N`aT4FOnFOkZDvWFL(MNi~O&lWt_ujTFa744Fec>FR}nZuWKa2>0|Q zS6@1mj1j|VZsjJeJ9bB)zCq=_b^EUE%q%if&SH(-l52R{)Ml5JJw3@Aq&Ut2ey{(mZ$y8r+H 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 @@