Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log records #71

Closed
deennoo opened this issue Dec 15, 2014 · 8 comments
Closed

Log records #71

deennoo opened this issue Dec 15, 2014 · 8 comments

Comments

@deennoo
Copy link
Contributor

deennoo commented Dec 15, 2014

Hello,

is this possible to had the possibility to records logs ?

On a CSV format, this way we can use this file as source for any app we want.

@Batilan
Copy link
Contributor

Batilan commented Dec 17, 2014

Hi Denoo, this is a good question. Currently the output of rtl_433 is rather free-format and is determined by the writers of the callback routines. If you are interested in adapting it for specific sensors it wouldn't be too hard to make the output more structured (like csv) yourself. Another possibility is to parse the current output using a scripting language like perl or python and generate csv from that.

At this moment I'm working on a version of rtl_433 that implements plugins for the different callbacks. Once I have the plugin infrastruture ready I planned on creating a generic output interface that can be used from the individual callbacks for writing output in different output formats (like csv). I think also (epoch) timestamps needs to be added so when parsing the output on a later time it is still possible to generate historic data (like required when feeding data in rdd files or graphite/whisper files).

Is this kind of what you are looking for?

@deennoo
Copy link
Contributor Author

deennoo commented Dec 17, 2014

This is, i'm still not enought educated about programing to do it my self.

Using fprintf ?

@deennoo
Copy link
Contributor Author

deennoo commented Dec 17, 2014

Ok got succes.

Using fprintf I start to create a txt file for each protocol, and it works, each time a callback give a result, it create a txt file (by overwriting the one create before).

First Probleme :
On this kind of line
fprintf(stderr, "battery = %s\n",bb[1][1]&0x80?"OK":"Low")

  • stderr is replace by f

fprintf(f, "battery = %s\n",bb[1][1]&0x80?"OK":"Low")

the string is well write on the txt file but nothng is shown on the rtl_433 screen, how can do both ?

@Batilan
Copy link
Contributor

Batilan commented Dec 17, 2014

Please send me a personal message and I will try to help: github at atilas . nl

@deennoo
Copy link
Contributor Author

deennoo commented Jan 6, 2015

i send you a mail, did you recieve it ?

@VigibotDev
Copy link

You can disable the buffering for stdin and stderr, to get grep/awk working

(root|~/rtl_433/src) git diff
diff --git a/src/rtl_433.c b/src/rtl_433.c
index fc85f0d..48406ef 100644
--- a/src/rtl_433.c
+++ b/src/rtl_433.c
@@ -987,6 +987,9 @@ int main(int argc, char **argv) {
     char vendor[256], product[256], serial[256];
     int have_opt_R = 0;

+    setbuf(stdout, NULL);
+    setbuf(stderr, NULL);
+
     demod = malloc(sizeof (struct dm_state));
     memset(demod, 0, sizeof (struct dm_state));

@VigibotDev
Copy link

(root|~) cat rtl_433.sh
#!/bin/bash

dir=/var/www/meteo

/usr/local/bin/rtl_433 \
| tee >(stdbuf -o0 fgrep 'Weather Sensor THGR810  Channel 1' > $dir/TH1.txt) \
| tee >(stdbuf -o0 fgrep 'Weather Sensor THGR810  Channel 2' > $dir/TH2.txt) \
| tee >(stdbuf -o0 fgrep 'Weather Sensor THGR810  Channel 3' > $dir/TH3.txt) \
| tee >(stdbuf -o0 fgrep 'Weather Sensor UVN800 Channel 1' > $dir/UV.txt) \
| tee >(stdbuf -o0 fgrep 'Weather Sensor WGR800' > $dir/WG.txt)

(root|/var/www/meteo) cat TH1.txt
Weather Sensor THGR810 Channel 1 Temp: 9.1C 48.4F Humidity: 90%
Weather Sensor THGR810 Channel 1 Temp: 9.1C 48.4F Humidity: 90%
Weather Sensor THGR810 Channel 1 Temp: 9.1C 48.4F Humidity: 90%

(root|/var/www/meteo) cat WG.txt
Weather Sensor WGR800 Wind Gauge Gust Wind Speed : 0 m/s Wind direction 180 dgrs
Weather Sensor WGR800 Wind Gauge Gust Wind Speed : 2 m/s Wind direction 202 dgrs
Weather Sensor WGR800 Wind Gauge Gust Wind Speed : 1 m/s Wind direction 248 dgrs

And for Cacti :

(root|~) cat /usr/share/cacti/site/scripts/meteo.sh
#!/bin/bash

dir=/var/www/meteo

a=$(cat $dir/TH1.txt | tail -n 1 | tr 'C' ' ' | tr '%' ' ' | awk '{print $7}')
b=$(cat $dir/TH1.txt | tail -n 1 | tr 'C' ' ' | tr '%' ' ' | awk '{print $10}')
c=$(cat $dir/TH2.txt | tail -n 1 | tr 'C' ' ' | tr '%' ' ' | awk '{print $7}')
d=$(cat $dir/TH2.txt | tail -n 1 | tr 'C' ' ' | tr '%' ' ' | awk '{print $10}')
e=$(cat $dir/TH3.txt | tail -n 1 | tr 'C' ' ' | tr '%' ' ' | awk '{print $7}')
f=$(cat $dir/TH3.txt | tail -n 1 | tr 'C' ' ' | tr '%' ' ' | awk '{print $10}')
g=$(cat $dir/UV.txt | tail -n 1 | awk '{print $8}')
h=$(cat $dir/WG.txt | tail -n 1 | awk '{print $10}')
i=$(cat $dir/WG.txt | tail -n 1 | awk '{print $14}')

echo -n T1:$a H1:$b T2:$c H2:$d T3:$e H3:$f UV:$g WS:$h WD:$i

(root|/usr/share/cacti/site/scripts) ./meteo.sh
T1:9.0 H1:90 T2:12.0 H2:71 T3:11.9 H3:62 UV:0 WS:1 WD:248

Result : http://www.serveurperso.net/meteo/

@merbanan
Copy link
Owner

CSV support is added now which should take care of this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants