/Designs/Measuring_instruments/RMDS01C/SW/Host_controller/setSi570.py
0,0 → 1,43
#!/usr/bin/python
#
# Utility for setting frequency of Si570
 
import time
import datetime
import sys
from pymlab import config
 
#### Script Arguments ###############################################
 
if (len(sys.argv) != 3):
sys.stderr.write("Invalid number of arguments.\n")
sys.stderr.write("Usage: %s PORT_ADDRESS/0 REQUIERED_MHz\n" % (sys.argv[0], ))
sys.exit(1)
 
port = eval(sys.argv[1])
#### Sensor Configuration ###########################################
 
cfg = config.Config(
port = port,
bus = [
{
"type": "i2chub",
"address": 0x70,
"children": [
{ "name":"clkgen", "type":"clkgen01", "channel": 5, },
],
},
],
)
cfg.initialize()
 
fgen = cfg.get_device("clkgen")
sys.stdout.write("Frequency will be set to " + sys.argv[2] + " MHz.\r\n")
fgen.reset()
time.sleep(3)
fgen = cfg.get_device("clkgen")
fgen.set_freq(10., float(eval(sys.argv[2])))
sys.stdout.write("Done.\r\n")
sys.stdout.flush()
sys.exit(0)