initial_commit
This commit is contained in:
		
						commit
						bde9eaef43
					
				
					 196 changed files with 120850 additions and 0 deletions
				
			
		
							
								
								
									
										
											BIN
										
									
								
								access_control_python/__pycache__/access_control.cpython-311.pyc
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								access_control_python/__pycache__/access_control.cpython-311.pyc
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										28
									
								
								access_control_python/access_control.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								access_control_python/access_control.py
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,28 @@
 | 
			
		|||
import serial
 | 
			
		||||
from threading import Thread
 | 
			
		||||
 | 
			
		||||
class access_control:
 | 
			
		||||
    _read_buffer = []
 | 
			
		||||
    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()
 | 
			
		||||
    def read_serial(self):
 | 
			
		||||
        while True:
 | 
			
		||||
            if self.serial_adapter.in_waiting:
 | 
			
		||||
                data = self.serial_adapter.read(1)
 | 
			
		||||
                #data = data.decode("ascii").removesuffix("\r\n")
 | 
			
		||||
                self._read_buffer.append(data)
 | 
			
		||||
    def light_on(self):
 | 
			
		||||
        packet = bytearray()
 | 
			
		||||
        packet.append(0x00)
 | 
			
		||||
        packet.append(0x01)
 | 
			
		||||
        packet.append(0xFF)
 | 
			
		||||
        self.serial_adapter.write(packet)
 | 
			
		||||
    def light_off(self):
 | 
			
		||||
        packet = bytearray()
 | 
			
		||||
        packet.append(0x00)
 | 
			
		||||
        packet.append(0x00)
 | 
			
		||||
        packet.append(0xFF)
 | 
			
		||||
        self.serial_adapter.write(packet)
 | 
			
		||||
    
 | 
			
		||||
							
								
								
									
										9
									
								
								access_control_python/main.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								access_control_python/main.py
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,9 @@
 | 
			
		|||
from access_control import access_control
 | 
			
		||||
import time 
 | 
			
		||||
 | 
			
		||||
stm32 = access_control("COM7")
 | 
			
		||||
while True:
 | 
			
		||||
    stm32.light_on()
 | 
			
		||||
    time.sleep(1)
 | 
			
		||||
    stm32.light_off()
 | 
			
		||||
    time.sleep(1)
 | 
			
		||||
							
								
								
									
										1
									
								
								access_control_python/requirements.txt
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								access_control_python/requirements.txt
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
pyserial
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue