Beispiel #1
0
    print "bartendro.db in order to provide Bartendro with a starting database."
    sys.exit(-1)

# Create a memcache connection and flush everything
app.mc = memcache.Client(['127.0.0.1:11211'], debug=0)
app.mc.flush_all()

# Create the Bartendro globals to prevent multiple people from using it at the same time.
app.globals = BartendroGlobalLock()

device = determine_serial_device()

startup_err = ""
# Start the driver, which talks to the hardware
try:
    app.driver = driver.RouterDriver(device, app.software_only)
    app.driver.open()
    logging.info("Found %d dispensers." % app.driver.count())
except BartendroBrokenError:
    err = "Cannot open I2C interface to a router board. If a router board is connected, please turn off Bartendro, wait 3 seconds and then turn back on."
    if have_uwsgi:
        startup_err = err
    else:
        print
        print err
        print
        print_software_only_notice()
        sys.exit(-1)
except SerialIOError:
    err = "Cannot open serial interface to a router board."
    if have_uwsgi:
Beispiel #2
0
if not os.path.exists("bartendro.db"):
    print "bartendro.db file not found. Please copy bartendro.db.default to "
    print "bartendro.db in order to provide Bartendro with a starting database."
    sys.exit(-1)

# Create a memcache connection and flush everything
app.mc = memcache.Client(['127.0.0.1:11211'], debug=0)
app.mc.flush_all()

# Create the Bartendro globals to prevent multiple people from using it at the same time.
app.globals = BartendroGlobalLock()

# Start the driver, which talks to the hardware
try:
    app.driver = driver.RouterDriver("/dev/ttyAMA0", app.software_only)
    app.driver.open()
except I2CIOError:
    print
    print "Cannot open I2C interface to a router board."
    print
    print_software_only_notice()
    sys.exit(-1)
except SerialIOError:
    print
    print "Cannot open serial interface to a router board."
    print
    print_software_only_notice()
    sys.exit(-1)

logging.info("Found %d dispensers." % app.driver.count())
Beispiel #3
0
def test(ll):
    try:
        subprocess.check_call(
            ["make", "-C", "../firmware/dispenser", "dispenser"])
    except subprocess.CalledProcessError:
        print "Failed to program dispenser!"
        sys.exit(-1)

    sleep(1)

    dt = driver.RouterDriver("/dev/ttyAMA0", False)
    dt.open()
    sleep(.1)
    if dt.ping(0):
        print "ping ok"
    else:
        print "ping failed"
        sys.exit(-1)

    dt.set_motor_direction(0, driver.MOTOR_DIRECTION_FORWARD)

    print "timed forward"
    if not dt.dispense_time(0, 950):
        print "timed dispense forward failed."
        sys.exit(-1)

    sleep(1.5)

    dt.set_motor_direction(0, driver.MOTOR_DIRECTION_BACKWARD)

    print "ticks backward"
    if not dt.dispense_ticks(0, 24):
        print "ticks dispense backward failed."
        sys.exit(-1)
    sleep(1.5)

    dt.set_motor_direction(0, driver.MOTOR_DIRECTION_FORWARD)

    print "ticks forward"
    if not dt.dispense_ticks(0, 24):
        print "tick dispense forward failed."
        sys.exit(-1)
    sleep(1.5)

    dt.set_motor_direction(0, driver.MOTOR_DIRECTION_BACKWARD)

    print "time backward"
    if not dt.dispense_time(0, 950):
        print "timed dispense backward failed."
        sys.exit(-1)
    sleep(1.5)

    dt.set_motor_direction(0, driver.MOTOR_DIRECTION_FORWARD)

    if ll:
        while True:
            line = raw_input(
                "Press Enter to check the liquid level sensor. Type 'q' to move on to the next dispenser... "
            )
            if line == 'q':
                break

            if not dt.update_liquid_levels():
                print "updating liquid levels failed."
                sys.exit(-1)

            sleep(.1)

            ll = dt.get_liquid_level(0)
            if ll < 0:
                print "updating liquid levels failed."
                sys.exit(-1)

            print "Current level: %d" % ll

    print "All tests passed!"
    print
    print