Esempio n. 1
0
def test():
    # Arguments
    parser = argparse.ArgumentParser(description=__doc__)
    parser = skibase.args_add_log(parser)
    parser = args_add_dbgled(parser)
    args = parser.parse_args()

    # Parse
    skibase.log_config(args.loglevel.upper(), args.syslog)

    # Signal
    skibase.signal_setup([signal.SIGINT, signal.SIGTERM])

    # dbgled
    program = 0
    dbgled_obj = dbgled_start(program, args.dbgpin)

    # Loop
    skibase.log_notice("Running DbgPin unittest")
    counter = 0
    while not skibase.signal_counter and dbgled_obj.status():
        dbgled_obj.program = counter
        time.sleep(5)
        counter += 1

    dbgled_obj = dbgled_stop(dbgled_obj)
    skibase.log_notice("DbgPin unittest ended")
Esempio n. 2
0
def test():
    # Arguments
    parser = argparse.ArgumentParser(description=__doc__)
    parser = skibase.args_add_log(parser)
    parser = args_add_sphat(parser)
    args = parser.parse_args()

    # Parse
    skibase.log_config(args.loglevel.upper(), args.syslog)

    # Signal
    skibase.signal_setup([signal.SIGINT, signal.SIGTERM])

    # sphat
    program = 0
    sphat_obj = sphat_start(program)

    # Loop
    skibase.log_notice("Running Scroll PHAT unittest")
    counter = 0
    while not skibase.signal_counter and sphat_obj.status():
        sphat_obj.program = counter % 9
        time.sleep(8)
        counter += 1

    sphat_obj = sphat_stop(sphat_obj)
    skibase.log_notice("Scroll PHAT unittest ended")
Esempio n. 3
0
def args_add_all(parser):
    # === Logging ===
    parser = skibase.args_add_log(parser)
    # === Watchdog ===
    parser = wd.args_add_wd(parser)
    # === Kesselfall Network ===
    parser = kfnet.args_add_kfnet(parser)
    # === WS281x ===
    parser = ws281x.args_add_ws281x(parser)
    # === Scroll PHAT ===
    parser = sphat.args_add_sphat(parser)
    # === Butt ===
    parser = butt.args_add_butt(parser)
    # === DbgLed ===
    parser = dbgled.args_add_dbgled(parser)
    # === Main ===
    # Start program
    parser.add_argument('-m',
                        '--program',
                        type=int,
                        action="store",
                        dest="start_program",
                        default=PROGRAM_DEFAULT,
                        help="Starting Program ID. Default: %d" %
                        PROGRAM_DEFAULT)
    return parser
Esempio n. 4
0
File: wd.py Progetto: nens90/skiPi
def test():
    # Arguments
    parser = argparse.ArgumentParser(description=__doc__)
    parser = skibase.args_add_log(parser)
    parser = args_add_wd(parser)
    args = parser.parse_args()

    # Parse
    skibase.log_config(args.loglevel.upper(), args.syslog)

    # Watchdog
    wd_set_handle(args.watchdog)

    # Signal
    skibase.signal_setup([signal.SIGINT, signal.SIGTERM])

    # Expect the main-loop to kick the watchdog again before time runs out.
    wd_kick()

    # Loop
    skibase.log_notice("Running watchdog unittest")
    next_kick = 0
    while not skibase.signal_counter:
        next_kick = wd_check(next_kick)
        skibase.log_info(".", end='')
        time.sleep(0.8)

    skibase.log_notice("\nWatchdog unittest ended...")
Esempio n. 5
0
def test():
    skibase.set_time_start()

    # Arguments
    parser = argparse.ArgumentParser(description=__doc__)
    parser = skibase.args_add_log(parser)
    parser = args_add_kfnet(parser)
    args = parser.parse_args()

    # Parse
    skibase.log_config(args.loglevel.upper(), args.syslog)

    # Signal
    skibase.signal_setup([signal.SIGINT, signal.SIGTERM])

    # Start queue
    main_queue = queue.Queue()

    # Start kfnet
    kfnet_obj = kfnet_start(main_queue, args.interface, MCAST_GRP,
                            args.ip_addr, args.mcast_port)

    # Loop (main)
    skibase.log_notice("Running Kesselfall network unittest")
    counter = random.randint(0, 0xFF)
    t_next_send = skibase.get_time_millis()
    while not skibase.signal_counter and kfnet_obj.status():
        try:
            task = main_queue.get(block=True, timeout=0.25)
        except queue.Empty:
            task = None
        if task:
            try:
                skibase.log_notice("-> task: %s" % skibase.task_to_str(task))
            except:
                skibase.log_warning("kfnet got unknown task")
            main_queue.task_done()
        if t_next_send < skibase.get_time_millis():
            # Send packet to kfnet task
            # otherwise use kfnet_obj.queue_task(task)
            packet = kfnet_obj.create_packet()
            packet.task = skibase.TASK_PROGRAM + \
                          (counter & skibase.MINOR_TASK)
            kfnet_obj.queue_packet(packet)
            skibase.log_notice("<- Packet: %s :: task: %s" %\
              (packet.id.decode(), task_to_str(packet.task)))
            t_next_send = t_next_send \
                          + random.randint(CHANGE_RATE_MIN, CHANGE_RATE_MAX)
            counter += 1

    kfnet_obj = kfnet_stop(kfnet_obj)
    skibase.log_notice("Kesselfall network unittest ended")
Esempio n. 6
0
File: butt.py Progetto: nens90/skiPi
def test():
    # Arguments
    parser = argparse.ArgumentParser(description=__doc__)
    parser = skibase.args_add_log(parser)
    parser = args_add_butt(parser)
    args = parser.parse_args()
    
    # Parse
    skibase.log_config(args.loglevel.upper(), args.syslog)
    
    # Signal
    skibase.signal_setup([signal.SIGINT, signal.SIGTERM])
    
    # Start queue
    main_queue = queue.Queue()
    
    # Start Butt
    butt_obj = butt_start(main_queue)
    
    # Loop
    skibase.log_notice("Running butt unittest")
    while not skibase.signal_counter and butt_obj.status():
        try:
            task = main_queue.get(block=True, timeout=0.25)
        except queue.Empty:
            task = None
        if task is not None:
            if task == skibase.TASK_BUTTON_PRESS:
                skibase.log_notice("butt press")
            elif task == skibase.TASK_BUTTON_LONG:
                skibase.log_notice("butt long press")
            else:
                skibase.log_warning("butt got unknown task")
        
    # Stop Butt
    butt_stop(butt_obj)

    skibase.log_notice("butt unittest ended")