Rev Author Line No. Line
3522 kaklik 1 #!/usr/bin/python
2  
3 # Python test script for MLAB ALTIMET01A sensor
4  
5 import time
6 import datetime
7 import sys
8 import serial
9  
10 from pymlab import config
11  
12  
13 #### Script Arguments ###############################################
14  
15 if len(sys.argv) != 2:
16 sys.stderr.write("Invalid number of arguments.\n")
17 sys.stderr.write("Usage: %s #I2CPORT\n" % (sys.argv[0], ))
18 sys.exit(1)
19  
20 port = eval(sys.argv[1])
21  
22  
23 #### Sensor Configuration ###########################################
24  
25 cfg = config.Config(
3526 kaklik 26 i2c = {
27 "port": port,
28 },
29  
3522 kaklik 30 bus = [
31 {
32 "type": "i2chub",
33 "address": 0x72,
34  
35 "children": [
36 {"name": "altimet", "type": "altimet01" , "channel": 7, },
37 ],
38 },
39 ],
40 )
41 cfg.initialize()
42 gauge = cfg.get_device("altimet")
43 time.sleep(0.5)
44  
45 #### Data Logging ###################################################
46  
47 sys.stdout.write("ALTIMET data acquisition system started \n")
48  
49 try:
50 while True:
51 gauge.route()
52 (t1, p1) = gauge.get_tp()
53 sys.stdout.write(" Temperature: %.2f Pressure: %d \n" % (t1, p1))
54 sys.stdout.flush()
55 # time.sleep(0.5)
56  
57 except KeyboardInterrupt:
58 ser.close()
59 sys.exit(0)
60