Line 10... |
Line 10... |
10 |
import time |
10 |
import time |
11 |
import datetime |
11 |
import datetime |
12 |
import sys |
12 |
import sys |
13 |
from pymlab import config |
13 |
from pymlab import config |
14 |
|
14 |
|
- |
|
15 |
import logging |
- |
|
16 |
logging.basicConfig(level=logging.DEBUG) |
- |
|
17 |
|
- |
|
18 |
|
15 |
#### Script Arguments ############################################### |
19 |
#### Script Arguments ############################################### |
16 |
|
20 |
|
17 |
if (len(sys.argv) != 3): |
21 |
if (len(sys.argv) != 3): |
18 |
sys.stderr.write("Invalid number of arguments.\n") |
22 |
sys.stderr.write("Invalid number of arguments.\n") |
19 |
sys.stderr.write("Usage: %s PORT_ADDRESS/0 REQUIERED_MHz\n" % (sys.argv[0], )) |
23 |
sys.stderr.write("Usage: %s PORT_ADDRESS/0 REQUIERED_MHz\n" % (sys.argv[0], )) |
Line 21... |
Line 25... |
21 |
|
25 |
|
22 |
port = eval(sys.argv[1]) |
26 |
port = eval(sys.argv[1]) |
23 |
#### Sensor Configuration ########################################### |
27 |
#### Sensor Configuration ########################################### |
24 |
|
28 |
|
25 |
cfg = config.Config( |
29 |
cfg = config.Config( |
- |
|
30 |
i2c = { |
26 |
port = port, |
31 |
"port": port, |
- |
|
32 |
}, |
27 |
bus = [ |
33 |
bus = [ |
28 |
{ |
34 |
{ |
29 |
"type": "i2chub", |
35 |
"type": "i2chub", |
30 |
"address": 0x70, |
36 |
"address": 0x72, |
31 |
"children": [ |
37 |
"children": [ |
32 |
{ "name":"clkgen", "type":"clkgen01", "channel": 5, }, |
38 |
{ "name":"clkgen", "type":"clkgen01", "channel": 7, }, |
33 |
], |
39 |
], |
34 |
}, |
40 |
}, |
35 |
], |
41 |
], |
36 |
) |
42 |
) |
37 |
cfg.initialize() |
43 |
cfg.initialize() |
38 |
|
44 |
|
39 |
fgen = cfg.get_device("clkgen") |
45 |
fgen = cfg.get_device("clkgen") |
40 |
sys.stdout.write("Frequency will be set to " + sys.argv[2] + " MHz.\r\n") |
46 |
sys.stdout.write("Frequency will be set to " + sys.argv[2] + " MHz.\r\n") |
- |
|
47 |
|
- |
|
48 |
time.sleep(3) |
- |
|
49 |
fgen.route() |
41 |
fgen.reset() # Reset Si570 to 10 MHz |
50 |
fgen.reset() # Reset Si570 to 10 MHz |
42 |
time.sleep(3) |
51 |
time.sleep(3) |
43 |
fgen = cfg.get_device("clkgen") # Reopen CP2112 |
52 |
fgen = cfg.get_device("clkgen") # Reopen CP2112 |
44 |
fgen.set_freq(10., float(eval(sys.argv[2]))) # Set frequency |
53 |
fgen.set_freq(10., float(eval(sys.argv[2]))) # Set frequency |
45 |
sys.stdout.write("Done.\r\n") |
54 |
sys.stdout.write("Done.\r\n") |