128def parse_args(raw_args):
129 """Parses the args into ready to write register_data."""
130
131 parser = argparse.ArgumentParser()
132 parser.add_argument("--port", type=str, default="A",
133 help="Output Port: A, B default A")
134 parser.add_argument("--output", type=str, default="32767",
135 help="Output Voltage: 0 to 65535 default 32767")
136 parser.add_argument("-t", "--test", action="store_true",
137 help="Print JSON of register_data")
138 args = parser.parse_args(raw_args)
139
140
141 register_data['control'] = 0x30
142 if (args.port == "A"):
143 register_data['control'] = 0x30
144 if (args.port == "B"):
145 register_data['control'] = 0x34
146
147
148 register_data['data_h'] = 0x00
149 register_data['data_l'] = 0x00
150 raw_output = int(args.output)
151 if (raw_output < 0):
152 raw_output = 0
153 if (raw_output > 65535):
154 raw_output = 65535
155 register_data['data_h'] = raw_output >> 8
156 register_data['data_l'] = raw_output & 0xFF
157
158
159 if args.test:
160 output_json()
161 exit()
162
163
164
165
166