Browse Source

add support for linux USB devices

subDesTagesMitExtraKaese 3 years ago
parent
commit
1abb3708ee
1 changed files with 10 additions and 0 deletions
  1. 10 0
      serialHandler.py

+ 10 - 0
serialHandler.py

@@ -12,6 +12,16 @@ class SerialConnection:
 	def connect(self, port = None):
 		if port == None:
 			port = self.port
+
+		if port == None:
+			for port in ["/dev/ttyUSB{}".format(p) for p in range(4)]:
+				try:
+					self._ser = serial.Serial(port, 115200)
+					print("connected to " + port)
+					self.port = port
+					break
+				except serial.SerialException:
+					pass
 			
 		if port == None:
 			for port in ["COM{}".format(p) for p in range(3,20)]: