From 196c4c3ea579c2bb7164f548bf9c4bd3837fc2eb Mon Sep 17 00:00:00 2001 From: uhi22 Date: Tue, 21 May 2024 16:55:26 +0200 Subject: [PATCH] feature: set ListenMode via command line. In ListenMode, print the SECC MAC. --- pyPlc.py | 4 ++++ pyPlcHomeplug.py | 13 +++++++++++++ pyPlcWorker.py | 3 ++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/pyPlc.py b/pyPlc.py index 401cf20..61e4fc1 100644 --- a/pyPlc.py +++ b/pyPlc.py @@ -76,6 +76,10 @@ if (len(sys.argv) > 1): else: if (sys.argv[1] == "E"): myMode = C_EVSE_MODE + else: + if (sys.argv[1] == "L"): + myMode = C_LISTEN_MODE + # The simulation mode can be set by command line in addition in both, PevMode and EvseMode. isSimulationMode=0 diff --git a/pyPlcHomeplug.py b/pyPlcHomeplug.py index 18f58f9..2395c86 100644 --- a/pyPlcHomeplug.py +++ b/pyPlcHomeplug.py @@ -120,6 +120,14 @@ class pyPlcHomeplug(): self.addToTrace("From " + strSourceMac + strSourceFriendlyName + " to " + strDestMac) + def getSourceMacAddressAsString(self): + strSourceMac = "" + for i in range(6, 12): + strSourceMac = strSourceMac + twoCharHex(self.myreceivebuffer[i]) + if (i<11): + strSourceMac = strSourceMac + ":" + return strSourceMac + def getEtherType(self, messagebufferbytearray): etherType=0 if len(messagebufferbytearray)>(6+6+2): @@ -657,6 +665,8 @@ class pyPlcHomeplug(): if (self.pevSequenceState==STATE_WAITING_FOR_SLAC_PARAM_CNF): # we were waiting for the SlacParamCnf self.pevSequenceDelayCycles = 4 # original Ioniq is waiting 200ms self.enterState(STATE_SLAC_PARAM_CNF_RECEIVED) # enter next state. Will be handled in the cyclic runPevSequencer + if (self.iAmListener==1): + self.addToTrace("SECC MAC is " + self.getSourceMacAddressAsString()) def evaluateMnbcSoundInd(self): # We received MNBC_SOUND.IND from the PEV. Normally this happens 10times, with a countdown (remaining number of sounds) @@ -1057,16 +1067,19 @@ class pyPlcHomeplug(): def enterPevMode(self): self.iAmEvse = 0 # not emulating a charging station self.iAmPev = 1 # emulating a vehicle + self.iAmListener = 0 # not a passive listener self.ipv6.enterPevMode() self.showStatus("PEV mode", "mode") def enterEvseMode(self): self.iAmEvse = 1 # emulating a charging station self.iAmPev = 0 # not emulating a vehicle + self.iAmListener = 0 # not a passive listener self.ipv6.enterEvseMode() self.showStatus("EVSE mode", "mode") def enterListenMode(self): self.iAmEvse = 0 # not emulating a charging station self.iAmPev = 0 # not emulating a vehicle + self.iAmListener = 1 # just listening self.ipv6.enterListenMode() self.showStatus("LISTEN mode", "mode") diff --git a/pyPlcWorker.py b/pyPlcWorker.py index c3f9252..c2761c9 100644 --- a/pyPlcWorker.py +++ b/pyPlcWorker.py @@ -75,7 +75,8 @@ class pyPlcWorker(): def mainfunction(self): self.nMainFunctionCalls+=1 #self.showStatus("pyPlcWorker loop " + str(self.nMainFunctionCalls)) - self.connMgr.mainfunction() + if (self.mode == C_PEV_MODE): + self.connMgr.mainfunction() self.handleTcpConnectionTrigger() self.hp.mainfunction() # call the lower-level workers self.hardwareInterface.mainfunction()