def test_p2_star_timeout(self): self.conn.touserqueue.get(timeout=0.2) response = Response( service=services.TesterPresent, code=Response.Code.RequestCorrectlyReceived_ResponsePending) self.conn.fromuserqueue.put(response.get_payload()) time.sleep(0.1) self.conn.fromuserqueue.put(response.get_payload())
def test_p2_star_timeout_overrided_by_diagnostic_session_control(self): self.conn.touserqueue.get(timeout=0.2) self.conn.fromuserqueue.put( b"\x50\x01\x03\xE8\x00\xC8" ) # Respond to diagnostic session control with timeout of 2 sec response = Response( service=services.TesterPresent, code=Response.Code.RequestCorrectlyReceived_ResponsePending) self.conn.fromuserqueue.put(response.get_payload()) time.sleep(0.1) self.conn.fromuserqueue.put(response.get_payload())
def RCRRP_responses(self): self.conn.touserqueue.get(timeout=0.2) response = Response( service=services.TesterPresent, code=Response.Code.RequestCorrectlyReceived_ResponsePending) t1 = time.time() while time.time() - t1 <= 4.0: self.conn.fromuserqueue.put(response.get_payload()) time.sleep(0.1) response = Response(service=services.TesterPresent, code=Response.Code.PositiveResponse, data=bytes(2)) self.conn.fromuserqueue.put(response.get_payload())
def test_make_payload_custom_data_negative(self): response = Response(DummyServiceNormal(), code=0x10) self.assertTrue(response.valid) self.assertFalse(response.positive) response.data = b"\x12\x34\x56\x78" payload = response.get_payload() self.assertEqual(b"\x7F\x13\x10\x12\x34\x56\x78", payload)
def test_make_payload_basic_negative(self): response = Response(DummyServiceNormal(), code=0x10) # General Reject self.assertFalse(response.positive) self.assertTrue(response.valid) payload = response.get_payload() self.assertEqual(b"\x7F\x13\x10", payload) # Original ID + 0x40. 7F indicate negative
def test_timeout_pending_response(self): if not hasattr(self, 'completed'): self.completed = False self.conn.touserqueue.get(timeout=0.2) response = Response(service=services.TesterPresent, code=Response.Code.RequestCorrectlyReceived_ResponsePending) t1 = time.time() while time.time() - t1 < 1 and not self.completed: self.conn.fromuserqueue.put(response.get_payload()) time.sleep(0.1)
def test_make_payload_basic_positive(self): response = Response(DummyServiceNormal(), code=0, data=b"\x01") self.assertTrue(response.positive) self.assertTrue(response.valid) payload = response.get_payload() self.assertEqual(b"\x53\x01", payload) # Original ID + 0x40