Exemplo n.º 1
0
 def test_process_invalid_service_request_returns_none(self):
     self.assertIsNone(services.process_service_request(requested_sid=INVALID_SID, requested_pid=0x00))
     self.assertIsNone(services.process_service_request(requested_sid=0x01, requested_pid=INVALID_PID))
     self.assertIsNone(services.process_service_request(requested_sid=INVALID_SID, requested_pid=INVALID_PID))
     self.assertIsNone(services.process_service_request(requested_sid=STRING_SID, requested_pid=0x00))
     self.assertIsNone(services.process_service_request(requested_sid=0x01, requested_pid=STRING_PID))
     self.assertIsNone(services.process_service_request(requested_sid=STRING_SID, requested_pid=STRING_PID))
Exemplo n.º 2
0
def start():
    request_socket = create_isotp_socket(OBD_BROADCAST_ADDRESS,
                                         OBD_TARGET_ADDRESS)
    response_socket = create_isotp_socket(OBD_ECU_ADDRESS, OBD_TARGET_ADDRESS)
    while True:
        request = request_socket.recv()
        requested_pid, requested_sid = get_sid_and_pid(request)
        if requested_sid is not None:
            log_request(request)
            response = services.process_service_request(
                requested_sid, requested_pid)
            if response is not None:
                log_response(response)
                response_socket.send(response)
Exemplo n.º 3
0
 def test_process_service_unknown_pid_returns_none(self):
     self.assertIsNone(services.process_service_request(requested_sid=0x01, requested_pid=UNSUPPORTED_PID))
Exemplo n.º 4
0
 def test_process_unsupported_service_returns_none(self):
     self.assertIsNone(services.process_service_request(requested_sid=UNSUPPORTED_SID, requested_pid=0x00))
     self.assertIsNone(services.process_service_request(requested_sid=UNSUPPORTED_SID, requested_pid=None))
Exemplo n.º 5
0
 def test_process_service_0x03_returns_DTCs(self):
     response = services.process_service_request(requested_sid=0x03, requested_pid=None)
     self.assertIsNotNone(response)
Exemplo n.º 6
0
 def test_process_service_0x09_pid_0x00(self):
     response = services.process_service_request(requested_sid=0x09, requested_pid=0x00)
     self.assertIsNotNone(response)
     self.assertEqual("490040400001", response.hex())
Exemplo n.º 7
0
 def test_process_service_0x01_pid_0xE0_returns_no_pids(self):
     response = services.process_service_request(requested_sid=0x01, requested_pid=0xE0)
     self.assertIsNotNone(response)
     self.assertEqual("41e000000000", response.hex())
Exemplo n.º 8
0
 def test_process_service_0x01_pid_0x40(self):
     response = services.process_service_request(requested_sid=0x01, requested_pid=0x40)
     self.assertIsNotNone(response)
     self.assertEqual("414000008001", response.hex())