aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEwald Weinhandl <ewald.weinhandl@gmail.com>2018-11-09 21:13:13 +0100
committerEwald Weinhandl <ewald.weinhandl@gmail.com>2018-11-09 22:11:22 +0100
commit84ebaf55250667fc86cd96b1c5311d29d56c7ba2 (patch)
tree7a0e72070e9966485e9c5cc670d6c63ccdb1965a
parent75b9589ed5d75702f7e488bfe5905790951d7fec (diff)
downloadpyprofibus-84ebaf55250667fc86cd96b1c5311d29d56c7ba2.zip
pyprofibus-84ebaf55250667fc86cd96b1c5311d29d56c7ba2.tar.xz
Add enable/disable hardware flow control (RTS/CTS) and (DSR/DTR) in config file.
-rw-r--r--pyprofibus/conf.py6
-rw-r--r--pyprofibus/phy_serial.py8
2 files changed, 10 insertions, 4 deletions
diff --git a/pyprofibus/conf.py b/pyprofibus/conf.py
index fc93c89..66e7c33 100644
--- a/pyprofibus/conf.py
+++ b/pyprofibus/conf.py
@@ -111,6 +111,10 @@ class PbConf(object):
fallback = "/dev/ttyS0")
self.phyBaud = getint("PHY", "baud",
fallback = 9600)
+ self.phyRtsCts = getboolean("PHY", "rtscts",
+ fallback = False)
+ self.phyDsrDtr = getboolean("PHY", "dsrdtr",
+ fallback = False)
# [DP]
self.dpMasterClass = getint("DP", "master_class",
@@ -180,5 +184,5 @@ class PbConf(object):
else:
raise PbConfError("Invalid phyType parameter value: "
"%s" % self.phyType)
- phy.setConfig(baudrate = self.phyBaud)
+ phy.setConfig(baudrate = self.phyBaud, rtscts = self.phyRtsCts, dsrdtr = self.phyDsrDtr)
return phy
diff --git a/pyprofibus/phy_serial.py b/pyprofibus/phy_serial.py
index c353307..46f8d37 100644
--- a/pyprofibus/phy_serial.py
+++ b/pyprofibus/phy_serial.py
@@ -64,7 +64,7 @@ class CpPhySerial(CpPhy):
self.__serial.timeout = 0
self.__serial.xonxoff = False
self.__serial.rtscts = False
- self.__serial.dsrdtr = True
+ self.__serial.dsrdtr = False
if useRS485Class:
self.__serial.rs485_mode = serial.rs485.RS485Settings(
rts_level_for_tx = True,
@@ -165,7 +165,7 @@ class CpPhySerial(CpPhy):
raise PhyError("PHY-serial: Failed to transmit "
"telegram:\n" + str(e))
- def setConfig(self, baudrate = CpPhy.BAUD_9600):
+ def setConfig(self, baudrate = CpPhy.BAUD_9600, rtscts = False, dsrdtr = False):
wellSuppBaud = (9600, 19200)
if baudrate not in wellSuppBaud:
# The hw/driver might silently ignore the baudrate
@@ -179,9 +179,11 @@ class CpPhySerial(CpPhy):
baudrate,
", ".join(str(b) for b in wellSuppBaud)))
try:
- if baudrate != self.__serial.baudrate:
+ if baudrate != self.__serial.baudrate or rtscts != self.__serial.rtscts or dsrdtr != self.__serial.dsrdtr:
self.__serial.close()
self.__serial.baudrate = baudrate
+ self.__serial.rtscts = rtscts
+ self.__serial.dsrdtr = dsrdtr
self.__serial.open()
self.__rxBuf = bytearray()
except (serial.SerialException, ValueError) as e:
bues.ch cgit interface