Exemplo n.º 1
0
    # Each bit set individually
    for byte in xrange(32):
        for bit in xrange(8):
            packet = [0] * 32
            packet[byte] = 1<<(7-bit)
            yield packet

    # Random pairs of bits set
    for i in xrange(500):
        packet = [0] * 32
        for j in xrange(2):
            byte = random.randint(0, 31)
            bit = random.randint(0, 7)
            packet[byte] |= 1<<(7-bit)
        yield packet

    # Completely random packets
    for i in xrange(500):
        yield [random.randint(0,255) for j in xrange(32)]


if __name__ == "__main__":
    filename = "crc_test_vectors.p"
    b = SerialBridge()
    vec = b.genVectors(packetGenerator())
    cPickle.dump(vec, open(filename, "wb"), -1)
    print "Saved to %s" % filename

### The End ###
Exemplo n.º 2
0
    # Each bit set individually
    for byte in xrange(32):
        for bit in xrange(8):
            packet = [0] * 32
            packet[byte] = 1 << (7 - bit)
            yield packet

    # Random pairs of bits set
    for i in xrange(500):
        packet = [0] * 32
        for j in xrange(2):
            byte = random.randint(0, 31)
            bit = random.randint(0, 7)
            packet[byte] |= 1 << (7 - bit)
        yield packet

    # Completely random packets
    for i in xrange(500):
        yield [random.randint(0, 255) for j in xrange(32)]


if __name__ == "__main__":
    filename = "crc_test_vectors.p"
    b = SerialBridge()
    vec = b.genVectors(packetGenerator())
    cPickle.dump(vec, open(filename, "wb"), -1)
    print "Saved to %s" % filename

### The End ###