There is still no switch in sdm120c to disable OK, but you can try with:hryst wrote:Hello
how to turn off the message "OK" at the end of a query result
sdm120c -p -q /dev/ttyUSB0
286.70 OK
Code: Select all
sdm120c -p -q /dev/ttyUSB0 | cut -d' ' -f1
There is still no switch in sdm120c to disable OK, but you can try with:hryst wrote:Hello
how to turn off the message "OK" at the end of a query result
sdm120c -p -q /dev/ttyUSB0
286.70 OK
Code: Select all
sdm120c -p -q /dev/ttyUSB0 | cut -d' ' -f1
Code: Select all
<?php
/*
Start and stop in metern/config/config_daemon.php
php /srv/http/comapps/sdm_daemon.php { start | stop }
Then, request values with these commands :
cat /tmp/metern_log.txt | egrep "^1_V\(" | grep "*V)"
cat /tmp/metern_log.txt | egrep "^1_F\(" | grep "*Hz)"
cat /tmp/metern_log.txt | egrep "^1_PF\(" | grep "*F)"
cat /tmp/metern_log.txt | egrep "^1_IE\(" | grep "*Wh)"
cat /tmp/metern_log.txt | egrep "^1_EE\(" | grep "*Wh)"
cat /tmp/metern_log.txt | egrep "^1_P\(" | grep "*W)"
*/
if (isset($_SERVER['REMOTE_ADDR'])) {
die('Direct access not permitted');
}
$SCRDIR = dirname(__FILE__);
if (file_exists($SCRDIR . '/sdm_daemon.pid')) {
$pid = (int) file_get_contents($SCRDIR . '/sdm_daemon.pid');
} else {
$pid = null;
}
if (isset($argv[1])) {
if (($argv[1] == 'start' || $argv[1] == 'stop') && file_exists('/tmp/metern_log.txt')) {
unlink('/tmp/metern_log.txt');
}
if ($argv[1] == 'start') {
if (is_null($pid)) {
$command = 'php /srv/http/comapps/sdm_daemon_loop.php' . ' > /dev/null 2>&1 & echo $!;';
$pid = exec($command);
file_put_contents($SCRDIR . '/sdm_daemon.pid', $pid);
} else {
echo "sdm_daemon seem to be running as $pid";
}
} else if ($argv[1] == 'stop') {
if (!is_null($pid)) {
$command = exec("kill -9 $pid > /dev/null 2>&1 &");
}
unlink($SCRDIR . '/sdm_daemon.pid');
} else {
echo "Usage : sdm_daemon {start | stop}\n";
}
} else {
echo "Usage : sdm_daemon {start | stop}\n";
}
?>
Code: Select all
<?php
if (isset($_SERVER['REMOTE_ADDR'])) {
die('Direct access not permitted');
}
while (true) {
$dataarray = array();
$output = exec('sdm120c -a1 -b9600 -z3 -2 -qpievfg /dev/sdm');
$dataarray = preg_split('/[[:space:]]+/', $output);
if (!isset($dataarray[6])) {
$dataarray[6] = 'NOK';
}
if ($dataarray[6] == 'OK') { // Make sure the frame is complete before filling the tmp file
$dataarray[0] = '1_V(' . $dataarray[0] . '*V)';
$dataarray[1] = '1_P(' . $dataarray[1] . '*W)';
$dataarray[2] = '1_PF(' . $dataarray[2] . '*F)';
$dataarray[3] = '1_F(' . $dataarray[3] . '*Hz)';
$dataarray[4] = '1_IE(' . $dataarray[4] . '*Wh)';
$dataarray[5] = '1_EE(' . $dataarray[5] . '*Wh)';
$str = implode(PHP_EOL, $dataarray);
file_put_contents('/tmp/metern_log.txt', $str);
} else {
$now = time();
if ($now - filemtime('/tmp/metern_log.txt') >= 5) { // 5 sec
unlink('/tmp/metern_log.txt');
}
}
usleep(500000);
}
?>
Users browsing this forum: No registered users and 1 guest