예제 #1
0
def main():
    args = get_argparser().parse_args()
    init_logger(args)

    if not args.print_decoded and args.write_vcd is None and args.write_dump is None:
        print("No action selected, use -p, -w and/or -d. See -h for help.")
        sys.exit(1)

    device_mgr = DeviceManager(DeviceDB(args.device_db))
    try:
        if args.read_dump:
            with open(args.read_dump, "rb") as f:
                dump = f.read()
        else:
            comm = device_mgr.get("comm")
            dump = comm.get_analyzer_dump()
        decoded_dump = decode_dump(dump)
        if args.print_decoded:
            print("Log channel:", decoded_dump.log_channel)
            print("DDS one-hot:", decoded_dump.dds_onehot_sel)
            for message in decoded_dump.messages:
                print(message)
        if args.write_vcd:
            with open(args.write_vcd, "w") as f:
                decoded_dump_to_vcd(f, device_mgr.get_device_db(), decoded_dump)
        if args.write_dump:
            with open(args.write_dump, "wb") as f:
                f.write(dump)
    finally:
        device_mgr.close_devices()
예제 #2
0
def main():
    args = get_argparser().parse_args()
    init_logger(args)

    if (not args.print_decoded and args.write_vcd is None
            and args.write_dump is None):
        print("No action selected, use -p, -w and/or -d. See -h for help.")
        sys.exit(1)

    device_mgr = DeviceManager(DeviceDB(args.device_db))
    try:
        if args.read_dump:
            with open(args.read_dump, "rb") as f:
                dump = f.read()
        else:
            comm = device_mgr.get("comm")
            dump = comm.get_analyzer_dump()
        decoded_dump = decode_dump(dump)
        if args.print_decoded:
            print("Log channel:", decoded_dump.log_channel)
            print("DDS one-hot:", decoded_dump.dds_onehot_sel)
            for message in decoded_dump.messages:
                print(message)
        if args.write_vcd:
            with open(args.write_vcd, "w") as f:
                decoded_dump_to_vcd(f, device_mgr.get_device_db(),
                                    decoded_dump)
        if args.write_dump:
            with open(args.write_dump, "wb") as f:
                f.write(dump)
    finally:
        device_mgr.close_devices()
예제 #3
0
    def test_ttl_pulse(self):
        comm = self.device_mgr.get("comm")

        exp = self.create(CreateTTLPulse)
        exp.initialize_io()
        comm.get_analyzer_dump()  # clear analyzer buffer
        exp.run()

        dump = decode_dump(comm.get_analyzer_dump())
        self.assertIsInstance(dump.messages[-1], StoppedMessage)
        output_messages = [
            msg for msg in dump.messages
            if isinstance(msg, OutputMessage) and msg.address == 0
        ]
        self.assertEqual(len(output_messages), 2)
        self.assertEqual(
            abs(output_messages[0].timestamp - output_messages[1].timestamp),
            1000)
        input_messages = [
            msg for msg in dump.messages if isinstance(msg, InputMessage)
        ]
        self.assertEqual(len(input_messages), 2)
        self.assertAlmostEqual(abs(input_messages[0].timestamp -
                                   input_messages[1].timestamp),
                               1000,
                               delta=1)
예제 #4
0
    def test_rtio_log(self):
        comm = self.device_mgr.get("comm")

        exp = self.create(WriteLog)
        comm.get_analyzer_dump()  # clear analyzer buffer
        exp.run()

        dump = decode_dump(comm.get_analyzer_dump())
        log  = "".join([_extract_log_chars(msg.data)
                        for msg in dump.messages
                        if isinstance(msg, OutputMessage) and msg.channel == dump.log_channel])
        self.assertEqual(log, "foo\x1E32\n\x1D")
예제 #5
0
    def test_ttl_pulse(self):
        comm = self.device_mgr.get("comm")

        # clear analyzer buffer
        comm.get_analyzer_dump()

        exp = self.create(CreateTTLPulse)
        exp.run()

        dump = decode_dump(comm.get_analyzer_dump())
        output_messages = [msg for msg in dump.messages if isinstance(msg, OutputMessage) and msg.address == 0]
        self.assertEqual(len(output_messages), 2)
        self.assertEqual(abs(output_messages[0].timestamp - output_messages[1].timestamp), 1000)
        input_messages = [msg for msg in dump.messages if isinstance(msg, InputMessage)]
        self.assertEqual(len(input_messages), 2)
        self.assertAlmostEqual(abs(input_messages[0].timestamp - input_messages[1].timestamp), 1000, delta=1)