exiConnector: improved demo mode, to fix issue #6

This commit is contained in:
uhi22 2023-06-19 07:52:08 +02:00
parent 2b87bcaa42
commit 7f233f1baa
4 changed files with 58 additions and 28 deletions

24
DemoExiLog.txt Normal file
View file

@ -0,0 +1,24 @@
init
Dh 80400040
ED 809a02000000000000000011d00000
DD 809A022189CBF75B9625A951E020040080
ED 809a022189cbf75b9625a95198
DD 809A022189CBF75B9625A951A00120024100C4
ED 809a022189cbf75b9625a951b2001280
DD 809A022189CBF75B9625A951C000
ED 809a022189cbf75b9625a950b8
DD 809A022189CBF75B9625A950C00200
ED 809a022189cbf75b9625a950b8
DD 809A022189CBF75B9625A950C00000
ED 809a022189cbf75b9625a9507191400500c8c82324701900
DD 809A022189CBF75B9625A9508002002802800007FFFFF8383FFFC045500000000101857040101C29C8408143C894080C03C08143403C4406010200
ED 809a022189cbf75b9625a9507191400500c8c82324701900
DD 809A022189CBF75B9625A9508000002802800007FFFFF8383FFFC045500000000101871048101C2209C08143C894080C03C08143403C4406010200
ED 809a022189cbf75b9625a95011400500
DD 809A022189CBF75B9625A95020000200000400
ED 809a022189cbf75b9625a95011400500
DD 809A022189CBF75B9625A95020004080000000
ED 809a022189cbf75b9625a95151400500c9cc0206401000
DD 809A022189CBF75B9625A9516000408000010284904800
ED 809a022189cbf75b9625a9513022800a0800
closing

View file

@ -261,31 +261,36 @@ def testReadExiFromSnifferFile():
#print(s) #print(s)
testDecoder(s, "DD", "") testDecoder(s, "DD", "")
def testReadExiFromExiLogFile(): def testReadExiFromExiLogFile(strLogFileName):
file1 = open('PevExiLog.txt', 'r') try:
fileOut = open('PevExiLog.decoded.txt', 'w') file1 = open(strLogFileName, 'r')
# example: "ED 809a02004080c1014181c210b8" fileOut = open('PevExiLog.decoded.txt', 'w')
# example with timestamp: "2022-12-20T08:17:15.055755=ED 809a02004080c1014181c21198" # example: "ED 809a02004080c1014181c210b8"
Lines = file1.readlines() # example with timestamp: "2022-12-20T08:17:15.055755=ED 809a02004080c1014181c21198"
for myLine in Lines: Lines = file1.readlines()
posOfEqual=myLine.find("=") for myLine in Lines:
if (posOfEqual>0): posOfEqual=myLine.find("=")
# we have an equal-sign. Take the string behind it. if (posOfEqual>0):
strToDecode=myLine[posOfEqual+1:] # we have an equal-sign. Take the string behind it.
else: strToDecode=myLine[posOfEqual+1:]
# no equal-sign. Take the complete line. else:
strToDecode=myLine # no equal-sign. Take the complete line.
if (strToDecode[1:3]=="D "): # it is DIN strToDecode=myLine
posOfSpace=2 if (strToDecode[1:3]=="D "): # it is DIN
s = strToDecode[posOfSpace+1:] # The part after the " " contains the EXI hex data. posOfSpace=2
s = s.replace(" ", "") # Remove blanks s = strToDecode[posOfSpace+1:] # The part after the " " contains the EXI hex data.
s = s.replace("\n", "") # Remove line feeds s = s.replace(" ", "") # Remove blanks
#print(s) s = s.replace("\n", "") # Remove line feeds
decoded=exiDecode(s, "DD") #print(s)
print(decoded) decoded=exiDecode(s, "DD")
print(myLine.replace("\n", "") + " means:", file=fileOut) print(decoded)
print(decoded, file=fileOut) print(myLine.replace("\n", "") + " means:", file=fileOut)
fileOut.close() print(decoded, file=fileOut)
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"
@ -314,7 +319,8 @@ if __name__ == "__main__":
testTimeConsumption() testTimeConsumption()
exit() exit()
if (True): if (True):
testReadExiFromExiLogFile() testReadExiFromExiLogFile('DemoExiLog.txt')
testReadExiFromExiLogFile('PevExiLog.txt')
exit() exit()
if (False): if (False):

View file

@ -33,7 +33,7 @@ import json
directory = 'local/pcaps_to_convert' directory = 'local/pcaps_to_convert'
# stop the evaluation after this number of packets. Set to zero to have no limit. # stop the evaluation after this number of packets. Set to zero to have no limit.
nLimitNumberOfPackets = 2000 nLimitNumberOfPackets = -1
def getManufacturerFromMAC(strMAC): def getManufacturerFromMAC(strMAC):

View file

@ -79,7 +79,7 @@ c.create_line(x0Scope, y0Scope, x0Scope, y0Scope+ySizeScope, fill="#FFFFFF")
c.create_line(x0Scope+xSizeScope, y0Scope+ySizeScope, x0Scope+xSizeScope, y0Scope, fill="#FFFFFF") c.create_line(x0Scope+xSizeScope, y0Scope+ySizeScope, x0Scope+xSizeScope, y0Scope, fill="#FFFFFF")
c.create_line(x0Scope+xSizeScope, y0Scope+ySizeScope, x0Scope, y0Scope+ySizeScope, fill="#FFFFFF") c.create_line(x0Scope+xSizeScope, y0Scope+ySizeScope, x0Scope, y0Scope+ySizeScope, fill="#FFFFFF")
inputFileName = "local/pcaps_converted/2023-05-12_174912_tcpdump.pcap.values.txt" inputFileName = "local/pcaps_to_convert/ccm_spi_ioniq_compleo_full_charge_sequence_ended_on_charger.txt.pcap.values.txt"
fileIn = open(inputFileName, 'r') fileIn = open(inputFileName, 'r')
Lines = fileIn.readlines() Lines = fileIn.readlines()