MCPcopy Create free account
hub / github.com/FastLED/FastLED / check_port_status

Function check_port_status

ci/debug/validate_port_kill.py:40–61  ·  view source on GitHub ↗

Check if a port is locked.

(port_name: str)

Source from the content-addressed store, hash-verified

38
39
40def check_port_status(port_name: str) -> bool:
41 """Check if a port is locked."""
42 import serial
43
44 try:
45 ser = serial.Serial(port_name, baudrate=115200, timeout=1)
46 ser.close()
47 print(f"✅ {port_name}: Available (not locked)")
48 return False
49 except serial.SerialException as e:
50 error_msg = str(e)
51 if (
52 "PermissionError" in error_msg
53 or "Access is denied" in error_msg
54 or "in use" in error_msg.lower()
55 ):
56 print(f"🔒 {port_name}: LOCKED")
57 print(f" Error: {error_msg}")
58 return True
59 else:
60 print(f"❌ {port_name}: Error - {error_msg}")
61 return False
62
63
64def main():

Callers 1

mainFunction · 0.85

Calls 2

printFunction · 0.50
closeMethod · 0.45

Tested by

no test coverage detected