I am running a number of 4 ch A/D 1wire chips on my network.  The 1wire cable 
runs in parallel with a 24VDC cable that energises some solenoids.  When the 
solenoid turns on I get a read error on my 1wire bus on a random channel of the 
A/D chip.  I've tried diodes across my solenoid etc etc however cannot seem to 
track down the root cause so I thought I would try and mask the problem in my 
script file, and here lies my question:

As it only has 1 read error I thought i'd trap it.  I assumed that the reading 
was going to be high or lower than an acceptable range however it didn't quite 
go as expected.

Here is an extract of my read script which would normally give a result of 
about 28.x and if outside the boundaries of 5-50 than set the result to "U"

--------------------------------------
### Read 1wire data and convert into engineering units ##
TempAqua=$(/opt/bin/owread $OWSERVER 20.B71F05000000/volt.C | /opt/bin/awk 
'{printf "%3.1f\n",((($0-1)*5)+20)}')

### Out of Range Error trap -Do not log data ###
TEMPtest=`echo $TempAqua |cut -f1 -d'.'`
if [ $TEMPtest -gt 50 ] || [ $TEMPtest -lt 5 ]; then
TempAqua=U
echo "`date` Aquarium Temp reading error, value $TempAqua" >>/public/nohup.out
fi
--------------------------------------

As I start the read stript now with nohup I can see the error via nohup.out 
(which is very handy)...
Data error on 20.B71F05000000/volt.C
./aquaread: line 41: [: -gt: unary operator expected
./aquaread: line 41: [: -lt: unary operator expectedSo my error trap didn't 
work as expected as the result was not unary (what ever that means !)


Does anybody have any other idea's on how to trap a read error within my bash 
script.  The values are fed into a trend package and I average three readings 
every 5 minutes and store to an rrd database.  When I get a read error it 
produces a spike in my trend.

Cheers

rob







-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Owfs-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/owfs-developers

Reply via email to