PEV: read the modems software versions after successful SLAC

This commit is contained in:
uhi22 2022-11-30 19:58:26 +01:00
parent 591a2a2190
commit f885f3c4ce
2 changed files with 38 additions and 24 deletions

View file

@ -89,8 +89,9 @@ STATE_DELAY_BEFORE_MATCH = 10
STATE_WAITING_FOR_SLAC_MATCH_CNF = 11 STATE_WAITING_FOR_SLAC_MATCH_CNF = 11
STATE_WAITING_FOR_RESTART2 = 12 STATE_WAITING_FOR_RESTART2 = 12
STATE_FIND_MODEMS2 = 13 STATE_FIND_MODEMS2 = 13
STATE_WAITING_FOR_RESTART2 = 14 STATE_WAITING_FOR_SW_VERSIONS = 14
STATE_SDP = 15 STATE_READY_FOR_SDP = 15
STATE_SDP = 16
class pyPlcHomeplug(): class pyPlcHomeplug():
@ -603,7 +604,7 @@ class pyPlcHomeplug():
def evaluateGetSwCnf(self): def evaluateGetSwCnf(self):
# The GET_SW confirmation. This contains the software version of the homeplug modem. # The GET_SW confirmation. This contains the software version of the homeplug modem.
# Reference: see wireshark interpreted frame from TPlink, Ioniq and Alpitronic charger # Reference: see wireshark interpreted frame from TPlink, Ioniq and Alpitronic charger
self.addToTrace("received GET_SW.CNF") self.addToTrace("[SNIFFER] received GET_SW.CNF")
self.numberOfSoftwareVersionResponses+=1 self.numberOfSoftwareVersionResponses+=1
sourceMac=bytearray(6) sourceMac=bytearray(6)
for i in range(0, 6): for i in range(0, 6):
@ -617,7 +618,7 @@ class pyPlcHomeplug():
if (x<0x20): if (x<0x20):
x=0x20 # make unprintable character to space. x=0x20 # make unprintable character to space.
strVersion+=chr(x) # convert ASCII code to string strVersion+=chr(x) # convert ASCII code to string
self.addToTrace("For " + strMac + " the software version is " + strVersion) self.addToTrace("[SNIFFER] For " + strMac + " the software version is " + strVersion)
def evaluateSlacParamReq(self): def evaluateSlacParamReq(self):
# We received a SLAC_PARAM request from the PEV. This is the initiation of a SLAC procedure. # We received a SLAC_PARAM request from the PEV. This is the initiation of a SLAC procedure.
@ -763,7 +764,6 @@ class pyPlcHomeplug():
self.enterState(STATE_MODEM_SEARCH_ONGOING) self.enterState(STATE_MODEM_SEARCH_ONGOING)
return return
if (self.pevSequenceState==STATE_MODEM_SEARCH_ONGOING): # Waiting for the modems to answer. if (self.pevSequenceState==STATE_MODEM_SEARCH_ONGOING): # Waiting for the modems to answer.
print("test")
if (self.pevSequenceCyclesInState>=10): if (self.pevSequenceCyclesInState>=10):
# It was sufficient time to get the answers from the modems. # It was sufficient time to get the answers from the modems.
self.addToTrace("[PEVSLAC] It was sufficient time to get the answers from the modems.") self.addToTrace("[PEVSLAC] It was sufficient time to get the answers from the modems.")
@ -887,7 +887,7 @@ class pyPlcHomeplug():
# (the normal state transition is done in the receive handler of SLAC_MATCH.CNF, # (the normal state transition is done in the receive handler of SLAC_MATCH.CNF,
# including the transmission of SET_KEY.REQ) # including the transmission of SET_KEY.REQ)
return return
if (self.pevSequenceState==STATE_WAITING_FOR_RESTART2): # SLAC is finished, SET_KEY.REQ is if (self.pevSequenceState==STATE_WAITING_FOR_RESTART2): # SLAC is finished, SET_KEY.REQ was
# transmitted. The homeplug modem makes # transmitted. The homeplug modem makes
# the reset and we need to wait until it # the reset and we need to wait until it
# is up with the new key. # is up with the new key.
@ -927,6 +927,20 @@ class pyPlcHomeplug():
if (self.isSimulationMode): if (self.isSimulationMode):
self.addToTrace("[PEVSLAC] But this is only simulated.") self.addToTrace("[PEVSLAC] But this is only simulated.")
self.nEvseModemMissingCounter=0 self.nEvseModemMissingCounter=0
self.pevSequenceDelayCycles=0
self.composeGetSwReq()
self.addToTrace("[PEVSLAC] Requesting SW versions from the modems...")
self.transmit(self.mytransmitbuffer)
self.enterState(STATE_WAITING_FOR_SW_VERSIONS)
return
if (self.pevSequenceState==STATE_WAITING_FOR_SW_VERSIONS):
if (self.pevSequenceCyclesInState>=2): # 2 cycles = 60ms are more than sufficient.
# Measured: The local modem answers in less than 1ms. The remote modem in ~5ms.
# It was sufficient time to get the answers from the modems.
self.addToTrace("[PEVSLAC] It was sufficient time to get the SW versions from the modems.")
self.enterState(STATE_READY_FOR_SDP)
return
if (self.pevSequenceState==STATE_READY_FOR_SDP):
# The AVLN is established, we have at least two modems in the network. # The AVLN is established, we have at least two modems in the network.
# If we did not SDP up to now, let's do it. # If we did not SDP up to now, let's do it.
if (self.isSDPDone): if (self.isSDPDone):

View file

@ -44,9 +44,9 @@ class pyPlcWorker():
def callbackReadyForTcp(self, status): def callbackReadyForTcp(self, status):
if (status==1): if (status==1):
self.workerAddToTrace("[PLCWORKER] Network is established, ready for TCP.") self.workerAddToTrace("[PLCWORKER] Network is established, ready for TCP.")
self.workerAddToTrace("[PLCWORKER] Waiting....") #self.workerAddToTrace("[PLCWORKER] Waiting....")
time.sleep(5) #time.sleep(5)
self.workerAddToTrace("[PLCWORKER] now...") #self.workerAddToTrace("[PLCWORKER] now...")
if (self.oldAvlnStatus==0): if (self.oldAvlnStatus==0):
self.oldAvlnStatus = 1 self.oldAvlnStatus = 1
if (self.mode == C_PEV_MODE): if (self.mode == C_PEV_MODE):