mbuesch / pyprofibus

PROFIBUS-DP stack

Home Page:https://bues.ch/a/profibus

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

After slave was reset/reloaded timeout occurs and slave-object changes its state to STATE_INIT, but its fcb remained in previous state ( fcv=1 fcb=0/1 )

Berendej opened this issue · comments

Because of that master sends Set Prm to reloaded/reset slave with wrong fcv/fcb (fcv=1, fcb=x). Slave expects (fcv=0 fcb=1).
Proposal : add

class DpSlaveState(object):
	def setState(self, state, stateTimeLimit=None):
                ...
		if state == self.STATE_INIT:
			**self.fcb.resetFCB()** 
			self.dxCycleRunning = False

In order this to work, attribute DpSlaveState.fcb should be initialized before initial call to setState() in init()

class DpSlaveState(object):
	def __init__(self, master, slaveDesc):
		self.fcb = FdlFCB()
		self.setState(self.STATE_INIT)

Hi.
Thanks a lot for reporting this.

Yes indeed, this looks like a problem. Fcb handling is not 100% correct in all cases.

Do you want to create a pull request with the proposed change and test it on your device?
I will then check if pyprofibus still works correctly on my devices.