Register
It is currently Mon Nov 24, 2014 8:58 am

Terminal to rrdtool- for a float


All times are UTC - 6 hours


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Mon Nov 30, 2009 4:10 am   

Joined: Mon Nov 30, 2009 4:06 am
Posts: 16
Im recording a float which arrives on /dev/ttyUSB0 and looks like this
-
Code:
9.87,-10.00,-10.12,-10.25,-10.50,-10.50,-10.62,-10.75,-10.75,
-10.75,-10.87,-10.87,-10.87,-11.00,-11.12,-11.12,-11.25,-11.25,
-11.25,-11.37,-11.37,-11.37,-11.37,-11.50,-11.50,-11.50,-11.62,
-11.62,-11.62,-11.62,-11.62,-11.75,-11.75,-11.75,-11.75,-11.87,


I am trying to set the tty and trf the value to a round robin database with the following script.
Code:
#!/bin/bash
cat </dev/ttyUSB1 >> fromarduino &
temp1= tail -c7 fromarduino
rrdupdate freezer.rrd N:`${temp1%%,}`
echo `${temp1%%,}`
date > arduinolastdate
stty -F /dev/ttyUSB1 cs6 9600 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts -clocal sane
# run this with the command " nohup bash myscript < /dev/null > sh.err 2>&1 "

#Experimental
for (( c=1; c<=60; c++ ))
do
   value=`cat fromarduino|cut -d ',' -f $c`
   let $value=$value   
   let total=$total+$value
   let average=$total/60
done
rrdtool update number.rrd -t number N:$average
#rrdtool create number.rrd -s 60 DS:number:GAUGE:120:0:1000 RRA:AVERAGE:0.5:1:44640   #  This is the command to create the database, 44640 = number of minutes in a month of 31 days

I can obtain the variable "temp1" OK but it seems I cannot get it into the rrd database . It says NaN on the dump - Not a Number
I suppose it is being fed a string rather than a float but I understood it could handle a negative float.
Can anybody help? The top 7 lines are what I'm using and the last 10 or so lines are just me playing around with other code I found

I created the "rrd" database with this command

Code:
rrdtool create freezer.rrd --step 30 \
    DS:temp:GAUGE:60:-50.00:100.00 \
         RRA:AVERAGE:0.5:1:250
         RRA:AVERAGE:0.5:12:250


Top
 Profile  
 PostPosted: Wed Jun 27, 2012 12:57 am   

Joined: Mon Nov 30, 2009 4:06 am
Posts: 16
I thought I might just bump this as maybe there are a few more members now


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP