if os.path.isfile("data/data.pkl"): serializedDataFile = open("data/data.pkl", "rb") defined_parameters = pickle.load(serializedDataFile) serializedDataFile.close() else: defined_parameters = parser.parse("logger_METRIC_EN_v263.xml") defined_parameters = sorted(defined_parameters, key=lambda x: x.get_id(), reverse=True) output = open("data/data.pkl", "wb") pickle.dump(defined_parameters, output, -1) output.close() if len(sys.argv) > 1 and sys.argv[1] == "demo": connection = PMDemoConnection() elif platform.system() == "Linux": connection = PMConnection() else: connection = PMDemoConnection() while True: try: connection.open() ecu_packet = connection.init(1) tcu_packet = connection.init(2) ecu_context = PMCUContext(ecu_packet, [1, 3]) ecu_parameters = ecu_context.match_parameters(defined_parameters) ecu_switch_parameters = ecu_context.match_switch_parameters( defined_parameters)
def prepare_1_open_connection(self): self._connection = PMDemoConnection() result = self._connection.open() self.assertTrue(result)