feature: set ListenMode via command line. In ListenMode, print the SECC MAC.

This commit is contained in:
uhi22 2024-05-21 16:55:26 +02:00
parent e4bff44e80
commit 196c4c3ea5
3 changed files with 19 additions and 1 deletions

View file

@ -76,6 +76,10 @@ if (len(sys.argv) > 1):
else: else:
if (sys.argv[1] == "E"): if (sys.argv[1] == "E"):
myMode = C_EVSE_MODE 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. # The simulation mode can be set by command line in addition in both, PevMode and EvseMode.
isSimulationMode=0 isSimulationMode=0

View file

@ -120,6 +120,14 @@ class pyPlcHomeplug():
self.addToTrace("From " + strSourceMac + strSourceFriendlyName + " to " + strDestMac) 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): def getEtherType(self, messagebufferbytearray):
etherType=0 etherType=0
if len(messagebufferbytearray)>(6+6+2): 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 if (self.pevSequenceState==STATE_WAITING_FOR_SLAC_PARAM_CNF): # we were waiting for the SlacParamCnf
self.pevSequenceDelayCycles = 4 # original Ioniq is waiting 200ms 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 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): def evaluateMnbcSoundInd(self):
# We received MNBC_SOUND.IND from the PEV. Normally this happens 10times, with a countdown (remaining number of sounds) # 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): def enterPevMode(self):
self.iAmEvse = 0 # not emulating a charging station self.iAmEvse = 0 # not emulating a charging station
self.iAmPev = 1 # emulating a vehicle self.iAmPev = 1 # emulating a vehicle
self.iAmListener = 0 # not a passive listener
self.ipv6.enterPevMode() self.ipv6.enterPevMode()
self.showStatus("PEV mode", "mode") self.showStatus("PEV mode", "mode")
def enterEvseMode(self): def enterEvseMode(self):
self.iAmEvse = 1 # emulating a charging station self.iAmEvse = 1 # emulating a charging station
self.iAmPev = 0 # not emulating a vehicle self.iAmPev = 0 # not emulating a vehicle
self.iAmListener = 0 # not a passive listener
self.ipv6.enterEvseMode() self.ipv6.enterEvseMode()
self.showStatus("EVSE mode", "mode") self.showStatus("EVSE mode", "mode")
def enterListenMode(self): def enterListenMode(self):
self.iAmEvse = 0 # not emulating a charging station self.iAmEvse = 0 # not emulating a charging station
self.iAmPev = 0 # not emulating a vehicle self.iAmPev = 0 # not emulating a vehicle
self.iAmListener = 1 # just listening
self.ipv6.enterListenMode() self.ipv6.enterListenMode()
self.showStatus("LISTEN mode", "mode") self.showStatus("LISTEN mode", "mode")

View file

@ -75,7 +75,8 @@ class pyPlcWorker():
def mainfunction(self): def mainfunction(self):
self.nMainFunctionCalls+=1 self.nMainFunctionCalls+=1
#self.showStatus("pyPlcWorker loop " + str(self.nMainFunctionCalls)) #self.showStatus("pyPlcWorker loop " + str(self.nMainFunctionCalls))
self.connMgr.mainfunction() if (self.mode == C_PEV_MODE):
self.connMgr.mainfunction()
self.handleTcpConnectionTrigger() self.handleTcpConnectionTrigger()
self.hp.mainfunction() # call the lower-level workers self.hp.mainfunction() # call the lower-level workers
self.hardwareInterface.mainfunction() self.hardwareInterface.mainfunction()