annotate web/test.py @ 110:4eb5a746d7af avr-http

Import avrusbmodem code minus the USB bits. Not built yet.
author Matt Johnston <matt@ucc.asn.au>
date Sat, 15 Sep 2012 21:49:05 +0800
parents ca08442635ca
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
29
048143905092 work on web interface
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1 #!/usr/bin/env python
048143905092 work on web interface
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2 import time
75
ca08442635ca report raw ds18b20 values instead
Matt Johnston <matt@ucc.asn.au>
parents: 29
diff changeset
3 import struct
ca08442635ca report raw ds18b20 values instead
Matt Johnston <matt@ucc.asn.au>
parents: 29
diff changeset
4 import sys
ca08442635ca report raw ds18b20 values instead
Matt Johnston <matt@ucc.asn.au>
parents: 29
diff changeset
5 import binascii
29
048143905092 work on web interface
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6
75
ca08442635ca report raw ds18b20 values instead
Matt Johnston <matt@ucc.asn.au>
parents: 29
diff changeset
7 def convert_ds18b20_12bit(reading):
ca08442635ca report raw ds18b20 values instead
Matt Johnston <matt@ucc.asn.au>
parents: 29
diff changeset
8 value = struct.unpack('>h', binascii.unhexlify(reading))[0]
ca08442635ca report raw ds18b20 values instead
Matt Johnston <matt@ucc.asn.au>
parents: 29
diff changeset
9 return value * 0.0625
ca08442635ca report raw ds18b20 values instead
Matt Johnston <matt@ucc.asn.au>
parents: 29
diff changeset
10
ca08442635ca report raw ds18b20 values instead
Matt Johnston <matt@ucc.asn.au>
parents: 29
diff changeset
11 if __name__ == '__main__':
ca08442635ca report raw ds18b20 values instead
Matt Johnston <matt@ucc.asn.au>
parents: 29
diff changeset
12 print convert_ds18b20_12bit(sys.argv[1])