mirror of
https://github.com/uhi22/pyPLC.git
synced 2024-11-10 01:05:42 +00:00
fix: EvseMode: Find the DIN schema and use the related SchemaID. Should fix issue #9
This commit is contained in:
parent
12d3d021bf
commit
2b5806bf43
3 changed files with 33 additions and 11 deletions
|
@ -55,6 +55,10 @@ exiHexDemoSupportedApplicationProtocolRequestIoniq="8000dbab9371d3234b71d1b98189
|
|||
# Command line:
|
||||
# ./OpenV2G.exe DH8000dbab9371d3234b71d1b981899189d191818991d26b9b3a232b30020000040040
|
||||
|
||||
# (1b) From the tesla. Source https://github.com/SmartEVSE/SmartEVSE-3/issues/25#issuecomment-1606259381)
|
||||
exiHexDemoSupportedApplicationProtocolRequestTesla="8000DBAB9371D3234B71D1B981899189D191818991D26B9B3A232B30020000040401B75726E3A7465736C613A64696E3A323031383A4D736744656600001C0100080"
|
||||
# The BMW iX3 handshake request (one schema, schemaID 0, from https://github.com/SmartEVSE/SmartEVSE-3/issues/25#issuecomment-1606271999)
|
||||
exiHexDemoSupportedApplicationProtocolRequestBMWiX3="8000DBAB9371D3234B71D1B981899189D191818991D26B9B3A232B30020000000040"
|
||||
|
||||
# (2) From OpenV2G main_example.appHandshake()
|
||||
# 8000ebab9371d34b9b79d189a98989c1d191d191818981d26b9b3a232b30010000040001b75726e3a64696e3a37303132313a323031323a4d73674465660020000100880
|
||||
|
|
37
fsmEvse.py
37
fsmEvse.py
|
@ -51,17 +51,32 @@ class fsmEvse():
|
|||
self.rxData = []
|
||||
strConverterResult = exiDecode(exidata, "DH") # Decode Handshake-request
|
||||
self.addToTrace(strConverterResult)
|
||||
if (strConverterResult.find("ProtocolNamespace=urn:din")>0):
|
||||
# todo: of course we should care for schemaID and prio also here
|
||||
self.addToTrace("Detected DIN")
|
||||
# TESTSUITE: When the EVSE received the Handshake, it selects a new test case.
|
||||
testsuite_choose_testcase()
|
||||
# Eh for encode handshake, SupportedApplicationProtocolResponse
|
||||
msg = addV2GTPHeader(exiEncode("Eh"))
|
||||
self.addToTrace("responding " + prettyHexMessage(msg))
|
||||
self.Tcp.transmit(msg)
|
||||
self.publishStatus("Schema negotiated")
|
||||
self.enterState(stateWaitForSessionSetupRequest)
|
||||
if (strConverterResult.find("supportedAppProtocolReq")>0):
|
||||
nDinSchemaID = 255 # invalid default value
|
||||
try:
|
||||
y = json.loads(strConverterResult)
|
||||
nAppProtocol_ArrayLen = int(y["AppProtocol_arrayLen"])
|
||||
self.addToTrace("The car supports " + str(nAppProtocol_ArrayLen) + " schemas.")
|
||||
for i in range(nAppProtocol_ArrayLen):
|
||||
strNameSpace = y["NameSpace_"+str(i)]
|
||||
nSchemaId = int(y["SchemaID_"+str(i)])
|
||||
self.addToTrace("The NameSpace " + strNameSpace + " has SchemaID " + str(nSchemaId))
|
||||
if (strNameSpace.find(":din:70121:")>0):
|
||||
nDinSchemaID = nSchemaId
|
||||
except:
|
||||
self.addToTrace("ERROR: Could not decode the supportedAppProtocolReq")
|
||||
if (nDinSchemaID<255):
|
||||
self.addToTrace("Detected DIN")
|
||||
# TESTSUITE: When the EVSE received the Handshake, it selects a new test case.
|
||||
testsuite_choose_testcase()
|
||||
# Eh for encode handshake, SupportedApplicationProtocolResponse, with SchemaID as parameter
|
||||
msg = addV2GTPHeader(exiEncode("Eh__"+str(nDinSchemaID)))
|
||||
self.addToTrace("responding " + prettyHexMessage(msg))
|
||||
self.Tcp.transmit(msg)
|
||||
self.publishStatus("Schema negotiated")
|
||||
self.enterState(stateWaitForSessionSetupRequest)
|
||||
else:
|
||||
self.addToTrace("Error: The connected car does not support DIN. At the moment, the pyPLC only supports DIN.")
|
||||
|
||||
def stateFunctionWaitForSessionSetupRequest(self):
|
||||
if (len(self.rxData)>0):
|
||||
|
|
|
@ -232,6 +232,9 @@ class fsmPev():
|
|||
# We just use the initial request message from the Ioniq. It contains one entry: DIN.
|
||||
self.addToTrace("Checkpoint400: Sending the initial SupportedApplicationProtocolReq")
|
||||
self.Tcp.transmit(addV2GTPHeader(exiHexToByteArray(exiHexDemoSupportedApplicationProtocolRequestIoniq)))
|
||||
# For testing purposes, we can also use the requests from other cars:
|
||||
#self.Tcp.transmit(addV2GTPHeader(exiHexToByteArray(exiHexDemoSupportedApplicationProtocolRequestTesla)))
|
||||
#self.Tcp.transmit(addV2GTPHeader(exiHexToByteArray(exiHexDemoSupportedApplicationProtocolRequestBMWiX3)))
|
||||
self.hardwareInterface.resetSimulation()
|
||||
self.enterState(stateWaitForSupportedApplicationProtocolResponse)
|
||||
|
||||
|
|
Loading…
Reference in a new issue