기존 코드는 USB ACM디바이스들을 list에 넣어서 인식하도록 했는데, Silab 디바이스도 추가되도록 macineCOM.py 파일의 serialList 함수 수정.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def serialList(forAutoDetect=False): | |
""" | |
Retrieve a list of serial ports found in the system. | |
:param forAutoDetect: if true then only the USB serial ports are listed. Else all ports are listed. | |
:return: A list of strings where each string is a serial port. | |
""" | |
baselist=[] | |
if platform.system() == "Windows": | |
try: | |
key=_winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,"HARDWARE\\DEVICEMAP\\SERIALCOMM") | |
i=0 | |
while True: | |
values = _winreg.EnumValue(key, i) | |
if not forAutoDetect or ('USBSER' in values[0]) or ('Silabser' in values[0]): | |
baselist+=[values[1]] | |
i+=1 | |
except: | |
pass | |
if forAutoDetect: | |
baselist = baselist + glob.glob('/dev/ttyUSB*') + glob.glob('/dev/ttyACM*') + glob.glob("/dev/cu.usb*") + glob.glob("/dev/tty.SLAB*") | |
baselist = filter(lambda s: not 'Bluetooth' in s, baselist) | |
prev = profile.getMachineSetting('serial_port_auto') | |
if prev in baselist: | |
baselist.remove(prev) | |
baselist.insert(0, prev) | |
else: | |
baselist = baselist + glob.glob('/dev/ttyUSB*') + glob.glob('/dev/ttyACM*') + glob.glob("/dev/cu.*") + glob.glob("/dev/tty.usb*") + glob.glob("/dev/rfcomm*") + glob.glob('/dev/serial/by-id/*') | |
if version.isDevVersion() and not forAutoDetect: | |
baselist.append('VIRTUAL') | |
return baselist |