diff --git a/doc/todo.md b/doc/todo.md index 268f848..1d5204a 100644 --- a/doc/todo.md +++ b/doc/todo.md @@ -5,7 +5,7 @@ - [ ] Encoder: PreChargeReq: is it possible to enable the units for EVTargetVoltage and EVTargetCurrent? - [ ] Find out, why Alpi reports CableCheckRes = Finished FAILED in v0.4 - [ ] Find out, why Compleo ignores the PowerDeliveryReq START in v0.4 -- [ ] Add date/time into ExiLog +- [x] Add date/time into ExiLog - [ ] PevMode: Add state transition in case of failed CableCheck - [x] PevMode: PreChargeReq: Fill EVRESSSOC, EVTargetVoltage, EVTargetCurrent - [x] PevMode: PowerDeliveryReq: Fill EVRESSSOC, Stop/Start @@ -14,9 +14,9 @@ - [ ] EvseMode: Fill V2G messages as far as needed, to convince the car to accept it. - [x] PevMode: Fill V2G messages as far as needed, to convince the charger to accept it. - [x] PevMode: Find out the SLAC issue on Supercharger and Compleo. -- [ ] PevMode: Connect the inlet voltage measurement +- [x] PevMode: Connect the inlet voltage measurement - [x] PevMode: Connect the control of CP -- [ ] PevMode: Connect the control of Relay +- [x] PevMode: Connect the control of Relay - [ ] docu: add link to evse which provides the 5% PWM) - [ ] docu: add hardwareInterface into software architecture puml - [ ] docu: create hardware architecture picture diff --git a/exiConnector.py b/exiConnector.py index 7f3dfc8..ca3642e 100644 --- a/exiConnector.py +++ b/exiConnector.py @@ -243,21 +243,29 @@ def testReadExiFromSnifferFile(): testDecoder(s, "DD", "") def testReadExiFromExiLogFile(): - file1 = open('PevExiLog_2022-12-13_westparkAlpi_twice.txt', 'r') - fileOut = open('PevExiLog_2022-12-13_westparkAlpi_twice.txt.decoded.txt', 'w') + file1 = open('PevExiLog.txt', 'r') + fileOut = open('PevExiLog.decoded.txt', 'w') # example: "ED 809a02004080c1014181c210b8" + # example with timestamp: "2022-12-20T08:17:15.055755=ED 809a02004080c1014181c21198" Lines = file1.readlines() for myLine in Lines: - if (myLine[1:3]=="D "): # it is DIN + posOfEqual=myLine.find("=") + if (posOfEqual>0): + # we have an equal-sign. Take the string behind it. + strToDecode=myLine[posOfEqual+1:] + else: + # no equal-sign. Take the complete line. + strToDecode=myLine + if (strToDecode[1:3]=="D "): # it is DIN posOfSpace=2 - s = myLine[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("\n", "") # Remove line feeds #print(s) decoded=exiDecode(s, "DD") print(decoded) print(myLine.replace("\n", "") + " means:", file=fileOut) - print(decoded, file=fileOut) + print(decoded, file=fileOut) fileOut.close() def testTimeConsumption(): diff --git a/fsmPev.py b/fsmPev.py index 29fcb2c..cf607c2 100644 --- a/fsmPev.py +++ b/fsmPev.py @@ -6,6 +6,7 @@ import pyPlcTcpSocket import time # for time.sleep() +from datetime import datetime from helpers import prettyHexMessage, compactHexMessage from exiConnector import * # for EXI data handling/converting import json @@ -43,14 +44,16 @@ class fsmPev(): def exiDecode(self, exidata, schema): s = compactHexMessage(exidata) - self.exiLogFile.write(schema + " " + s +"\n") # write the EXI data to the exiLogFile + strDateTime=datetime.today().strftime('%Y-%m-%dT%H:%M:%S.%f') + self.exiLogFile.write(strDateTime + "=" + schema + " " + s +"\n") # write the EXI data to the exiLogFile return exiDecode(exidata, schema) # call the decoder def exiEncode(self, input): schema = input[0:2] exidata = exiEncode(input) # call the encoder s = exidata # it is already a hex string - self.exiLogFile.write(schema + " " + s +"\n") # write the EXI data to the exiLogFile + strDateTime=datetime.today().strftime('%Y-%m-%dT%H:%M:%S.%f') + self.exiLogFile.write(strDateTime + "=" + schema + " " + s +"\n") # write the EXI data to the exiLogFile return exidata def sendChargeParameterDiscoveryReq(self):