ISSUE
Pyserial: A USB serial device has different addresses depending on whether I install it to a desktop (Catalina) or laptop (High Sierra):
ser = serial.Serial('/dev/cu.usbserial', 9600) #OSX High-Sierra
ser = serial.Serial('/dev/cu.usbserial-1D120', 9600) #OSX Catalina
Is there a method to use a wildcard? /dev/su.usbseria*
. The goal is one line of code that will handle either case.
Any insight as to why -1D120
was appended, is appreciated.
REFERENCES
Example
import serial.tools.list_ports
#Find USB Port
def find_port(): #Finds which port the arduino is plugged into
ports = list(serial.tools.list_ports.comports())
for p in ports:
if '0403' in p[2]: #unique to Osepp Uno (arduino clone)
return p[0]
Assume that the target string (regular expression) is of the format:
/dev/cu.usbserial**************
How would the above snippet of code be modified to trap and return the USB serial device?