mirror of
https://github.com/dustinbrun/JDS6600_python_Influx-DB_logger.git
synced 2025-08-26 04:50:29 +02:00
V1
This commit is contained in:
17
helper_scripts/auto_detect_port.py
Normal file
17
helper_scripts/auto_detect_port.py
Normal file
@@ -0,0 +1,17 @@
|
||||
import warnings
|
||||
import serial
|
||||
import serial.tools.list_ports
|
||||
|
||||
found_ports = [
|
||||
p.device
|
||||
for p in serial.tools.list_ports.comports()
|
||||
if 'CH340' in p.description or 'USB Serial' in p.description #CH340 for Windows, USB Serial for Linux
|
||||
]
|
||||
|
||||
if not found_ports:
|
||||
raise IOError("No JDS6600-device found")
|
||||
if len(found_ports) > 1:
|
||||
warnings.warn('Multiple JDS6600-devices found - using the first')
|
||||
|
||||
portname = found_ports[0]
|
||||
print(portname)
|
16
helper_scripts/list_serial_ports.py
Normal file
16
helper_scripts/list_serial_ports.py
Normal file
@@ -0,0 +1,16 @@
|
||||
import os
|
||||
import serial.tools.list_ports
|
||||
|
||||
ports = serial.tools.list_ports.comports(include_links=True)
|
||||
|
||||
print("Serial Ports:")
|
||||
print("path \t\t| name \t\t| description")
|
||||
print("-------------------------------------------------------------------------")
|
||||
|
||||
for port in ports :
|
||||
print(port.device + " \t\t| " + port.name + "\t\t| " + port.description)
|
||||
|
||||
print("-------------------------------------------------------------------------")
|
||||
|
||||
os.system("pause")
|
||||
|
Reference in New Issue
Block a user