Browse Source

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

Maxime Alves LIRMM@home 3 years ago
parent
commit
7564b2e4ba
1 changed files with 9 additions and 3 deletions
  1. 9
    3
      pyheatpump/modbus.py

+ 9
- 3
pyheatpump/modbus.py View File

@@ -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…
Cancel
Save