How to use the pfio.write_output function in pfio

To help you get started, we’ve selected a few pfio examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github thomasmacpherson / piface / python / piface / pfion.py View on Github external
return

    else:
        if verbose:
            print "Listening at %s on port %d" % (hostname, port)

    while True:
        # get the packet
        packet, sender = sock.recvfrom(BUFFER_SIZE)
        if verbose:
            print "Recieved packet from", sender
        # make it something sensible
        packet = PfionPacket().from_network(packet)

        if packet.command == WRITE_OUT_CMD:
            pfio.write_output(packet.bit_pattern)
            p = PfionPacket(WRITE_OUT_ACK)
            sock.sendto(p.for_network(), sender)

        elif packet.command == READ_OUT_CMD:
            output_bitp = pfio.read_output()
            p = PfionPacket(READ_OUT_ACK)
            p.bit_pattern = output_bitp
            sock.sendto(p.for_network(), sender)

        elif packet.command == READ_IN_CMD:
            input_bitp = pfio.read_input()
            p = PfionPacket(READ_IN_ACK)
            p.bit_pattern = input_bitp
            sock.sendto(p.for_network(), sender)

        elif packet.command == DIGITAL_WRITE_CMD: