def easy_batch_write(p3):
    boards = get_boards()
    if len(boards.keys()) == 0:
        print "No boards found"
        return
    set_bootloader_eeprom(boards, p3)
    time.sleep(1.0)
    m3t.load_m3ec_kmod()
    bld = m3.m3_bootloader.M3Bootloader()
    bld.SetVerbose(1)
    boards = batch_startup(bld, boards)
    bords = batch_ping(bld, boards)
    boards = batch_write(bld, boards)
    for k in boards.keys():
        print "Write success", k, " : ", boards[k]["write_success"]
    bld.Shutdown()
    m3t.unload_m3ec_kmod()
    time.sleep(1.0)
    restore_board_eeprom(boards, p3)
def easy_batch_write(p3):
    boards = get_boards()
    if len(boards.keys()) == 0:
        print 'No boards found'
        return
    set_bootloader_eeprom(boards, p3)
    time.sleep(1.0)
    m3t.load_m3ec_kmod()
    bld = m3.m3_bootloader.M3Bootloader()
    bld.SetVerbose(1)
    boards = batch_startup(bld, boards)
    bords = batch_ping(bld, boards)
    boards = batch_write(bld, boards)
    for k in boards.keys():
        print 'Write success', k, ' : ', boards[k]['write_success']
    bld.Shutdown()
    m3t.unload_m3ec_kmod()
    time.sleep(1.0)
    restore_board_eeprom(boards, p3)
 c = raw_input()
 if (
     c == "q"
     or c == "w"
     or c == "p"
     or c == "l"
     or c == "r"
     or c == "b"
     or c == "e"
     or c == "s"
     or c == "d"
 ):
     if c == "d":
         display_boards(boards)
     if c == "s":
         m3t.load_m3ec_kmod()
         unload = True
         boards = batch_startup(bld, boards)
     if c == "l":
         list_slaves()
     if c == "e":
         easy_batch_write(bld, boards)
         unload = False
     if c == "w":
         boards = batch_write(bld, boards)
     if c == "p":
         boards = batch_ping(bld, boards)
     if c == "r":
         m3t.unload_m3ec_kmod()
         unload = False
         restore_board_eeprom(boards, p3)
     easy_batch_write(p3)
     exit()
 else:
     boards = get_boards()
 if not len(boards):
     exit()
 bld = m3.m3_bootloader.M3Bootloader()
 unload = False
 while (True):
     print_usage()
     c = raw_input()
     if c == 'q' or c == 'w' or c == 'p' or c == 'l' or c == 'r' or c == 'b' or c == 'e' or c == 's' or c == 'd':
         if c == 'd':
             display_boards(boards)
         if c == 's':
             m3t.load_m3ec_kmod()
             unload = True
             boards = batch_startup(bld, boards)
         if c == 'l':
             list_slaves()
         if c == 'e':
             easy_batch_write(bld, boards)
             unload = False
         if c == 'w':
             boards = batch_write(bld, boards)
         if c == 'p':
             boards = batch_ping(bld, boards)
         if c == 'r':
             m3t.unload_m3ec_kmod()
             unload = False
             restore_board_eeprom(boards, p3)