OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 | 2 |
| 3 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. |
| 6 |
3 import re | 7 import re |
4 import sys | 8 import sys |
5 import time | 9 import time |
6 | 10 |
7 import dbus | 11 import dbus |
8 import mm | 12 import mm |
9 | 13 |
10 INTERFACES = ['interface_1_dbm', 'interface_2_dbm'] | 14 INTERFACES = ['interface_1_dbm', 'interface_2_dbm'] |
11 | 15 |
12 TIME = 60 | 16 TIME = 60 |
13 SAMPLES = TIME * 2 | 17 SAMPLES = TIME * 2 |
14 | 18 |
15 | 19 |
16 manager = mm.ModemManager() | 20 manager, path = mm.PickOneModem('') |
17 path = mm.PickOneModem(manager, '') | |
18 simple_modem = manager.SimpleModem(path) | 21 simple_modem = manager.SimpleModem(path) |
19 | 22 |
20 strengths = [] # list of lists where list[i] is dbm for interface #i | 23 strengths = [] # list of lists where list[i] is dbm for interface #i |
21 start = time.time() | 24 start = time.time() |
22 finish = start + TIME | 25 finish = start + TIME |
23 | 26 |
24 for i in xrange(SAMPLES): | 27 for i in xrange(SAMPLES): |
25 next_reading_time = start + i * (float(TIME) / float(SAMPLES)) | 28 next_reading_time = start + i * (float(TIME) / float(SAMPLES)) |
26 | 29 |
27 # Wait for next reading time | 30 # Wait for next reading time |
(...skipping 25 matching lines...) Expand all Loading... |
53 sum([sample[interface] for sample in strengths]) / | 56 sum([sample[interface] for sample in strengths]) / |
54 float(len(strengths))) | 57 float(len(strengths))) |
55 | 58 |
56 output = ['%.1f' % x for x in [start] + means] | 59 output = ['%.1f' % x for x in [start] + means] |
57 output_string = '\t'.join(output) | 60 output_string = '\t'.join(output) |
58 | 61 |
59 print >> sys.stderr, ( | 62 print >> sys.stderr, ( |
60 time.strftime('%a, %d %b %Y %H:%M:%S local: ', time.localtime()) + | 63 time.strftime('%a, %d %b %Y %H:%M:%S local: ', time.localtime()) + |
61 output_string) | 64 output_string) |
62 print output_string | 65 print output_string |
OLD | NEW |