feature: exit if connectionLevel decreases from full. Raspberry docu improved.

This commit is contained in:
uhi22 2023-05-13 20:27:08 +02:00
parent 2565435d09
commit 1b5af0d2e2
4 changed files with 32 additions and 7 deletions

View file

@ -13,6 +13,9 @@
# the lower-layer state machine can stay silent as long as the upper layers are working # the lower-layer state machine can stay silent as long as the upper layers are working
# fine. # fine.
from configmodule import getConfigValue, getConfigValueBool
import sys # For exit_on_session_end hack
CONNLEVEL_100_APPL_RUNNING = 100 CONNLEVEL_100_APPL_RUNNING = 100
CONNLEVEL_80_TCP_RUNNING = 80 CONNLEVEL_80_TCP_RUNNING = 80
CONNLEVEL_50_SDP_DONE = 50 CONNLEVEL_50_SDP_DONE = 50
@ -98,6 +101,14 @@ class connMgr():
self.ConnectionLevel=0 self.ConnectionLevel=0
if (self.ConnectionLevelOld!=self.ConnectionLevel): if (self.ConnectionLevelOld!=self.ConnectionLevel):
self.addToTrace("[CONNMGR] ConnectionLevel changed from " + str(self.ConnectionLevelOld) + " to " + str(self.ConnectionLevel)) self.addToTrace("[CONNMGR] ConnectionLevel changed from " + str(self.ConnectionLevelOld) + " to " + str(self.ConnectionLevel))
if ((self.ConnectionLevelOld==100) and (self.ConnectionLevel<100)):
# We had a charging session, and now it is gone.
# Depending on configuration option, we may end the script here.
if getConfigValueBool("exit_on_session_end"):
# TODO: This is a hack. Do this in fsmPev instead?
self.addToTrace("[CONNMGR] Terminating the application.")
sys.exit(0)
self.ConnectionLevelOld = self.ConnectionLevel self.ConnectionLevelOld = self.ConnectionLevel
if ((self.cycles % 33)==0): if ((self.cycles % 33)==0):
# once per second # once per second

View file

@ -83,6 +83,15 @@ Try-out the cooperation of Python with the EXI encoder/decoder:
``` ```
This should run some decoder/encoder tests and report in the end "Number of fails: 0". This should run some decoder/encoder tests and report in the end "Number of fails: 0".
Copy the pyPlc.ini.template into the same directory where pyPlc.py is, and rename it to pyPlc.ini. Edit the settings in this file as you need.
Make some files executable:
```
chmod 744 c55*
chmod 744 pevNoGui.py
chmod 744 starter.sh
```
As first test, use the simulation mode (no need for modems or other hardware). As first test, use the simulation mode (no need for modems or other hardware).
Start the EVSE in simulation mode `sudo python pyPlc.py E S`. Start the EVSE in simulation mode `sudo python pyPlc.py E S`.
Open a second console window, and start here the pev in simulation mode Open a second console window, and start here the pev in simulation mode
@ -111,8 +120,8 @@ In this file, we write the following, to configure the new service:
[Service] [Service]
Type=simple Type=simple
ExecStart=/home/pi/myprogs/pyPlc/starter.sh ExecStart=/home/pi/myprogs/pyPLC/starter.sh
Restart=on-abort Restart=always
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

View file

@ -66,8 +66,11 @@ u_delta_max_for_end_of_precharge = 10
# The serial port and baud rate used for communication. Used # The serial port and baud rate used for communication. Used
# for serial devices like Dieter, OLED-Display and # for serial devices like Dieter, OLED-Display and
# celeron55's measuring and switching device # celeron55's measuring and switching device
serial_port = /dev/ttyS1 # Examples:
serial_baud = 115200 # /dev/ttyS1
# auto
serial_port = auto
serial_baud = 19200
# The target voltage used in the CurrentDemandRequest. # The target voltage used in the CurrentDemandRequest.
# This is a value for first try-outs. Better would # This is a value for first try-outs. Better would

View file

@ -29,13 +29,15 @@ set -euv
# Keep all IPv6 addresses on the interface down event. # Keep all IPv6 addresses on the interface down event.
# Todo: flexible interface name. # Todo: flexible interface name.
# Todo: On raspberry, without NetworkManager, this option does not help. After the down and up (see below), the IPv6 is missing.
sysctl net.ipv6.conf.eth0.keep_addr_on_down=1 sysctl net.ipv6.conf.eth0.keep_addr_on_down=1
# Shut down and activate the interface. # Shut down and activate the interface.
# Todo: Why this needed? # Todo: Why this needed? On raspberry, where the NetworkManager is not runnning, this disturbs, because
ip link set eth0 down # afterwards the pyPlc does not see the interfaces IPv6 address.
# ip link set eth0 down
sleep 1 sleep 1
ip link set eth0 up # ip link set eth0 up
sleep 1 sleep 1
# show the addresses # show the addresses