mirror of
https://github.com/uhi22/pyPLC.git
synced 2024-11-10 01:05:42 +00:00
feature: add handshake examples to DemoExiLog and handshake decoding to exiconnector demo mode
This commit is contained in:
parent
7f233f1baa
commit
cc2131dc23
3 changed files with 34 additions and 8 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -3,6 +3,7 @@
|
||||||
/doc/*.jar
|
/doc/*.jar
|
||||||
*.bat
|
*.bat
|
||||||
PevExiLog*.txt
|
PevExiLog*.txt
|
||||||
|
DemoExiLog.txt.decoded.txt
|
||||||
testresults.txt
|
testresults.txt
|
||||||
*.ini
|
*.ini
|
||||||
/log
|
/log
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
init
|
init
|
||||||
Dh 80400040
|
|
||||||
ED 809a02000000000000000011d00000
|
ED 809a02000000000000000011d00000
|
||||||
DD 809A022189CBF75B9625A951E020040080
|
DD 809A022189CBF75B9625A951E020040080
|
||||||
ED 809a022189cbf75b9625a95198
|
ED 809a022189cbf75b9625a95198
|
||||||
|
@ -21,4 +20,14 @@ DD 809A022189CBF75B9625A95020004080000000
|
||||||
ED 809a022189cbf75b9625a95151400500c9cc0206401000
|
ED 809a022189cbf75b9625a95151400500c9cc0206401000
|
||||||
DD 809A022189CBF75B9625A9516000408000010284904800
|
DD 809A022189CBF75B9625A9516000408000010284904800
|
||||||
ED 809a022189cbf75b9625a9513022800a0800
|
ED 809a022189cbf75b9625a9513022800a0800
|
||||||
|
# The Tesla handshake request (two schemas supported, from https://github.com/SmartEVSE/SmartEVSE-3/issues/25#issuecomment-1606259381)
|
||||||
|
DH 8000DBAB9371D3234B71D1B981899189D191818991D26B9B3A232B30020000040401B75726E3A7465736C613A64696E3A323031383A4D736744656600001C0100080
|
||||||
|
# The Ioniq handshake request (one schema, schemaID 1)
|
||||||
|
DH 8000dbab9371d3234b71d1b981899189d191818991d26b9b3a232b30020000040040
|
||||||
|
# The BMW iX3 handshake request (one schema, schemaID 0, from https://github.com/SmartEVSE/SmartEVSE-3/issues/25#issuecomment-1606271999)
|
||||||
|
DH 8000DBAB9371D3234B71D1B981899189D191818991D26B9B3A232B30020000000040
|
||||||
|
# The handshake response with schemaID 1
|
||||||
|
Dh 80400040
|
||||||
|
# The handshake response with schemaID 0
|
||||||
|
Dh 80400000
|
||||||
closing
|
closing
|
||||||
|
|
|
@ -101,6 +101,7 @@ exiHexDemoSupportedApplicationProtocolRequest2="8000ebab9371d34b9b79d189a98989c1
|
||||||
# 809a0125e6cecc50e0004080000082867dc8081818000000040a1b64802030882702038486580800 CurrentDemandRes
|
# 809a0125e6cecc50e0004080000082867dc8081818000000040a1b64802030882702038486580800 CurrentDemandRes
|
||||||
# 809a0125e6cecc50e0804080000082867dc8081818000000040a1b64802030882702038486580800 CurrentDemandRes with "FAILED"
|
# 809a0125e6cecc50e0804080000082867dc8081818000000040a1b64802030882702038486580800 CurrentDemandRes with "FAILED"
|
||||||
|
|
||||||
|
# Further examples are collected in the DemoExiLog.txt.
|
||||||
|
|
||||||
# Configuration of the exi converter tool
|
# Configuration of the exi converter tool
|
||||||
if os.name == "nt":
|
if os.name == "nt":
|
||||||
|
@ -262,9 +263,17 @@ def testReadExiFromSnifferFile():
|
||||||
testDecoder(s, "DD", "")
|
testDecoder(s, "DD", "")
|
||||||
|
|
||||||
def testReadExiFromExiLogFile(strLogFileName):
|
def testReadExiFromExiLogFile(strLogFileName):
|
||||||
|
print("Trying to read from ExiLogFile " + strLogFileName)
|
||||||
try:
|
try:
|
||||||
file1 = open(strLogFileName, 'r')
|
file1 = open(strLogFileName, 'r')
|
||||||
fileOut = open('PevExiLog.decoded.txt', 'w')
|
isFileOk = True
|
||||||
|
except:
|
||||||
|
print("Could not open " + strLogFileName)
|
||||||
|
isFileOk = False
|
||||||
|
if (strLogFileName == "PevExiLog.txt"):
|
||||||
|
print("This is no problem. The PevExiLog.txt will be created when the pyPLC runs in PevMode, and can be decoded afterwards.")
|
||||||
|
if (isFileOk):
|
||||||
|
fileOut = open(strLogFileName + '.decoded.txt', 'w')
|
||||||
# example: "ED 809a02004080c1014181c210b8"
|
# example: "ED 809a02004080c1014181c210b8"
|
||||||
# example with timestamp: "2022-12-20T08:17:15.055755=ED 809a02004080c1014181c21198"
|
# example with timestamp: "2022-12-20T08:17:15.055755=ED 809a02004080c1014181c21198"
|
||||||
Lines = file1.readlines()
|
Lines = file1.readlines()
|
||||||
|
@ -276,21 +285,28 @@ def testReadExiFromExiLogFile(strLogFileName):
|
||||||
else:
|
else:
|
||||||
# no equal-sign. Take the complete line.
|
# no equal-sign. Take the complete line.
|
||||||
strToDecode=myLine
|
strToDecode=myLine
|
||||||
if (strToDecode[1:3]=="D "): # it is DIN
|
if (myLine[0]=="#"):
|
||||||
|
# take-over comment lines into the output
|
||||||
|
print(myLine.replace("\n", ""))
|
||||||
|
print(myLine.replace("\n", ""), file=fileOut)
|
||||||
|
strDecoderSelection = "" # default: unknown line
|
||||||
|
if (strToDecode[1:3]=="D "):
|
||||||
|
strDecoderSelection = "D" # it is a DIN message
|
||||||
|
if (strToDecode[1:3]=="H ") or (strToDecode[1:3]=="h "):
|
||||||
|
strDecoderSelection = "H" # it is a ProtocolHandshake message
|
||||||
|
|
||||||
|
if (len(strDecoderSelection)>0): # if we have selected a valid decoder
|
||||||
posOfSpace=2
|
posOfSpace=2
|
||||||
s = strToDecode[posOfSpace+1:] # The part after the " " contains the EXI hex data.
|
s = strToDecode[posOfSpace+1:] # The part after the " " contains the EXI hex data.
|
||||||
s = s.replace(" ", "") # Remove blanks
|
s = s.replace(" ", "") # Remove blanks
|
||||||
s = s.replace("\n", "") # Remove line feeds
|
s = s.replace("\n", "") # Remove line feeds
|
||||||
#print(s)
|
#print(s)
|
||||||
decoded=exiDecode(s, "DD")
|
decoded=exiDecode(s, "D"+strDecoderSelection)
|
||||||
|
print(myLine.replace("\n", "") + " means:")
|
||||||
print(decoded)
|
print(decoded)
|
||||||
print(myLine.replace("\n", "") + " means:", file=fileOut)
|
print(myLine.replace("\n", "") + " means:", file=fileOut)
|
||||||
print(decoded, file=fileOut)
|
print(decoded, file=fileOut)
|
||||||
fileOut.close()
|
fileOut.close()
|
||||||
except:
|
|
||||||
print("Could not open " + strLogFileName)
|
|
||||||
if (strLogFileName == "PevExiLog.txt"):
|
|
||||||
print("This is no problem. The PevExiLog.txt will be created when the pyPLC runs in PevMode, and can be decoded afterwards.")
|
|
||||||
|
|
||||||
def testTimeConsumption():
|
def testTimeConsumption():
|
||||||
strHex = "809a001150400000c80006400000"
|
strHex = "809a001150400000c80006400000"
|
||||||
|
|
Loading…
Reference in a new issue