Site Tools


linux:raspberry:wde:scripts:reader

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
linux:raspberry:wde:scripts:reader [2015/06/15 15:42] lunetikklinux:raspberry:wde:scripts:reader [2018/12/20 17:40] – Discussion status changed lunetikk
Line 7: Line 7:
 This will execute socat with daily modified parameters. The logfile parameter will have the date of "today". It starts at 12:02 am everyday. This will execute socat with daily modified parameters. The logfile parameter will have the date of "today". It starts at 12:02 am everyday.
  
-<code sh wde.sh>+<code bash wde.sh>
 #!/bin/bash #!/bin/bash
  
Line 13: Line 13:
 FILETYPE=.log FILETYPE=.log
  
-nohup /usr/bin/perl /wde/wde_reader.pl /dev/ttyUSB0 /media/weatherlog/$DATE$FILETYPE </dev/null >/wde/wde1_reader.out &+if [ -f "/media/weatherlog/$DATE$FILETYPE" ]; then 
 +echo ""/dev/null 
 +else 
 +echo "Date;Time;Column1;Column2;Column3;Column4;Column5;Column6;Column7;Column8;Column9;Column10;Column11;Column12;Column13;Column14;Column15;Column16;Column17;Column18;Column19;Column20;Column21;Column22;Column23;Column24;Column25"/media/weatherlog/$DATE$FILETYPE 
 +fi 
 + 
 +nohup /wde/wde_reader.sh </dev/null >/wde/wde_reader.out &
 echo $! >/wde/wde_reader.pid echo $! >/wde/wde_reader.pid
 </code> </code>
Line 19: Line 25:
 ==== Script 2 - Reader ==== ==== Script 2 - Reader ====
  
-This script is a cutted version from [[http://wetter.tdressler.net/Download/wde1_reader.txt|tdressler.net]]. Instead of writing things into 2 files and other things this script will only write 1 file with a single outputline, started with the date and time.+This script will write 1 file with a single outputline, started with the date and time.
  
-<code perl wde_reader.pl+<code bash wde_reader.sh
-#!/usr/bin/env perl+#!/bin/bash
  
-use strict; +DATE=`date +%d_%m_%Y` 
-use IO::Handle; +FILETYPE=.log
-use Time::Piece;+
  
-my $dev=$ARGV[0]||'/dev/ttyUSB0'; +FILE=/media/weatherlog/$DATE$FILETYPE
-my $socat='/usr/bin/socat'; +
-my $cmd="$socat $dev,b9600 STDOUT |"; +
-my $log=$ARGV[1]||"/tmp/wde1.log";+
  
 +SOCAT=/usr/bin/socat
 +DEV=/dev/ttyUSB0
 +BAUD=\,b9600
 +CMD="$SOCAT $DEV$BAUD STDOUT"
  
-$SIG{QUIT}=$SIG{INT}=$SIG{TERM}=\&handler; +while read -r line 
-$SIG{HUP}=$SIG{PIPE}='IGNORE'; +do 
- +    echo "$(date +'%d.%m.%Y;%H:%M:%S;')$line">> $FILE 
-$|=1; +done < <( $CMD )
- +
-open (S,$cmd) ||die "Cannot open $dev using $cmd ($!)\n"; +
-open(R,">>","$log") ||die "Cannot open logfile $log!\n"; +
- +
-R->autoflush(1); +
- +
-while (<S>) { +
-        my $date = localtime->strftime('%d.%m.%Y;%H:%M:%S;')+
- print R "$date$_"; +
-}+
 </code> </code>
  
Line 54: Line 50:
 This script is killing socat everyday at 11:58 pm. Remember, it will start again at 12:02 am with a new date. This script is killing socat everyday at 11:58 pm. Remember, it will start again at 12:02 am with a new date.
  
-<code sh wdekill.sh>+<code bash wdekill.sh>
 #!/bin/bash #!/bin/bash
  
-sudo kill -9 `cat /wde/wde1_reader.pid` +sudo kill -9 `cat /wde/wde_reader.pid` 
-sudo rm /wde/wde1_reader.pid +sudo rm /wde/wde_reader.pid
 </code> </code>
  
 ==== Output ==== ==== Output ====
  
-There will be a new logfile with another date everyday. +There will be a new logfile with another date everyday. 
 + 
 +Examplefile 06_05_2015.log:
  
-Examplefile 05_06_2015.log: 
 <code> <code>
 06.05.2015;16:00:26;$1;1;;34,8;71,1;;;33,1;;;;33;;;;39;;;;;;;;;0 06.05.2015;16:00:26;$1;1;;34,8;71,1;;;33,1;;;;33;;;;39;;;;;;;;;0
-06.05.2015;16:00:26; 
 06.05.2015;16:02:06;$1;1;;34,8;71,1;;;33,1;;;;33;;;;39;;;;;;;;;0 06.05.2015;16:02:06;$1;1;;34,8;71,1;;;33,1;;;;33;;;;39;;;;;;;;;0
-06.05.2015;16:02:06; 
 06.05.2015;16:02:29;$1;1;;34,8;71,0;;;33,1;;;;33;;;;39;;;;;;;;;0 06.05.2015;16:02:29;$1;1;;34,8;71,0;;;33,1;;;;33;;;;39;;;;;;;;;0
-06.05.2015;16:02:29; 
 06.05.2015;16:03:24;$1;1;;34,8;71,0;;;33,1;;;;33;;;;39;;;;;;;;;0 06.05.2015;16:03:24;$1;1;;34,8;71,0;;;33,1;;;;33;;;;39;;;;;;;;;0
-06.05.2015;16:03:24; 
 06.05.2015;16:04:58;$1;1;;34,8;71,0;;;33,0;;;;33;;;;36;;;;;;;;;0 06.05.2015;16:04:58;$1;1;;34,8;71,0;;;33,0;;;;33;;;;36;;;;;;;;;0
-06.05.2015;16:04:58; 
 06.05.2015;16:05:24;$1;1;;34,8;71,0;;;33,0;;;;33;;;;36;;;;;;;;;0 06.05.2015;16:05:24;$1;1;;34,8;71,0;;;33,0;;;;33;;;;36;;;;;;;;;0
-06.05.2015;16:05:24; 
 06.05.2015;16:06:22;$1;1;;34,8;71,0;;;33,0;;;;33;;;;36;;;;;;;;;0 06.05.2015;16:06:22;$1;1;;34,8;71,0;;;33,0;;;;33;;;;36;;;;;;;;;0
-06.05.2015;16:06:22; 
 </code> </code>
  
 \\ \\
-\\ +~~DISCUSSION:closed~~ 
-~~DISCUSSION~~+ 
linux/raspberry/wde/scripts/reader.txt · Last modified: 2019/12/10 14:43 by lunetikk