def test_boards(self): d = tmpdir(suffix='_test') os.environ['ARDUINO_HOME'] = d boards_txt = d / 'hardware' / 'arduino' / 'boards.txt' boards_txt.parent.makedirs() boards_txt.write_text('') eq_(board_names(), []) check_keys(boards().keys(), []) # invalid board boards_txt.write_text(''' brd.x3=foo ''') eq_(board_names(), []) boards_txt.write_text(''' brd.name=foo brd.build=foo brd.x3=foo ''') eq_(board_names(), ['brd']) check_keys(boards().keys(), ['brd']) # invalid install_board('ardu', dict(x1='hi')) eq_(board_names(), ['brd']) install_board('ardu', dict(name='hi', build=1)) eq_(set(board_names()), set(['brd', 'ardu'])) install_board('ardu', dict(x1='hi')) eq_(set(board_names()), set(['brd', 'ardu'])) remove_board('brd') eq_(board_names(), ['ardu'])
def install_board(board_id, board_options, hwpack='arduino', replace_existing=False): """install board in boards.txt. :param board_id: string identifier :param board_options: dict like :param replace_existing: bool :rtype: None """ doaction = 0 if board_id in boards(hwpack).keys(): log.debug('board already exists: %s', board_id) if replace_existing: log.debug('remove board: %s' , board_id) remove_board(board_id) doaction = 1 else: doaction = 1 if doaction: lines = bunch2properties(board_id, board_options) boards_txt().write_lines([''] + lines, append=1)
def hwpacks(): ''' example:: {'Sanguino': {'sanguino': {'bootloader': {'extended_fuses': '0xFD', 'file': 'ATmegaBOOT_644P.hex', 'high_fuses': '0xDC', 'lock_bits': '0x0F', 'low_fuses': '0xFF', 'path': 'atmega644p', 'unlock_bits': '0x3F'}, 'build': {'core': 'arduino', 'f_cpu': '16000000L', 'mcu': 'atmega644p'}, 'name': 'Sanguino', 'upload': {'maximum_size': '63488', 'protocol': 'stk500', 'speed': '38400'}}}, 'arduino': {'atmega8': {'bootloader': {'file': 'ATmegaBOOT.hex', 'high_fuses': '0xca', 'lock_bits': '0x0F', 'low_fuses': '0xdf', 'path': 'atmega8', 'unlock_bits': '0x3F'}, 'build': {'core': 'arduino', 'f_cpu': '16000000L', 'mcu': 'atmega8'}, 'name': 'Arduino NG or older w/ ATmega8', 'upload': {'maximum_size': '7168', 'protocol': 'stk500', 'speed': '19200'}}, 'uno': {'bootloader': {'extended_fuses': '0x05', 'file': 'optiboot_atmega328.hex', 'high_fuses': '0xde', 'lock_bits': '0x0F', 'low_fuses': '0xff', 'path': 'optiboot', 'unlock_bits': '0x3F'}, 'build': {'core': 'arduino', 'f_cpu': '16000000L', 'mcu': 'atmega328p'}, 'name': 'Arduino Uno', 'upload': {'maximum_size': '32256', 'protocol': 'stk500', 'speed': '115200'}}}, 'arduino-extras': {'arduino_amber128': {'bootloader': {'extended_fuses': '0xFF', 'file': 'stk500boot_v2_amber128.hex', 'high_fuses': '0xC8', 'lock_bits': '0x0F', 'low_fuses': '0x8F', 'path': 'atmega', 'unlock_bits': '0x3F'}, 'build': {'core': 'arduino', 'f_cpu': '14745600L', 'mcu': 'atmega128'}, 'name': 'Arduino-Amber 128 14.7456 Mhz', 'upload': {'maximum_size': '122880', 'protocol': 'stk500v2', 'speed': '115200'}}, 'stk525_647': {'build': {'core': 'arduino', 'f_cpu': '8000000L', 'mcu': 'at90usb647', 'post_compile_script': 'teensy_post_compile'}, 'name': 'STK500 w/STK525 - at90usb647 (Arduino Core)', 'upload': {'avrdude_wrapper': 'teensy_reboot', 'disable_flushing': 'true', 'maximum_size': '56000', 'protocol': 'halfkay', 'speed': '38400'}}}} ''' bunch = AutoBunch() for x in hwpack_names(): bunch[x] = boards(x) return bunch
def mcu(board_id, hwpack_id): """""" board = boards(hwpack=hwpack_id)[board_id] return board.build.mcu