/[svn.andrew.net.au]/scripts/read-temperature.py
ViewVC logotype

Diff of /scripts/read-temperature.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 19 by apollock, Sun May 27 18:28:36 2007 UTC revision 22 by apollock, Sun May 27 19:46:53 2007 UTC
# Line 30  except ImportError: Line 30  except ImportError:
30      "try checking the python-serial package is installed"      "try checking the python-serial package is installed"
31    
32  from optparse import OptionParser  from optparse import OptionParser
33    import sys
34    
35  SENSOR_QUERY_CMD = (None, 'S', 'T', 'U')  SENSOR_QUERY_CMD = (None, 'S', 'T', 'U')
36  USAGE = "usage: %prog [options] [action]"  USAGE = "usage: %prog [options] [action]"
# Line 55  parser.add_option("--mrtg", action="stor Line 56  parser.add_option("--mrtg", action="stor
56  if not(options.sensor > 0 and options.sensor <= len(SENSOR_QUERY_CMD) - 1):  if not(options.sensor > 0 and options.sensor <= len(SENSOR_QUERY_CMD) - 1):
57    parser.error("Invalid sensor")    parser.error("Invalid sensor")
58    
59  ser = serial.Serial(options.device, 9600, timeout=1)  try:
60      ser = serial.Serial(options.device, 9600, timeout=1)
61    except serial.SerialException, e:
62      print "%s" % (e)
63      sys.exit(1)
64    
65  ser.write(SENSOR_QUERY_CMD[options.sensor])  ser.write(SENSOR_QUERY_CMD[options.sensor])
66  buf = ser.read(8)  buf = ser.read(8)

Legend:
Removed from v.19  
changed lines
  Added in v.22

  ViewVC Help
Powered by ViewVC 1.1.22