Skip to content

Commit e2bb803

Browse files
Known VIDs and PIDS
1 parent f24146b commit e2bb803

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

electroblocks/core.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,28 @@ class ElectroBlocks:
3232
verbose = False
3333
pins = {}
3434

35-
35+
# Known vendor IDs (decimal)
36+
KNOWN_VIDS = {
37+
9025, # 0x2341 - Arduino
38+
6790, # 0x1A86 - WCH (CH340/CH341)
39+
4292, # 0x10C4 - Silicon Labs (CP210x)
40+
1027, # 0x0403 - FTDI
41+
1659, # 0x067B - Prolific
42+
}
43+
44+
# Known product IDs (decimal)
45+
KNOWN_PIDS = {
46+
67, # 0x0043 - Uno R3 PID
47+
66, # 0x0042 - Mega R3 PID (common variant)
48+
16, # 0x0010 - Mega2560 pre-R3
49+
60000, # 0xEA60 - CP210x example (Silicon Labs)
50+
29987, # 0x7523 - CH340 common PID
51+
24577, # 0x6001 - FTDI FT232
52+
24592, # 0x6010 - FTDI FT2232
53+
24593, # 0x6011 - FTDI FT4232
54+
24596, # 0x6014 - FTDI variant
55+
24597, # 0x6015 - FTDI FT231X
56+
}
3657

3758
def __init__(self, baudrate=115200, timeout=2, verbose = False):
3859
self.ser = self._auto_connect(baudrate, timeout)
@@ -45,7 +66,7 @@ def __init__(self, baudrate=115200, timeout=2, verbose = False):
4566
def _auto_connect(self, baudrate, timeout):
4667
ports = list(serial.tools.list_ports.comports())
4768
for p in ports:
48-
if p.vid in (9025, 6790, 4292) or p.pid in (67, 16, 60000): # Arduino Uno or Mega and Indian Arduino UNO
69+
if p.vid in self.KNOWN_VIDS or p.pid in self.KNOWN_VIDS:
4970
try:
5071
ser = serial.Serial(p.device, baudrate, timeout=timeout)
5172
time.sleep(2) # Give Arduino time to reset

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "electroblocks"
7-
version = "0.1.14"
7+
version = "0.1.15"
88
description = "Python client library to interact with ElectroBlocks Arduino firmware"
99
authors = [
1010
{ name = "Noah Glaser", email = "glaserpower@gmail.com" }

0 commit comments

Comments
 (0)