mirror of
https://github.com/janishutz/BiogasControllerApp.git
synced 2025-11-25 13:54:24 +00:00
Updated to Version V2.3.0-stable, installer and compiled version will soon be available
This commit is contained in:
22
BiogasControllerApp-V2.3/bin/lib/comport_search.py
Normal file
22
BiogasControllerApp-V2.3/bin/lib/comport_search.py
Normal file
@@ -0,0 +1,22 @@
|
||||
import serial.tools.list_ports
|
||||
|
||||
|
||||
class ComportService:
|
||||
def __init__(self):
|
||||
self.__comport = []
|
||||
self.__import = []
|
||||
self.__working = []
|
||||
|
||||
def get_comport(self, special_port):
|
||||
self.__comport = [comport.device for comport in serial.tools.list_ports.comports()]
|
||||
self.__pos = 0
|
||||
if special_port != "":
|
||||
self.__working = special_port
|
||||
else:
|
||||
while self.__working == []:
|
||||
self.__com_name = serial.tools.list_ports.comports()[self.__pos]
|
||||
if "USB-Serial Controller" or "Prolific USB-Serial Controller" in self.__com_name:
|
||||
self.__working = self.__comport.pop(self.__pos)
|
||||
else:
|
||||
self.__pos += 1
|
||||
return self.__working
|
||||
Reference in New Issue
Block a user