forked from snaptec/openWB
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
modbus evse DIN implementiert, SDM Abfrage umgebaut
- Loading branch information
Showing
50 changed files
with
254 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,45 @@ | ||
#!/bin/bash | ||
|
||
############### | ||
#SDM630v2 wird mithilfe von https://github.com/gonium/gosdm630 ausgelesen. | ||
#auch für SDM230 nutzbar (L2 und L3 bleiben dann immer 0 | ||
#bezug = bezug soll Modbus ID 2 sein | ||
. /var/www/html/openWB/openwb.conf | ||
|
||
#check ob gonium reader lauft | ||
if ps ax |grep -v grep |grep "sdm630_httpd-linux-arm -s $sdm630modbusbezugsource -d SDM:$sdm630modbusbezugid -u $sdm630modbusbezugport" > /dev/null | ||
if [[ $sdm630modbusbezugsource = *virtual* ]] | ||
then | ||
else | ||
sudo /home/pi/bin/sdm630_httpd-linux-arm -s $sdm630modbusbezugsource -d SDM:$sdm630modbusbezugid -u $sdm630modbusbezugport & | ||
if ps ax |grep -v grep |grep "socat pty,link=$sdm630modbusbezugsource,raw tcp:$sdm630modbusbezuglanip:26" > /dev/null | ||
then | ||
echo "test" > /dev/null | ||
else | ||
sudo socat pty,link=$sdm630modbusbezugsource,raw tcp:$sdm630modbusbezuglanip:26 & | ||
fi | ||
else | ||
echo "echo" > /dev/null | ||
fi | ||
|
||
bezuga1=$(curl -s localhost:8080/last/$sdm630modbusbezugid |jq '.Current.L1' | tr -d '\n' | sed 's/\..*$//') | ||
bezuga2=$(curl -s localhost:8080/last/$sdm630modbusbezugid |jq '.Current.L2' | tr -d '\n' | sed 's/\..*$//') | ||
bezuga3=$(curl -s localhost:8080/last/$sdm630modbusbezugid |jq '.Current.L3' | tr -d '\n' | sed 's/\..*$//') | ||
wattbezug=`curl -s localhost:8080/last/$sdm630modbusbezugid |jq '.Power.L1' | tr -d '\n' | sed 's/\..*$//'` | ||
n=0 | ||
output=$(sudo python /var/www/html/openWB/modules/sdm630modbusbezug/readsdm.py $sdm630modbusbezugsource $sdm630modbusbezugid) | ||
while read -r line; do | ||
if (( $n == 0 )); then | ||
echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/bezuga1 | ||
fi | ||
if (( $n == 1 )); then | ||
echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/bezuga2 | ||
fi | ||
if (( $n == 2 )); then | ||
echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/bezuga3 | ||
fi | ||
if (( $n == 3 )); then | ||
wl1=$(echo "$line" | cut -c2- |sed 's/\..*$//') | ||
fi | ||
if (( $n == 4 )); then | ||
wl2=$(echo "$line" | cut -c2- |sed 's/\..*$//') | ||
fi | ||
if (( $n == 5 )); then | ||
wl3=$(echo "$line" | cut -c2- |sed 's/\..*$//') | ||
fi | ||
|
||
n=$((n + 1)) | ||
done <<< "$output" | ||
|
||
wattbezug=`echo "($wl1+wl2+$wl3)" |bc` | ||
echo $wattbezug > /var/www/html/openWB/ramdisk/wattbezug | ||
echo $bezuga1 > /var/www/html/openWB/ramdisk/bezuga1 | ||
echo $bezuga2 > /var/www/html/openWB/ramdisk/bezuga2 | ||
echo $bezuga3 > /var/www/html/openWB/ramdisk/bezuga3 | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/python | ||
import sys | ||
import os | ||
import time | ||
import getopt | ||
import socket | ||
import ConfigParser | ||
import struct | ||
import binascii | ||
seradd = str(sys.argv[1]) | ||
from pymodbus.client.sync import ModbusSerialClient | ||
client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, | ||
stopbits=1, bytesize=8, timeout=1) | ||
|
||
#rq = client.read_holding_registers(0,8,unit=5) | ||
#print(rq.registers) | ||
sdmid = int(sys.argv[2]) | ||
|
||
resp = client.read_input_registers(0x06,2, unit=sdmid) | ||
|
||
print(struct.unpack('>f',struct.pack('>HH',*resp.registers))) | ||
resp = client.read_input_registers(0x08,2, unit=sdmid) | ||
print(struct.unpack('>f',struct.pack('>HH',*resp.registers))) | ||
resp = client.read_input_registers(0x0A,2, unit=sdmid) | ||
print(struct.unpack('>f',struct.pack('>HH',*resp.registers))) | ||
|
||
resp = client.read_input_registers(0x0C,2, unit=sdmid) | ||
print(struct.unpack('>f',struct.pack('>HH',*resp.registers))) | ||
resp = client.read_input_registers(0x0E,2, unit=sdmid) | ||
print(struct.unpack('>f',struct.pack('>HH',*resp.registers))) | ||
resp = client.read_input_registers(0x10,2, unit=sdmid) | ||
print(struct.unpack('>f',struct.pack('>HH',*resp.registers))) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,34 @@ | ||
#!/bin/bash | ||
|
||
############### | ||
#SDM630v2 wird mithilfe von https://github.com/gonium/gosdm630 ausgelesen. | ||
#auch für SDM230 nutzbar (L2 und L3 bleiben dann immer 0 | ||
#ll = ladeleistung soll Modbus ID 1 sein | ||
# Gonium Tool fragt standard nur ID1 ab | ||
|
||
. /var/www/html/openWB/openwb.conf | ||
|
||
|
||
if [[ $sdm630modbusllsource = *virtual* ]] | ||
then | ||
if ps ax |grep -v grep |grep "socat pty,link=$sdm630modbusllsource,raw tcp:$sdm630modbuslllanip:26" > /dev/null | ||
then | ||
echo "test" > /dev/null | ||
else | ||
sudo socat pty,link=$sdm630modbusllsource,raw tcp:$sdm630modbuslllanip:26 | ||
sudo socat pty,link=$sdm630modbusllsource,raw tcp:$sdm630modbuslllanip:26 & | ||
fi | ||
else | ||
echo "echo" > /dev/null | ||
fi | ||
n=0 | ||
output=$(sudo python /var/www/html/openWB/modules/sdm630modbusll/readsdm.py $sdm630modbusllsource $sdm630modbusllid) | ||
while read -r line; do | ||
|
||
|
||
#check ob gonium reader lauft | ||
if ps ax |grep -v grep |grep "sdm630_httpd-linux-arm -s $sdm630modbusllsource -d SDM:$sdm630modbusllid -u $sdm630modbusllport" > /dev/null | ||
then | ||
echo "test" > /dev/null | ||
else | ||
sudo /home/pi/bin/sdm630_httpd-linux-arm -s $sdm630modbusllsource -d SDM:$sdm630modbusllid -u $sdm630modbusllport & | ||
if (( $n == 0 )); then | ||
echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/lla1 | ||
fi | ||
if (( $n == 1 )); then | ||
echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/lla2 | ||
fi | ||
if (( $n == 2 )); then | ||
echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/lla3 | ||
fi | ||
if (( $n == 3 )); then | ||
echo "$line" | cut -c2- |sed 's/\..*$//' > /var/www/html/openWB/ramdisk/llaktuell | ||
fi | ||
n=$((n + 1)) | ||
done <<< "$output" | ||
|
||
|
||
lla1=$(curl -s localhost:8080/last/$sdm630modbusllid |jq '.Current.L1' | tr -d '\n' | sed 's/\..*$//') | ||
lla2=$(curl -s localhost:8080/last/$sdm630modbusllid |jq '.Current.L2' | tr -d '\n' | sed 's/\..*$//') | ||
lla3=$(curl -s localhost:8080/last/$sdm630modbusllid |jq '.Current.L3' | tr -d '\n' | sed 's/\..*$//') | ||
ladeleistung=`curl -s localhost:8080/last/$sdm630modbusllid |jq '.Power.L1' | tr -d '\n' | sed 's/\..*$//'` | ||
|
||
|
||
echo $ladeleistung > /var/www/html/openWB/ramdisk/llaktuell | ||
echo $lla1 > /var/www/html/openWB/ramdisk/lla1 | ||
echo $lla2 > /var/www/html/openWB/ramdisk/lla2 | ||
echo $lla3 > /var/www/html/openWB/ramdisk/lla3 | ||
|
||
wattbezugint=0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/python | ||
import sys | ||
import os | ||
import time | ||
import getopt | ||
import socket | ||
import ConfigParser | ||
import struct | ||
import binascii | ||
seradd = str(sys.argv[1]) | ||
from pymodbus.client.sync import ModbusSerialClient | ||
client = ModbusSerialClient(method = "rtu", port=seradd, baudrate=9600, | ||
stopbits=1, bytesize=8, timeout=1) | ||
|
||
#rq = client.read_holding_registers(0,8,unit=5) | ||
#print(rq.registers) | ||
sdmid = int(sys.argv[2]) | ||
|
||
resp = client.read_input_registers(0x06,2, unit=sdmid) | ||
|
||
print(struct.unpack('>f',struct.pack('>HH',*resp.registers))) | ||
resp = client.read_input_registers(0x08,2, unit=sdmid) | ||
print(struct.unpack('>f',struct.pack('>HH',*resp.registers))) | ||
resp = client.read_input_registers(0x0A,2, unit=sdmid) | ||
print(struct.unpack('>f',struct.pack('>HH',*resp.registers))) | ||
|
||
resp = client.read_input_registers(0x0C,2, unit=sdmid) | ||
print(struct.unpack('>f',struct.pack('>HH',*resp.registers))) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0 | ||
1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0 | ||
16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0 | ||
3678 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0 | ||
1032 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
33 | ||
87 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1391 | ||
4529 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.