~ubuntu-branches/debian/jessie/digitemp/jessie

« back to all changes in this revision

Viewing changes to python/gui/dttest.py

  • Committer: Bazaar Package Importer
  • Author(s): Jesus Roncero
  • Date: 2004-09-01 01:34:37 UTC
  • Revision ID: james.westby@ubuntu.com-20040901013437-eicsrrd40dr371u0
Tags: upstream-3.3.2
ImportĀ upstreamĀ versionĀ 3.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/env python
 
2
 
 
3
# Initalize the indicated serial port and continuously read the temperatures
 
4
# and graph them in a window. Show the discovered sensors and allow the user
 
5
# to select the color associated with it. 
 
6
# Also allow them to control the refresh rate.
 
7
 
 
8
""" DigiTemp PyGTK Graph display """
 
9
 
 
10
import string, os, sys, time, gtk
 
11
 
 
12
 
 
13
dt = {}
 
14
 
 
15
# Initalize the 1-wire network, print out whatever it says
 
16
def init_1wire():
 
17
   cmd = "digitemp -i -q -o\"T %R %N %.2C\" -O\"C %R %N %n %C\""
 
18
   for outline in os.popen(cmd).readlines()
 
19
      outline = outline[:-1];
 
20
      print outline
 
21
 
 
22
   # Ought to be able to check return code for success/failure
 
23
 
 
24
 
 
25
# Read all attached sensors
 
26
def read_sensors():
 
27
   cmd = "digitemp -a -q -o1"
 
28
   for outline in os.popen(cmd).readlines():
 
29
      outline = outline[:-1]
 
30
      S = string.split( outline, " " )
 
31
 
 
32
      if S[0] == 'T':
 
33
         # Add the temperature reading to a dictionary
 
34
         dt[S[1]] = S[3]
 
35
 
 
36
      if S[0] == 'C':
 
37
         # Add the counter reading to a dictionary
 
38
         dt[S[1]] = S[3]
 
39
 
 
40
 
 
41
         
 
 
b'\\ No newline at end of file'