#!/usr/bin/env python # # Create a map of valid addresses. RA4 on the serial_bridge should # be connected to the WR pin on the controller bus. # from devices import SerialBridge b = SerialBridge() f = open("valid.addresses", "w") for addr in xrange(0x10000): count = b.busWrite([0]*32, addr)[0] if count: f.write("%d\n" % addr) print "%d ******" % addr else: print "%d" % addr ### The End ###
#!/usr/bin/env python3 # # Using the valid.addresses file created by find_valid_addresses, # generate another map of just the addresses that generate a pulse # on a particular address line. This creates files that will be # used to generate a mapping from resulting address to the codes that # can generate it. # from devices import SerialBridge import sys b = SerialBridge() addrs = map(int, open("valid.addresses").readlines()) f = open(sys.argv[1], "w") for addr in addrs: count = int.from_bytes(b.busWrite(bytes([0])*32, addr)[0], byteorder='big') if count: f.write("%d\n" % addr) print("{} ******".format(addr)) else: print("{}".format(addr)) ### The End ###
def __init__(self, bridge=None): if not bridge: bridge = SerialBridge() self.bridge = bridge
# 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 ###
# 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 ###
#!/usr/bin/env python # # Using the valid.addresses file created by find_valid_addresses, # generate another map of just the addresses that generate a pulse # on a particular address line. This creates files that will be # used to generate a mapping from resulting address to the codes that # can generate it. # from devices import SerialBridge import sys b = SerialBridge() addrs = map(int, open("valid.addresses").readlines()) f = open(sys.argv[1], "w") for addr in addrs: count = b.busWrite([0] * 32, addr)[0] if count: f.write("%d\n" % addr) print "%d ******" % addr else: print "%d" % addr ### The End ###