fredrik.eriksson wrote:
This should create a file named "probe0001" which contains a value from your proc file. It will probe it all the time as soon as it can and should only create a new file when the value has changed.
That is fresh, but the first thing that comes in my mind why copy the contens of a file to another file.
An advantage of this way is that the step times of reading and processing are seperate.
owfs has some way for this too, it has an uncached directory and the cached (normal) dir is refreshed whenever the uncached is accessed, so a read every XXXms would also refresh the normal reading.
fredrik.eriksson wrote:
The second script is something i would do like this:
Code:
#!/bin/bash
while [ true ]; do
file_1=$(ls --color=no /path/to/probe/files/probe_1* | head -n1)
file_2=$(ls --color=no /path/to/probe/files/probe_2* | head -n1)
content_1=$(cat $file_1)
content_2=$(cat $file_2)
Do what ever you want with content_1 and content_2
sleep 1
done
Hope this is a better way of doing it

It's atleast what i would've done.
Best regards
Fredrik Eriksson
I have tried a while to, but the problem is the processing lines beneeth it, there have to be done some calculations for every sensor and all of them together is giving some "lag" and therefore making the rpm reading/calculation unreliable.
That was the main reason for using pid and wait.
At the moment I have almost the same running without the wait function and it does 47 readings per minute but that means the rpm calculation is not reliable so I need to grab it all in a fixed timeframe.
Here the full script as I have so far:
Code:
#!/bin/sh
LANG=C
LC_ALL=C
export LANG LC_ALL
counter_1=$(cat /tmp/owfs/1D.E4D90D000000/counters.A)
read_owfs ()
{
time_step=$(sleep 1) &
time_step_pid=$!
time_stamp=$(date +%y%m%d%H%M%S) &
time_stamp_pid=$!
rpm_1=$(cat /tmp/owfs/1D.E4D90D000000/counters.A)-$counter_1
rpm_eng=$(echo "scale=0;($rpm_1/1)*60/2" | bc)
counter_1=$(cat /tmp/owfs/1D.E4D90D000000/counters.A) &
rpm_eng_pid=$!
pres_trb_air=$(cat /tmp/owfs/26.61D1BC000000/VAD)
pres_trb_air=$(echo "scale=2;(-0.5*($pres_trb_air*$pres_trb_air)+0.2*$pres_trb_air+7)*100" | bc) &
pres_trb_air_pid=$!
pres_eng_oil=$(cat /tmp/owfs/26.61CDBC000000/VAD)
pres_eng_oil=$(echo "scale=2;(0.84*($pres_eng_oil*$pres_eng_oil)+-0.2*$pres_eng_oil+0.5)*100" | bc) &
pres_eng_oil_pid=$!
temp_cyl_1=$(echo "scale=0;$(cat /tmp/owfs/30.03DD95110000/typeK/temperature)/1" | bc) &
temp_cyl_1_pid=$!
temp_cyl_2=$(echo "scale=0;$(cat /tmp/owfs/30.5FDF95110000/typeK/temperature)/1" | bc) &
temp_cyl_2_pid=$!
temp_cyl_3=$(echo "scale=0;$(cat /tmp/owfs/30.4CE495110000/typeK/temperature)/1" | bc) &
temp_cyl_3_pid=$!
temp_cyl_4=$(echo "scale=0;$(cat /tmp/owfs/30.08DD95110000/typeK/temperature)/1" | bc) &
temp_cyl_4_pid=$!
temp_trb_air=$(echo "scale=0;$(cat /tmp/owfs/30.ADDD95110000/typeK/temperature)/1" | bc) &
temp_trb_air_pid=$!
temp_eng_oil="0" &
temp_eng_oil_pid=$!
wait $time_step_pid $time_stamp_pid $temp_cyl_1_pid $temp_cyl_2_pid $temp_cyl_3_pid $temp_cyl_4_pid $temp_trb_air_pid $pres_trb_air_pid $temp_eng_oil_pid $pres_eng_oil_pid $rpm_eng_pid
values=$time_stamp,$temp_cyl_1,$temp_cyl_2,$temp_cyl_3,$temp_cyl_4,$temp_trb_air,$pres_trb_air,$temp_eng_oil,$pres_eng_oil,$rpm_eng
CMD="mysql -u root dlogger -e \"insert into samples values ($values)\""
# `eval $CMD`
echo $CMD
}
while [ 1 ]
do
read_owfs
done
exit 0