From: Philipp Klaus Date: Fri, 2 Jun 2017 14:51:11 +0000 (+0200) Subject: Pt100: new option pt100_config --initialize X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=bf1da65b1af4517e3ce50eef85b1b7ea6db84830;p=labtools.git Pt100: new option pt100_config --initialize --- diff --git a/sensors/pt100-board-python-package/pt100_board/pt100_config.py b/sensors/pt100-board-python-package/pt100_board/pt100_config.py index 796439c..2f1d481 100755 --- a/sensors/pt100-board-python-package/pt100_board/pt100_config.py +++ b/sensors/pt100-board-python-package/pt100_board/pt100_config.py @@ -47,6 +47,7 @@ def main(): parser.add_argument('--write-eeprom', type=parse_uint, metavar=('ADDR','VALUE'), nargs=2, help='write uint16 value to address in eeprom; first arg: ADDR, second: VALUE') parser.add_argument('--period', type=float, help='Set conversion period in ms') parser.add_argument('--average', type=parse_uint, help='Number of temperature values to average over (1 to 16, reduces the output frequency).') + parser.add_argument('--initialize', action='store_true', help='Initialize a new board with sensible default EEPROM values. Use with caution.') parser.add_argument('--reload-configuration', '-r', action='store_true', help='Reload the configuration of the board') args = parser.parse_args() @@ -100,6 +101,24 @@ def main(): print('Setting the period to %d ms' % (value * scaling)) write_register(args.board_id, address, value) + if args.initialize: + print('Do you really want to initialize the board with a new set of EEPROM configuration data?') + print('Your current values will be lost!!! This only makes sense for brand new boards!') + input('Press enter to continue or Ctrl-c to abort.') + for i in range(8): + write_register(args.board_id, i, 0x57) + write_register(args.board_id, 0x8, 0xffff) + write_register(args.board_id, 0x9, 0xd211) + write_register(args.board_id, 0xa, 250) + write_register(args.board_id, 0xb, 0x1) + write_register(args.board_id, 0xc, 0x1) + print("Done initializing the EEPROM") + if not args.reload_configuration: + print("You didn't choose to reload the configuration. The new values will only be used once reloaded or power cycled.") + print("Consider using the -r option.") + else: + time.sleep(0.1) + if args.reload_configuration: send('WR{:1X}0000000\n'.format(args.board_id))