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
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. 4
0
def main():
    skibase.set_time_start()

    # Arguments
    parser = argparse.ArgumentParser(description=__doc__)
    parser = args_add_all(parser)
    args = parser.parse_args()

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

    # Watchdog
    wd.wd_set_handle(args.watchdog)

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

    # Start queue
    main_queue = queue.Queue()

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

    # Start Debug LED
    dbgled_obj = dbgled.dbgled_start(args.start_program, args.dbgpin)
    # Start scroll phat
    sphat_obj = sphat.sphat_start(args.start_program)
    # Start LED strip (WS281x)
    ws281x_obj = ws281x.ws281x_start(args.start_program, args.color)
    # Start the Kesselfall network protocol
    kfnet_obj = kfnet.kfnet_start(main_queue, args.interface, kfnet.MCAST_GRP,
                                  args.ip_addr, args.mcast_port)
    # Start button
    butt_obj = butt.butt_start(main_queue)

    # Run
    skibase.log_notice("Running skipi")
    loop(main_queue, args.start_program, kfnet_obj, butt_obj, sphat_obj,
         ws281x_obj, dbgled_obj)

    # Stop
    skibase.log_notice("Stopping skipi")
    kfnet_obj = kfnet.kfnet_stop(kfnet_obj)
    butt_obj = butt.butt_stop(butt_obj)
    sphat_obj = sphat.sphat_stop(sphat_obj)
    ws281x_obj = ws281x.ws281x_stop(ws281x_obj)
    dbgled_obj = dbgled.dbgled_stop(dbgled_obj)
    # Empty queue and stop
    while main_queue.empty() is False:
        main_queue.get()
        main_queue.task_done()
    skibase.log_notice("\nskipi 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")