...
 
Commits (3)
......@@ -28,6 +28,10 @@ type=dummy_slave
; The Profibus on-wire baud rate.
baud=19200
; Serial line flow control and handshaking
rtscts=False
dsrdtr=False
; FDL protocol layer configuration
[FDL]
......
......@@ -28,6 +28,10 @@ dev=/dev/ttyS0
; The Profibus on-wire baud rate.
baud=19200
; Serial line flow control and handshaking
rtscts=False
dsrdtr=False
; FDL protocol layer configuration
[FDL]
......
......@@ -28,6 +28,10 @@ dev=/dev/ttyS0
; The Profibus on-wire baud rate.
baud=19200
; Serial line flow control and handshaking
rtscts=False
dsrdtr=False
; FDL protocol layer configuration
[FDL]
......
......@@ -51,6 +51,8 @@ class PbConf(object):
phyType = None
phyDev = None
phyBaud = None
phyRtsCts = None
phyDsrDtr = None
# [DP] section
dpMasterClass = None
dpMasterAddr = None
......@@ -111,6 +113,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 +186,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
......@@ -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:
......