Exemplo n.º 1
0
def read():
    print "reading"
    try:
        theDevice = atmelUsbDevice(idVendor=0x16c0, idProduct=0x05df)

        print "Found: 0x%04x 0x%04x %s %s" % (
            theDevice.idVendor, theDevice.idProduct, theDevice.productName,
            theDevice.manufacturer)
    except:
        time.sleep(2.5)
        print "Wait.."
    max_val = 0
    while True:
        # for i in range(1,1000):
        try:
            theDevice = atmelUsbDevice(idVendor=0x16c0, idProduct=0x05df)
            try:
                # sys.stdout.write(type(theDevice.read()))
                val = theDevice.read()
                # if val > max_val:
                #     max_val = val
                eq = "|" * int(val * 0.6)
                # eq = int(val)
                print(eq)

                # sys.stdout.flush()
            except:
                # TODO: Check for exception properly
                time.sleep(0.5)

        except:
            # TODO: Check for exception properly
            time.sleep(1)
Exemplo n.º 2
0
def read():
    print "reading"
    try:
        theDevice = atmelUsbDevice(idVendor=0x16c0, idProduct=0x05df)

        # It would be:
        #print "Found: 0x{idVendor:04x} 0x{idProduct:04x} {productName} {manufacturer}".format(**theDevice)
        # If it were a dictionary. I don't have my s×3 on me to check
        print "Found: 0x%04x 0x%04x %s %s" % (
            theDevice.idVendor, theDevice.idProduct, theDevice.productName,
            theDevice.manufacturer)
    except:
        pass

    while True:
        try:
            theDevice = atmelUsbDevice(idVendor=0x16c0, idProduct=0x05df)
            try:
                sys.stdout.write(chr(theDevice.read()))
                sys.stdout.flush()
            except:
                # TODO: Check for exception properly
                time.sleep(0.5)

        except:
            # TODO: Check for exception properly
            time.sleep(1)
Exemplo n.º 3
0
def send(args=args):
    """Send a command to the sensicorn stampeed stick."""
    try:
        theDevice = atmelUsbDevice(idVendor=0x16c0, idProduct=0x05df)
    except:
        sys.exit("No DigiUSB Device Found")

    try:
        user_input = args
        print args
    except:
        exit("No data to send")

    for c in user_input:
        theDevice.write(ord(c))
Exemplo n.º 4
0
def receive():
    time.sleep(.2)

    try:
        theDevice = atmelUsbDevice(idVendor=0x16c0, idProduct=0x05df)
    except:
        sys.exit("No DigiUSB Device Found")

    val = ""
    while True:
        try:
            lastChar = chr(theDevice.read())
            if (lastChar == "\n"):
                break
            # sys.stdout.write(lastChar)
            val += lastChar
            sys.stdout.flush()

        except:  # Exception as e:
            # TODO: Check for exception properly
            # print "sreepu", e
            time.sleep(0.1)

    print val.strip()