/Modules/Sensors/ALTIMET01A/SW/Python/data_logger.py
11,34 → 11,38
 
#### Script Arguments ###############################################
 
if len(sys.argv) != 3:
if len(sys.argv) != 2:
sys.stderr.write("Invalid number of arguments.\n")
sys.stderr.write("Usage: %s PORT ADDRESS\n" % (sys.argv[0], ))
sys.exit(1)
 
port = eval(sys.argv[1])
address = eval(sys.argv[2])
 
 
#### Sensor Configuration ###########################################
 
cfg = config.Config(
port = 1,
bus = [
{
"type": "i2chub",
"address": 0x70,
"children": [
{
"type": "i2chub",
"address": 0x70,
"channel": 1,
},
],
},
# {
# "type": "i2chub",
# "address": 0x70,
#
# "children": [
# {
# "type": "i2chub",
# "address": 0x70,
# "channel": 1,
#
# },
# ],
# },
 
{
"name": "altimet",
"type": "altimet01",
},
 
 
],
)
cfg.initialize()
51,10 → 55,12
try:
with open("temperature.log", "a") as f:
while True:
sys.stdout.write("Start measurement now? [ENTER]")
sys.stdin.readline()
(t, p) = gauge.get_tp()
#sys.stdout.write(" Temperature: " + str(t) + " Preassure: " + str(p) + "\r\n")
sys.stdout.write(" Temperature: %.2f Pressure: %d\n" % (t, p, ))
f.write("%d\t%s\t%.2f\t%d\n" % (time.time(), datetime.datetime.now().isoformat(), t, p, ))
sys.stdout.write(" Temperature: %.2f Pressure: %d Note: " % (t, p, ))
note = sys.stdin.readline()
f.write("%d\t%s\t%.2f\t%d\t%s\n" % (time.time(), datetime.datetime.now().isoformat(), t, p, note, ))
sys.stdout.flush()
time.sleep(0.5)
except KeyboardInterrupt: