diff --git a/connMgr.py b/connMgr.py index 795bb83..15bad92 100644 --- a/connMgr.py +++ b/connMgr.py @@ -24,6 +24,7 @@ CONNLEVEL_15_SLAC_ONGOING = 15 CONNLEVEL_10_ONE_MODEM_FOUND = 10 CONNLEVEL_5_ETH_LINK_PRESENT = 5 +CONNMGR_CYCLES_PER_SECOND = 33 # 33 cycles for one second, is 30ms call cycle CONNMGR_TIMER_MAX = (5*33) # 5 seconds until an OkReport is forgotten. CONNMGR_TIMER_MAX_10s = (10*33) # 10 seconds until an OkReport is forgotten. CONNMGR_TIMER_MAX_15s = (15*33) # 15 seconds until an OkReport is forgotten. @@ -133,8 +134,10 @@ class connMgr(): def TcpOk(self): self.timerTCP = CONNMGR_TIMER_MAX_10s - def ApplOk(self): - self.timerAppl = CONNMGR_TIMER_MAX_10s + def ApplOk(self, time_in_seconds=10): + # The application confirmed to have communication. It can decide, based on its state, + # how long the confirmation shall hold. Default is ten seconds. + self.timerAppl = time_in_seconds * CONNMGR_CYCLES_PER_SECOND def testCallbackAddToTrace(s): diff --git a/fsmEvse.py b/fsmEvse.py index 92876d6..f18b0bb 100644 --- a/fsmEvse.py +++ b/fsmEvse.py @@ -150,7 +150,11 @@ class fsmEvse(): self.enterState(stateWaitForFlexibleRequest) # todo: not clear, what is specified in DIN if (strConverterResult.find("CableCheckReq")>0): # todo: check the request content, and fill response parameters + # todo: make a real cable check, and while it is ongoing, send "Ongoing". msg = addV2GTPHeader(exiEncode("EDf")) # EDf for Encode, Din, CableCheckResponse + if (testsuite_faultinjection_is_triggered(TC_EVSE_ResponseCode_Failed_for_CableCheckRes)): + # send a CableCheckResponse with Responsecode Failed + msg = addV2GTPHeader("809a0125e6cecc5020804080000400") self.addToTrace("responding " + prettyHexMessage(msg)) self.publishStatus("CableCheck") if (not testsuite_faultinjection_is_triggered(TC_EVSE_Timeout_during_CableCheck)): @@ -181,6 +185,9 @@ class fsmEvse(): if (testsuite_faultinjection_is_triggered(TC_EVSE_Shutdown_during_PreCharge)): # send a PreChargeResponse with StatusCode EVSE_Shutdown, to simulate a user-triggered session stop msg = addV2GTPHeader("809a02180189551e24fc9e9160004100008182800000") + if (testsuite_faultinjection_is_triggered(TC_EVSE_ResponseCode_Failed_for_PreChargeRes)): + # send a PreChargeResponse with ResponseCode Failed + msg = addV2GTPHeader("809a0125e6cecc516080408000008284de880800") self.addToTrace("responding " + prettyHexMessage(msg)) self.publishStatus("PreCharging " + strPresentVoltage) if (not testsuite_faultinjection_is_triggered(TC_EVSE_Timeout_during_PreCharge)): @@ -220,6 +227,9 @@ class fsmEvse(): if (testsuite_faultinjection_is_triggered(TC_EVSE_Shutdown_during_CurrentDemand)): # send a CurrentDemandResponse with StatusCode EVSE_Shutdown, to simulate a user stop request msg = addV2GTPHeader("809a0125e15c2cd0e000410000018280001818000000040a1b648030300002038486580800") + if (testsuite_faultinjection_is_triggered(TC_EVSE_ResponseCode_Failed_for_CurrentDemandRes)): + # send a CurrentDemandResponse with ResponseCode Failed + msg = addV2GTPHeader("809a0125e6cecc50e0804080000082867dc8081818000000040a1b64802030882702038486580800") self.addToTrace("responding " + prettyHexMessage(msg)) self.publishStatus("CurrentDemand") if (not testsuite_faultinjection_is_triggered(TC_EVSE_Timeout_during_CurrentDemand)): diff --git a/fsmPev.py b/fsmPev.py index 27ba218..e1da261 100644 --- a/fsmPev.py +++ b/fsmPev.py @@ -158,6 +158,10 @@ class fsmPev(): msg = addV2GTPHeader(self.exiEncode("EDF_"+self.sessionId + "_" + soc)) # EDF for Encode, Din, CableCheckReq self.addToTrace("responding " + prettyHexMessage(msg)) self.Tcp.transmit(msg) + # Since the response to the CableCheckRequest may need longer, inform the connection manager to be patient. + # This makes sure, that the timeout of the state machine comes before the timeout of the connectionManager, so + # that we enter the safe shutdown sequence as intended. + self.connMgr.ApplOk(31) def sendCurrentDemandReq(self): @@ -485,6 +489,7 @@ class fsmPev(): msg = addV2GTPHeader(self.exiEncode("EDG_"+self.sessionId+"_"+str(soc)+"_"+str(EVTargetVoltage))) # EDG for Encode, Din, PreChargeReq self.addToTrace("responding " + prettyHexMessage(msg)) self.Tcp.transmit(msg) + self.connMgr.ApplOk(31) # PreChargeResponse may need longer. Inform the connection manager to be patient. self.enterState(stateWaitForPreChargeResponse) else: if (self.numberOfCableCheckReq>60): # approx 60s should be sufficient for cable check. The ISO allows up to 55s reaction time and 60s timeout for "ongoing". diff --git a/mytestsuite.py b/mytestsuite.py index 8cd6332..c9dd78a 100644 --- a/mytestsuite.py +++ b/mytestsuite.py @@ -19,11 +19,11 @@ from configmodule import getConfigValue, getConfigValueBool # The list of test cases. Each must have a unique test case ID. TC_NOTHING_TO_TEST = 0 TC_EVSE_ResponseCode_SequenceError_for_SessionSetup = 1 -TC_EVSE_ResponseCode_SequenceError_for_ServiceDiscoveryRes = 2 -TC_EVSE_ResponseCode_SequenceError_for_ServicePaymentSelectionRes = 3 -TC_EVSE_ResponseCode_SequenceError_for_ContractAuthenticationRes = 4 -TC_EVSE_ResponseCode_ServiceSelectionInvalid_for_ChargeParameterDiscovery = 5 -TC_EVSE_ResponseCode_Failed_for_CableCheckRes = 6 +TC_EVSE_ResponseCode_Failed_for_CableCheckRes = 2 +TC_EVSE_ResponseCode_SequenceError_for_ServiceDiscoveryRes = 3 +TC_EVSE_ResponseCode_SequenceError_for_ServicePaymentSelectionRes = 4 +TC_EVSE_ResponseCode_SequenceError_for_ContractAuthenticationRes = 5 +TC_EVSE_ResponseCode_ServiceSelectionInvalid_for_ChargeParameterDiscovery = 6 TC_EVSE_ResponseCode_Failed_for_PreChargeRes = 7 TC_EVSE_ResponseCode_Failed_for_PowerDeliveryRes = 8 TC_EVSE_ResponseCode_Failed_for_CurrentDemandRes = 9 @@ -162,7 +162,7 @@ def testsuite_choose_testcase(): testsuite_TcTitle = "ServiceSelectionInvalid in ChargeParameterDiscoveryshall lead to SafeShutdown" if (testsuite_testcase_number == TC_EVSE_ResponseCode_Failed_for_CableCheckRes): - testsuite_delayCycles=2 # after two ok cycles, we inject the fault in the third cycle + testsuite_delayCycles=0 # immediately in the first message testsuite_expectedResult = "TSRS_SafeShutdownFinished" testsuite_TcTitle = "Failed in CableCheckRes shall lead to SafeShutdown"