import serial.tools.list_ports
def find_arduino():
ports = serial.tools.list_ports.comports()
for port in ports:
# Check if the device name or description contains "Arduino"
if "Arduino" in port.description or "Arduino" in port.manufacturer:
print(f"Arduino found on port: {port.device}")
return port.device
print("Arduino not found")
return None
# Run the function to find the Arduino
arduino_port = find_arduino()
Po veľa chybných odoslaniach skript padne s errorom "UnboundLocalError: cannot access local variable 'response' where it is not associated with a value" na riadku https://github.com/BUT-DRONE-RESEARCH-CENTER/peripherals_hangar/blob/0053d993ec4e724e653d06fc4340c87f59f43589/stepper_motors/rpi_stepper_control.py#L41 . Načo je tam return niečoho čo sa aj tak nikde nečíta + vracia to len poslednú hodnotu??? Zároveň riadok https://github.com/BUT-DRONE-RESEARCH-CENTER/peripherals_hangar/blob/0053d993ec4e724e653d06fc4340c87f59f43589/stepper_motors/rpi_stepper_control.py#L42 Toto ani testované nebolo. Aj editor vie, že tam má byť keď tak "except". Ak sa niekto nudíte, tento kód vám zistí port arduina :)