Skip to content

Commit

Permalink
First upload
Browse files Browse the repository at this point in the history
  • Loading branch information
gianfrdp committed Apr 29, 2015
1 parent a1eaf31 commit fa9fe1e
Show file tree
Hide file tree
Showing 8 changed files with 1,790 additions and 0 deletions.
Binary file added 123solar/123solar1.5.5.tar.gz
Binary file not shown.
1,534 changes: 1,534 additions & 0 deletions 123solar/123solar_pdc-1.5.5-5.diff

Large diffs are not rendered by default.

75 changes: 75 additions & 0 deletions metern/comapps/pool123-1.5.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?php
if ($_SERVER['SERVER_ADDR'] != '127.0.0.1' && $_SERVER['SERVER_ADDR'] != 'localhost') {
die('Direct access not permitted');
}

// This script will output a 123solar counter into a meterN compatible format
// You'll need to setup the path to 123, your inverter number and your meter id
// Request live command with "curl http://localhost/metern/comapps/pool123solar.php?cmd=1"
// Main command with "curl http://localhost/metern/comapps/pool123solar.php?cmd=2"

$pathto123s = '/srv/http/123solar';
//$pathto123s = '/var/www/123solar';
// for multiple inverters
$invtnums = array (0 => 1, 1 => 2);
$meterid = 4;
//$server = 'http://192.168.2.12/123solar/programs/programmultilive.php';
$server = 'http://localhost/123solar/programs/programmultilive.php';

//parse_str(implode('&', array_slice($argv, 1)), $_GET);

// No edit is needed below
if (!empty($_GET['cmd']) && is_numeric($_GET['cmd'])) {
$cmd = $_GET['cmd'];
} else {
die('Wrong command');
}

define('checkaccess', TRUE);
include("$pathto123s/config/config_main.php");
include("$pathto123s/scripts/memory.php");

date_default_timezone_set($DTZ);

$KWHT = 0;

if ($cmd == 2) {

for ($i = 0; $i < count($invtnums); $i++) {
$invtnum = $invtnums[$i];
include("$pathto123s/config/config_invt$invtnum.php");

$dir = $pathto123s . '/data/invt' . $invtnum . '/csv';
$output = glob($dir . "/*.csv");
sort($output);
$xdays = count($output);
if ($xdays > 1) {
$lastlog = $output[$xdays - 1];
$lines = file($lastlog);
$contalines = count($lines);
$array_last = preg_split('/,/', $lines[$contalines - 1]);

$KWHT += round(($array_last[14] * ${'CORRECTFACTOR'} * 1000), 0); //in Wh
} else {
$KWHT += 0;
}
}

echo "$meterid($KWHT*Wh)\n";
} elseif ($cmd == 1) {

$GP = 0;

$data = file_get_contents($server);
$memarray = json_decode($data, true);
$GP = $memarray[0]['GPTOT'];
if ($GP > 1000) {
$GP = round($GP, 0);
} else {
$GP = round($GP, 1);
}

echo "$meterid($GP*W)\n";
}

?>
78 changes: 78 additions & 0 deletions metern/programs/meter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php
// Credit Louviaux Jean-Marc 2015
define('checkaccess', TRUE);
include('../config/config_main.php');
include('../scripts/memory.php');
date_default_timezone_set($DTZ);

$dir = '../data/csv/';
$output = glob($dir . '/*.csv');
rsort($output);

@$shmid = shmop_open($LIVEMEMORY, 'a', 0, 0);
if (!empty($shmid) && isset($output[0])) {
$size = shmop_size($shmid);
shmop_close($shmid);
$shmid = shmop_open($LIVEMEMORY, 'c', 0644, $size);
$memdata = shmop_read($shmid, 0, $size);
$live = json_decode($memdata, true);
shmop_close($shmid);

$array = array();
for ($i = 1; $i <= $NUMMETER; $i++) {
include("../config/config_met$i.php");

if (${'TYPE' . $i} != 'Sensor') {
$file = file($output[0]);
$month = substr($output[0], -8, 2);
$day = substr($output[0], -6, 2);
$contalines = count($file);
$prevarray = preg_split('/,/', $file[1]);
$linearray = preg_split('/,/', $file[$contalines - 1]);

$val_first = $prevarray[$i];
$val_last = $linearray[$i];
settype($val_first, 'float');
settype($val_last, 'float');

if (${'TYPE' . $i} == 'Elect') {
$val_tot = $val_last / 1000;
$val_tot = $val_last;
} else {
settype(${'PRECI' . $i}, 'integer');
$val_tot = $val_last;
$prefix = '';
}
} else {
$val_tot = 0;
$val_last = 0;
}

$data["Totalcounter$i"] = $val_tot;

if ($val_first <= $val_last) {
$val_last -= $val_first;
} else { // counter pass over
$val_last += ${'PASSO' . $metnum} - $val_first;
}

if (${'TYPE' . $i} == 'Elect') {
$val_last /= 1000;
} else {
settype(${'PRECI' . $i}, 'integer');
}
$data["Dailycounter$i"] = $val_last;

$array["${'METNAME'.$i}$i"] = array("KW" => $live["${'METNAME'.$i}$i"], "KWH" => round($data["Dailycounter$i"],${'PRECI' . $i}));
}
} else {
for ($i = 1; $i <= $NUMMETER; $i++) {
include("../config/config_met$i.php");

$array["${'METNAME'.$i}$i"] = array("KW" => 0, "KWH" => 0);
}
}

header("Content-type: text/json");
echo json_encode($array);
?>
Binary file added redis/pi/phpredis-2.2.4-1_armhf.deb
Binary file not shown.
Binary file added redis/pogo/phpredis-2.2.4-1_armel.deb
Binary file not shown.
Binary file added redis/src/phpredis-2.2.4.src.tar.bz2
Binary file not shown.
103 changes: 103 additions & 0 deletions webiopi/WebIOPi-0.7.1.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
diff -u -r WebIOPi-0.7.1.orig/htdocs/webiopi.js WebIOPi-0.7.1/htdocs/webiopi.js
--- WebIOPi-0.7.1.orig/htdocs/webiopi.js 2014-02-23 17:37:07.000000000 +0100
+++ WebIOPi-0.7.1/htdocs/webiopi.js 2015-03-21 00:18:38.247504315 +0100
@@ -73,7 +73,7 @@
this.readyCallback = null;
this.context = "/";
this.GPIO = Array(54);
- this.PINS = Array(27);
+ this.PINS = Array(41);

this.TYPE = {
DNC: {value: 0, style: "DNC", label: "--"},
@@ -577,7 +577,7 @@
RPiHeader.prototype.createTable = function (containerId) {
var table = $("<table>");
table.attr("id", "RPiHeader")
- for (var pin=1; pin<=26; pin++) {
+ for (var pin=1; pin<=40; pin++) {
var line = $('<tr>');
line.append(this.getFunctionCell(pin))
line.append(this.getDescriptionCell(pin, "right"))
diff -u -r WebIOPi-0.7.1.orig/python/native/cpuinfo.c WebIOPi-0.7.1/python/native/cpuinfo.c
--- WebIOPi-0.7.1.orig/python/native/cpuinfo.c 2012-10-28 22:26:10.000000000 +0100
+++ WebIOPi-0.7.1/python/native/cpuinfo.c 2015-03-20 23:03:56.552367425 +0100
@@ -37,7 +37,10 @@
while(!feof(fp)) {
fgets(buffer, sizeof(buffer) , fp);
sscanf(buffer, "Hardware : %s", hardware);
- if (strcmp(hardware, "BCM2708") == 0)
+ if (strcmp(hardware, "BCM2708") == 0 ||
+ strcmp(hardware, "BCM2709") == 0 ||
+ strcmp(hardware, "BCM2835") == 0 ||
+ strcmp(hardware, "BCM2836") == 0)
rpi_found = 1;
sscanf(buffer, "Revision : %s", revision);
}
diff -u -r WebIOPi-0.7.1.orig/python/native/gpio.c WebIOPi-0.7.1/python/native/gpio.c
--- WebIOPi-0.7.1.orig/python/native/gpio.c 2013-02-03 23:04:18.000000000 +0100
+++ WebIOPi-0.7.1/python/native/gpio.c 2015-03-20 22:58:22.453452062 +0100
@@ -20,6 +20,7 @@
SOFTWARE.
*/

+#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
@@ -29,8 +30,8 @@
#include <pthread.h>
#include "gpio.h"

-#define BCM2708_PERI_BASE 0x20000000
-#define GPIO_BASE (BCM2708_PERI_BASE + 0x200000)
+#define BCM2708_PERI_BASE_DEFAULT 0x20000000
+#define GPIO_BASE_OFFSET 0x200000
#define FSEL_OFFSET 0 // 0x0000
#define SET_OFFSET 7 // 0x001c / 4
#define CLR_OFFSET 10 // 0x0028 / 4
@@ -71,6 +72,22 @@
{
int mem_fd;
uint8_t *gpio_mem;
+ uint32_t peri_base = BCM2708_PERI_BASE_DEFAULT;
+ uint32_t gpio_base;
+ unsigned char buf[4];
+ FILE *fp;
+
+ // get peri base from device tree
+ if ((fp = fopen("/proc/device-tree/soc/ranges", "rb")) != NULL) {
+ fseek(fp, 4, SEEK_SET);
+ if (fread(buf, 1, sizeof buf, fp) == sizeof buf) {
+ peri_base = buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3] << 0;
+
+ }
+ fclose(fp);
+ }
+
+ gpio_base = peri_base + GPIO_BASE_OFFSET;

if ((mem_fd = open("/dev/mem", O_RDWR|O_SYNC) ) < 0)
{
@@ -83,7 +100,7 @@
if ((uint32_t)gpio_mem % PAGE_SIZE)
gpio_mem += PAGE_SIZE - ((uint32_t)gpio_mem % PAGE_SIZE);

- gpio_map = (uint32_t *)mmap( (caddr_t)gpio_mem, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED, mem_fd, GPIO_BASE);
+ gpio_map = (uint32_t *)mmap( (caddr_t)gpio_mem, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED, mem_fd, gpio_base);

if ((uint32_t)gpio_map < 0)
return SETUP_MMAP_FAIL;
diff -u -r WebIOPi-0.7.1.orig/python/webiopi/utils/version.py WebIOPi-0.7.1/python/webiopi/utils/version.py
--- WebIOPi-0.7.1.orig/python/webiopi/utils/version.py 2015-02-04 21:21:44.000000000 +0100
+++ WebIOPi-0.7.1/python/webiopi/utils/version.py 2015-03-21 00:19:56.627251593 +0100
@@ -8,8 +8,7 @@

_MAPPING = [[], [], []]
_MAPPING[1] = ["V33", "V50", 0, "V50", 1, "GND", 4, 14, "GND", 15, 17, 18, 21, "GND", 22, 23, "V33", 24, 10, "GND", 9, 25, 11, 8, "GND", 7]
-_MAPPING[2] = ["V33", "V50", 2, "V50", 3, "GND", 4, 14, "GND", 15, 17, 18, 27, "GND", 22, 23, "V33", 24, 10, "GND", 9, 25, 11, 8, "GND", 7]
-
+_MAPPING[2] = ["V33", "V50", 2, "V50", 3, "GND", 4, 14, "GND", 15, 17, 18, 27, "GND", 22, 23, "V33", 24, 10, "GND", 9, 25, 11, 8, "GND", 7, "DNC", "DNC" , 5, "GND", 6, 12, 13, "GND", 19, 16, 26, 20, "GND", 21]

try:
with open("/proc/cpuinfo") as f:

0 comments on commit fa9fe1e

Please sign in to comment.