Esempio n. 1
0
def main():
    global bbd

    bbd = None
    #
    # Create an FTDI BigBangDevice instance, based on serial number passed in
    #
    bbd = BitBangDevice(device_index=0)

    #
    # Set direction regiser
    #
    bbd.direction = 0xFF

    #
    # Set initial port value to 0
    #
    bbd.port = 0

    #
    # That worked, setup XMLRPC server
    #
    server = SimpleXMLRPCServer.SimpleXMLRPCServer(
        ('localhost', int(sys.argv[1])), logRequests=False, allow_none=True)
    server.register_introspection_functions()
    server.register_function(set_bit, 'set_bit')
    server.serve_forever()
    return 0
Esempio n. 2
0
def _select_ftdi_channel(channel):
    """Select multiplexer channel. Currently uses a FTDI chip via pylibftdi"""
    if channel < 0 or channel > 8:
        raise ArgumentError(
            "FTDI-selected multiplexer only has channels 0-7 valid, make sure you specify channel with -c channel=number",
            channel=channel)
    from pylibftdi import BitBangDevice
    bb = BitBangDevice(auto_detach=False)
    bb.direction = 0b111
    bb.port = channel
Esempio n. 3
0
wait = 10
count = 0
done = False
current_rate = None

bbd = None
#
# Create an FTDI BigBangDevice instance, based on serial number passed in
#
bbd = BitBangDevice(device_index=0)

#
# Set direction regiser
#
bbd.direction = 0xFF
bbd.port = 0

#
# For the way we've wired up the linear actuator motor, this should
#   produce an "UP" and "DOWN" motor direction.
#
# Two of the relay channels--the low-order bits just control the +/-
#   that go to the other two channels.  Those channels are wired in
#   a kind of exclusive OR, so that only bits with opposite settings
#   produce any motion at all.
#
DOWN = 0b00001101
UP = 0b00001110

#
# Threshold for determining "done" when moving
Esempio n. 4
0
    v = (chksum(command) << 7) + command
    i = 0x200
    while i > 0:
        if v & i:
            vll1()
        else:
            vll0()
        i = i >> 1
    vllstop()


def cp_pause():
    bb.port = 1
    sleep(PAUSE)


# auto_detach = False is needed as a workaround to prevent
# segmentation faults when accessing the FTDI device
# see pylibftdi issue #25

bb = BitBangDevice(FTDI_SN, auto_detach=False)
bb.direction = DIRECTION
bb.port = 0

vllinit()
sleep(2)

while True:
    send(MS_FWD)
    send(MS_REV)