瀏覽代碼

[modbus] retrieve "real" serial port with "os.path.realpath"

Maxime Alves LIRMM@home 4 年之前
父節點
當前提交
7564b2e4ba
共有 1 個文件被更改,包括 9 次插入3 次删除
  1. 9
    3
      pyheatpump/modbus.py

+ 9
- 3
pyheatpump/modbus.py 查看文件

@@ -1,4 +1,5 @@
1 1
 #!/usr/bin/env python3
2
+import os
2 3
 from serial import Serial
3 4
 from serial.serialutil import SerialException
4 5
 from umodbus.client.serial import rtu
@@ -16,10 +17,15 @@ def connect():
16 17
     global serial_conn
17 18
 
18 19
     if serial_conn is None:
19
-        print('Connecting to serial port *{}*'.format(
20
-            config.get('heatpump', 'serial_port')))
20
+        real_serial_port = os.path.realpath(
21
+            config.get('heatpump', 'serial_port'))
22
+
23
+        print('Connecting to serial port *{}* ({})'.format(
24
+            config.get('heatpump', 'serial_port'),
25
+            real_serial_port))
26
+
21 27
         serial_conn = Serial(
22
-            port=config.get('heatpump', 'serial_port'),
28
+            port=real_serial_port,
23 29
             baudrate=config.get('heatpump', 'baudrate'),
24 30
             bytesize=8,
25 31
             parity='N',

Loading…
取消
儲存