pylessard / python-udsoncan

Python implementation of UDS (ISO-14229) standard.
MIT License
575 stars 199 forks source link

the logging module and can data are inconsistent #171

Closed hanlfa closed 11 months ago

hanlfa commented 1 year ago

logging:

2023-09-07 16:03:02 [DEBUG] Connection: Sending 2 bytes : [b'1101']
2023-09-07 16:03:02 [DEBUG] Connection: Received 3 bytes : [b'7f1178']
2023-09-07 16:03:04 [DEBUG] Connection: Received 3 bytes : [b'7f1178']
2023-09-07 16:03:05 [DEBUG] Connection: Received 2 bytes : [b'5101']
2023-09-07 16:03:05 [INFO] UdsClient: Received positive response for service ECUReset (0x11) from server.
-->Reset ECU1101 is ok
2023-09-07 16:03:15 [INFO] UdsClient: ReadDataByIdentifier<0x22> - Reading data identifier : 0xf195 (SystemSupplierECUSoftwareVersionNumberDataIdentifier)
2023-09-07 16:03:15 [DEBUG] Connection: Sending 3 bytes : [b'22f195']
2023-09-07 16:03:15 [DEBUG] Connection: Received 11 bytes : [b'62f19556335f00015f0003']
2023-09-07 16:03:15 [INFO] UdsClient: Received positive response for service ReadDataByIdentifier (0x22) from server.
SW: V3_0001_0003
F195: V3_0001_0003
2023-09-07 16:03:18 [INFO] Connection: Connection opened
2023-09-07 16:03:18 [INFO] UdsClient: DiagnosticSessionControl<0x10> - Switching session to extendedDiagnosticSession (0x03)
2023-09-07 16:03:18 [DEBUG] Connection: Sending 2 bytes : [b'1003']
2023-09-07 16:03:33 [DEBUG] Connection: No data received: [TimeoutException] - Did not receive frame IsoTP Transport layer in time (timeout=15 sec) 
2023-09-07 16:03:33 [ERROR] UdsClient: [TimeoutException] : Did not receive response in time. P2 timeout time has expired (timeout=15.000 sec)
2023-09-07 16:03:33 [INFO] UdsClient: CommunicationControl<0x28> - ControlType=0x00 (enableRxAndTx) - Sending request with a CommunicationType byte of 0x03 (subnet=0x0. Flags : [NormalMsg,NetworkManagementMsg])
2023-09-07 16:03:33 [DEBUG] Connection: Sending 3 bytes : [b'280003']
2023-09-07 16:03:48 [DEBUG] Connection: No data received: [TimeoutException] - Did not receive frame IsoTP Transport layer in time (timeout=15 sec) 
2023-09-07 16:03:48 [ERROR] UdsClient: [TimeoutException] : Did not receive response in time. P2 timeout time has expired (timeout=15.000 sec)
Tester turn on communication failed.
2023-09-07 16:03:48 [INFO] UdsClient: ControlDTCSetting<0x85> - SettingType=0x01 (on) - Turning DTC On with a payload of 0 bytes
2023-09-07 16:03:48 [DEBUG] Connection: Sending 2 bytes : [b'8501']
2023-09-07 16:04:03 [DEBUG] Connection: No data received: [TimeoutException] - Did not receive frame IsoTP Transport layer in time (timeout=15 sec) 
2023-09-07 16:04:03 [ERROR] UdsClient: [TimeoutException] : Did not receive response in time. P2 timeout time has expired (timeout=15.000 sec)
Tester turn on DTC failed.Did not receive response in time. P2 timeout time has expired (timeout=15.000 sec)
2023-09-07 16:04:03 [INFO] UdsClient: DiagnosticSessionControl<0x10> - Switching session to defaultSession (0x01)
2023-09-07 16:04:03 [DEBUG] Connection: Sending 2 bytes : [b'1001']
2023-09-07 16:04:03 [DEBUG] Connection: Received 6 bytes : [b'5001003201f4']
2023-09-07 16:04:03 [INFO] UdsClient: Received positive response for service DiagnosticSessionControl (0x10) from server.
-->enter 1001 ok
2023-09-07 16:04:03 [INFO] Connection: Connection closed
2023-09-07 16:04:03 [INFO] Connection: Connection closed
2023-09-07 16:04:03 [INFO] Connection: Connection opened
2023-09-07 16:04:03 [INFO] UdsClient: ClearDiagnosticInformation<0x14> - Clearing all DTCs (group mask : 0xFFFFFF)
2023-09-07 16:04:03 [DEBUG] Connection: Sending 4 bytes : [b'14ffffff']
2023-09-07 16:04:03 [DEBUG] Connection: Received 3 bytes : [b'7f1478']
2023-09-07 16:04:03 [DEBUG] Connection: Received 1 bytes : [b'54']
2023-09-07 16:04:03 [INFO] UdsClient: Received positive response for service ClearDiagnosticInformation (0x14) from server.
-->Firmware updated successfully!
2023-09-07 16:04:03 [INFO] Connection: Connection closed

Can data: ![Uploading mmexport1694075300064.png…]()

hanlfa commented 1 year ago

The log module return an timeout error,but the actual can data is normal,all requests have returned a positive reponse.

hanlfa commented 1 year ago
mmexport1694075300064
hanlfa commented 12 months ago

Because I need to print some information according to the response data, the return timeout error gets no response and cannot make further judgment. who can help me?

pylessard commented 11 months ago

Hi, you should share some code. Either your ids are not configured properly or you are using the isotp.CanStack and you consume all the messages in parallel.

hanlfa commented 11 months ago

this is code,The code was simplified due to confidentiality system, but the timeout problem persisted。


import os
import time
import bincopy
import threading
import hashlib
import re
import can
import datetime
import isotp
import udsoncan
from can.interfaces.pcan import PcanBus
from udsoncan import services
from udsoncan.connections import PythonIsoTpConnection
from udsoncan.client import Client
from udsoncan.exceptions import *
from udsoncan.services import *
from udsoncan import DidCodec

class F195_did(udsoncan.DidCodec):
   def decode(self, payload):
      stage_version=chr(payload[0])+ chr(payload[1]) #默认10进制,需要根据实际转化
      xiahuaxian_1=chr(payload[2])  #_
      MajorVersion=str(payload[3]).zfill(2)+str(payload[4]).zfill(2)
      xiahuaxian_2 = chr(payload[5])  # _
      MinorVersion = str(payload[6]).zfill(2)+str(payload[7]).zfill(2)
      sw=stage_version+xiahuaxian_1+MajorVersion+xiahuaxian_2+MinorVersion
      print("SW:",sw)
      return sw
   def __len__(self):
      return 8    # encoded payload is 4 byte long

class StubbedDidCodec(DidCodec):
    def encode(self, did_value):
        return   did_value

    def decode(self, did_payload):
        return   did_payload

    def __len__(self):
        return 1

config = dict(udsoncan.configs.default_client_config)
config['use_server_timing'] = False
config['request_timeout'] = 30
config['p2_timeout'] =  0.05   #1
config['request_timeout'] = 25
config['p2_star_timeout'] =  5
config['data_identifiers'] = {
   0xF195 :F195_did,
}

tester_present_flag=False

def simple_periodic_send():
   """
   #发送一条周期为4000ms的周期报文到总线
   """
   while tester_present_flag:
      msg = can.Message(arbitration_id=0x7DF, data=[0x02, 0x3E, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00], is_extended_id=False)
      #bus.send_periodic(msg, 4)
      bus.send(msg)
      time.sleep(4)
def uds_download():
   diag_funcreq = 0x7DF
   diag_phyreq = 0x61B
   diag_phyresp = 0x71B
   global tester_present_flag
   tester_present_flag = True
   # Get flash driver and app files infomation.

# txid = diag_funcreq- 7DF
   tp_addr = isotp.Address(isotp.AddressingMode.Normal_11bits, txid=diag_funcreq, rxid=diag_phyresp) # Network layer addressing scheme
   stack = isotp.CanStack(bus=bus, address=tp_addr, params=isotp_params)               # Network/Transport layer (IsoTP protocol)
   conn = PythonIsoTpConnection(stack)# interface between Application and Transport layer
   with Client(conn, config=config) as client:
      print('-->Connection opened')
      # 10 Change Session - Entry extended session
      #try_times = 0
      while True:
         try:
            response = client.change_session(3)  
            DiagnosticSessionControl.interpret_response(response)
            if response.service_data.session_echo == DiagnosticSessionControl.Session.extendedDiagnosticSession:
               print('-->Change Session - Entry Extended Session is ok')
               break
         except TimeoutException:
            pass

 # Extended session
   config['p2_timeout'] = 15
# txid = 0x61B
   try:
      tp_addr = isotp.Address(isotp.AddressingMode.Normal_11bits, txid=diag_phyreq, rxid=diag_phyresp) # Network layer addressing scheme
      stack = isotp.CanStack(bus=bus, address=tp_addr, params=isotp_params)               # Network/Transport layer (IsoTP protocol)
      conn = PythonIsoTpConnection(stack)  # interface between Application and Transport layer
      with Client(conn, config=config) as client:  # Application layer (UDS protocol)
         # 31 Routing control - Start program condition check routine
         routin_progm_check_id = 0x0203
         reponse=client.routine_control(routin_progm_check_id, RoutineControl.ControlType.startRoutine)
         if reponse.original_payload==b'7101020300':
            print('-->Routing control - Start Program Condition Check Routine31010203 is ok')
         else:
            print(f'-->Routing control - Start Program Condition Check Routine31010203 failed{reponse.original_payload}')
   except Exception as e:
      print("出现异常:",e)

# txid = diag_funcreq
   # ID:diag_funcreq turn off all dtc setting by tester
   tp_addr = isotp.Address(isotp.AddressingMode.Normal_11bits, txid=diag_funcreq, rxid=diag_phyresp) # Network layer addressing scheme
   stack = isotp.CanStack(bus=bus, address=tp_addr, params=isotp_params)               # Network/Transport layer (IsoTP protocol)
   conn = PythonIsoTpConnection(stack)                                                 # interface between Application and Transport layer
   with Client(conn, config=config) as client:                                         # Application layer (UDS protocol)
      try:
         # 85 Control DTC setting - turn off dtc setting
         client.control_dtc_setting(services.ControlDTCSetting.SettingType.off)
         print('-->Control DTC setting - Turn off DTC setting8502 is ok')
      except:
         print('Tester turn off DTC8502 failed.')
      try:
         # 280303 Control con setting - turn off dtc setting
         client.communication_control(0x03, CommunicationControl.ControlType.disableRxAndTx)
         print('-->Commu Control - Disable Rx and Disable Tx280303 is ok')
      except:
         print('Tester turn off communication280303 failed.')

# tx = diag_phyreq
 #Programming session
   tp_addr = isotp.Address(isotp.AddressingMode.Normal_11bits, txid=diag_phyreq, rxid=diag_phyresp) # Network layer addressing scheme
   stack = isotp.CanStack(bus=bus, address=tp_addr, params=isotp_params)               # Network/Transport layer (IsoTP protocol)
   conn = PythonIsoTpConnection(stack)                                                 # interface between Application and Transport layer
   with Client(conn, config=config) as client:                                         # Application layer (UDS protocol)
      # read DID F195
      response = client.read_data_by_identifier([0xF195])
      print("F195:", response.service_data.values[0xF195])  # This is a dict of DID:Value
      print('-->DID read - DID read is ok')
      try:
         # 10 Change Session - Entry programming session 1002
         reponse=client.change_session(DiagnosticSessionControl.Session.programmingSession)
         if reponse.service_data.session_echo==2:
            print('-->Change Session - Entry Programming Session1002 is ok')
         else:
            print(f'-->Change Session - Entry Programming Session1002 failed{reponse.original_payload}')
      except:
         print('-->Change Session - Entry Programming Session1002 failed!')

      # 11 Reset ECU
      try:
         reponse=client.ecu_reset(ECUReset.ResetType.hardReset)
         if reponse.original_payload.hex()=='5101':
            print('-->Reset ECU1101 is ok')
         else:
            print(f'-->Reset ECU1101 failed:{reponse.original_payload}')
      except Exception as e:
         print(print(f'-->Reset ECU1101 failed:{e}'))
      time.sleep(10)
      # read DID F195
      response = client.read_data_by_identifier([0xF195])
      print("F195:", response.service_data.values[0xF195])

      config['p2_timeout'] = 15
      time.sleep(3)

      # txid = diag_funcreq
      # ID:diag_funcreq turn off all dtc setting by tester
      tp_addr = isotp.Address(isotp.AddressingMode.Normal_11bits, txid=diag_funcreq,
                              rxid=diag_phyresp)  # Network layer addressing scheme
      stack = isotp.CanStack(bus=bus, address=tp_addr, params=isotp_params)  # Network/Transport layer (IsoTP protocol)
      conn = PythonIsoTpConnection(stack)  # interface between Application and Transport layer
      with Client(conn, config=config,request_timeout=17) as client:  # Application layer (UDS protocol)
         try:
            response=client.change_session(3)
            DiagnosticSessionControl.interpret_response(response)
            if response.service_data.session_echo==DiagnosticSessionControl.Session.extendedDiagnosticSession:
               print('enter 1003 OK')
         except TimeoutException:
            pass
         try:
            # 280003 Control con setting - turn off dtc setting
            #client.communication_control(0x00, CommunicationControl.ControlType.enableRxAndTx)
            client.communication_control(0x00, 0x03)
            print('-->Commu Control - Enable Rx and Enable Tx280003 is ok')
         except:
            print('Tester turn on communication failed.')
         try:
            # 8501 Control DTC setting - turn on dtc setting
            client.control_dtc_setting(services.ControlDTCSetting.SettingType.on)
            print('-->Control DTC setting - Turn on DTC setting8501 is ok')
         except Exception as e:
            print(f'Tester turn on DTC failed.{e}')
         try:
            # 1001
            client.change_session(1)
            print('-->enter 1001 ok')
         except Exception as e:
            print(f'enter 1001 failed.{e}')

   # tx = diag_phyreq
   # Programming session
   tp_addr = isotp.Address(isotp.AddressingMode.Normal_11bits, txid=diag_phyreq,rxid=diag_phyresp)  # Network layer addressing scheme
   stack = isotp.CanStack(bus=bus, address=tp_addr,params=isotp_params)  # Network/Transport layer (IsoTP protocol)
   conn = PythonIsoTpConnection(stack)  # interface between Application and Transport layer
   #clear DTC
   with Client(conn, config=config) as client:
      try:
         client.clear_dtc()
         print('-->Firmware updated successfully!')
      except Exception as e:
         print(f'-->Firmware updated Failed!{e}')
   #tester_present_flag = False

if __name__ == "__main__":
   isotp_params = {
      'stmin': 20,
      # Will request the sender to wait 32ms between consecutive frame. 0-127ms or 100-900ns with values from 0xF1-0xF9
      'blocksize': 8,  # Request the sender to send 8 consecutives frames before sending a new flow control message
      'wftmax': 0,  # Number of wait frame allowed before triggering an error
      'tx_data_length': 8,  # Link layer (CAN layer) works with 8 byte payload (CAN 2.0)
      'tx_data_min_length': None,
      # Minimum length of CAN messages. When different from None, messages are padded to meet this length. Works with CAN 2.0 and CAN FD.
      'tx_padding': 0xAA,  # Will pad all transmitted CAN messages with byte 0x00.
      'rx_flowcontrol_timeout': 75,  # Triggers a timeout if a flow control is awaited for more than 1000 milliseconds,N_BS
      'rx_consecutive_frame_timeout': 50,# Triggers a timeout if a consecutive frame is awaited for more than 1000 milliseconds,N_CS
      'squash_stmin_requirement': False,
      # When sending, respect the stmin requirement of the receiver. If set to True, go as fast as possible.
      'max_frame_size': 4095,  # Limit the size of receive frame.
      'can_fd':False
   }
   try:
      bus = can.interface.Bus(bustype='pcan', channel='PCAN_USBBUS1', bitrate=500000)
   except:
      print('Connect PCAN failed.')
      os.system('pause')
      os._exit(0)

   print('ECU OTA PC Tool V1.0')
   thread1 = threading.Thread(target=simple_periodic_send)
   thread2 = threading.Thread(target=uds_download )
   # Enable to logging output
   udsoncan.setup_logging()
   thread2.start()
   thread1.start()
   os.system('pause')
   # 等待线程结束
   os._exit(0)
   thread1.join()
   thread2.join()
hanlfa commented 11 months ago

this is udsoncan log

2023-09-18 17:30:29 [INFO] Connection: Connection opened
2023-09-18 17:30:29 [INFO] UdsClient: DiagnosticSessionControl<0x10> - Switching session to extendedDiagnosticSession (0x03)
2023-09-18 17:30:29 [DEBUG] Connection: Sending 2 bytes : [b'1003']
2023-09-18 17:30:29 [DEBUG] Connection: No data received: [TimeoutException] - Did not receive frame IsoTP Transport layer in time (timeout=0.05 sec) 
2023-09-18 17:30:29 [ERROR] UdsClient: [TimeoutException] : Did not receive response in time. P2 timeout time has expired (timeout=0.050 sec)
2023-09-18 17:30:29 [INFO] UdsClient: DiagnosticSessionControl<0x10> - Switching session to extendedDiagnosticSession (0x03)
2023-09-18 17:30:29 [DEBUG] Connection: Sending 2 bytes : [b'1003']
2023-09-18 17:30:29 [DEBUG] Connection: Received 6 bytes : [b'5003003201f4']
2023-09-18 17:30:29 [INFO] UdsClient: Received positive response for service DiagnosticSessionControl (0x10) from server.
2023-09-18 17:30:29 [INFO] Connection: Connection closed
2023-09-18 17:30:29 [INFO] Connection: Connection opened
2023-09-18 17:30:29 [INFO] UdsClient: RoutineControl<0x31> - ControlType=0x01 - Starting routine ID 0x0203 (VehicleManufacturerSpecific) with a payload of 0 bytes
2023-09-18 17:30:29 [DEBUG] Connection: Sending 4 bytes : [b'31010203']
2023-09-18 17:30:29 [DEBUG] Connection: Received 5 bytes : [b'7101020300']
2023-09-18 17:30:29 [INFO] UdsClient: Received positive response for service RoutineControl (0x31) from server.
2023-09-18 17:30:29 [INFO] Connection: Connection closed
2023-09-18 17:30:29 [INFO] Connection: Connection opened
2023-09-18 17:30:29 [INFO] UdsClient: ControlDTCSetting<0x85> - SettingType=0x02 (off) - Turning DTC Off with a payload of 0 bytes
2023-09-18 17:30:29 [DEBUG] Connection: Sending 2 bytes : [b'8502']
2023-09-18 17:30:29 [DEBUG] Connection: Received 2 bytes : [b'c502']
2023-09-18 17:30:29 [INFO] UdsClient: Received positive response for service ControlDTCSetting (0x85) from server.
2023-09-18 17:30:29 [INFO] UdsClient: CommunicationControl<0x28> - ControlType=0x03 (disableRxAndTx) - Sending request with a CommunicationType byte of 0x03 (subnet=0x0. Flags : [NormalMsg,NetworkManagementMsg])
2023-09-18 17:30:29 [DEBUG] Connection: Sending 3 bytes : [b'280303']
2023-09-18 17:30:29 [DEBUG] Connection: Received 2 bytes : [b'6803']
2023-09-18 17:30:29 [INFO] UdsClient: Received positive response for service CommunicationControl (0x28) from server.
2023-09-18 17:30:29 [INFO] Connection: Connection closed
2023-09-18 17:30:29 [INFO] Connection: Connection opened
2023-09-18 17:30:29 [INFO] UdsClient: ReadDataByIdentifier<0x22> - Reading data identifier : 0xf195 (SystemSupplierECUSoftwareVersionNumberDataIdentifier)
2023-09-18 17:30:29 [DEBUG] Connection: Sending 3 bytes : [b'22f195']
2023-09-18 17:30:30 [DEBUG] Connection: Received 11 bytes : [b'62f19556345f00015f0001']
2023-09-18 17:30:30 [INFO] UdsClient: Received positive response for service ReadDataByIdentifier (0x22) from server.
2023-09-18 17:30:30 [INFO] UdsClient: DiagnosticSessionControl<0x10> - Switching session to programmingSession (0x02)
2023-09-18 17:30:30 [DEBUG] Connection: Sending 2 bytes : [b'1002']
2023-09-18 17:30:30 [DEBUG] Connection: Received 3 bytes : [b'7f1078']
2023-09-18 17:30:30 [DEBUG] Connection: Received 6 bytes : [b'5002003201f4']
2023-09-18 17:30:30 [INFO] UdsClient: Received positive response for service DiagnosticSessionControl (0x10) from server.
2023-09-18 17:30:30 [INFO] UdsClient: ECUReset<0x11> - Requesting reset of type 0x01 (hardReset)
2023-09-18 17:30:30 [DEBUG] Connection: Sending 2 bytes : [b'1101']
2023-09-18 17:30:30 [DEBUG] Connection: Received 3 bytes : [b'7f1178']
2023-09-18 17:30:32 [DEBUG] Connection: Received 3 bytes : [b'7f1178']
2023-09-18 17:30:33 [DEBUG] Connection: Received 2 bytes : [b'5101']
2023-09-18 17:30:33 [INFO] UdsClient: Received positive response for service ECUReset (0x11) from server.
2023-09-18 17:30:43 [INFO] UdsClient: ReadDataByIdentifier<0x22> - Reading data identifier : 0xf195 (SystemSupplierECUSoftwareVersionNumberDataIdentifier)
2023-09-18 17:30:43 [DEBUG] Connection: Sending 3 bytes : [b'22f195']
2023-09-18 17:30:43 [DEBUG] Connection: Received 11 bytes : [b'62f19556345f00015f0001']
2023-09-18 17:30:43 [INFO] UdsClient: Received positive response for service ReadDataByIdentifier (0x22) from server.
2023-09-18 17:30:46 [INFO] Connection: Connection opened
2023-09-18 17:30:46 [INFO] UdsClient: DiagnosticSessionControl<0x10> - Switching session to extendedDiagnosticSession (0x03)
2023-09-18 17:30:46 [DEBUG] Connection: Sending 2 bytes : [b'1003']
2023-09-18 17:31:01 [DEBUG] Connection: No data received: [TimeoutException] - Did not receive frame IsoTP Transport layer in time (timeout=15 sec) 
2023-09-18 17:31:01 [ERROR] UdsClient: [TimeoutException] : Did not receive response in time. P2 timeout time has expired (timeout=15.000 sec)
2023-09-18 17:31:01 [INFO] UdsClient: CommunicationControl<0x28> - ControlType=0x00 (enableRxAndTx) - Sending request with a CommunicationType byte of 0x03 (subnet=0x0. Flags : [NormalMsg,NetworkManagementMsg])
2023-09-18 17:31:01 [DEBUG] Connection: Sending 3 bytes : [b'280003']
2023-09-18 17:31:01 [DEBUG] Connection: Received 2 bytes : [b'6800']
2023-09-18 17:31:01 [INFO] UdsClient: Received positive response for service CommunicationControl (0x28) from server.
2023-09-18 17:31:01 [INFO] UdsClient: ControlDTCSetting<0x85> - SettingType=0x01 (on) - Turning DTC On with a payload of 0 bytes
2023-09-18 17:31:01 [DEBUG] Connection: Sending 2 bytes : [b'8501']
2023-09-18 17:31:16 [DEBUG] Connection: No data received: [TimeoutException] - Did not receive frame IsoTP Transport layer in time (timeout=15 sec) 
2023-09-18 17:31:16 [ERROR] UdsClient: [TimeoutException] : Did not receive response in time. P2 timeout time has expired (timeout=15.000 sec)
2023-09-18 17:31:16 [INFO] UdsClient: DiagnosticSessionControl<0x10> - Switching session to defaultSession (0x01)
2023-09-18 17:31:16 [DEBUG] Connection: Sending 2 bytes : [b'1001']
2023-09-18 17:31:31 [DEBUG] Connection: No data received: [TimeoutException] - Did not receive frame IsoTP Transport layer in time (timeout=15 sec) 
2023-09-18 17:31:31 [ERROR] UdsClient: [TimeoutException] : Did not receive response in time. P2 timeout time has expired (timeout=15.000 sec)
2023-09-18 17:31:31 [INFO] Connection: Connection closed
2023-09-18 17:31:31 [INFO] Connection: Connection closed
2023-09-18 17:31:31 [INFO] Connection: Connection opened
2023-09-18 17:31:31 [INFO] UdsClient: ClearDiagnosticInformation<0x14> - Clearing all DTCs (group mask : 0xFFFFFF)
2023-09-18 17:31:31 [DEBUG] Connection: Sending 4 bytes : [b'14ffffff']
2023-09-18 17:31:31 [DEBUG] Connection: Received 3 bytes : [b'7f1478']
2023-09-18 17:31:31 [DEBUG] Connection: Received 1 bytes : [b'54']
2023-09-18 17:31:31 [INFO] UdsClient: Received positive response for service ClearDiagnosticInformation (0x14) from server.
2023-09-18 17:31:31 [INFO] Connection: Connection closed
pylessard commented 11 months ago

Thanks. First, you don't need to call DiagnosticSessionControl.interpret_response(response). The client does it for you.

Also I find weird that you create and destroy a client for each request. You can use the same client.

In the canalyzer log that you shared, I do not see the message that is missing, so I see no issue so far.
You can enable the "isotp" logger in debug mode as well if you want to see more.

hanlfa commented 11 months ago

1.ok,i will delete DiagnosticSessionControl.interpret_response(response). 2.Because the flashing process will have a physical address and functional address distinction, so produced multiple clients, as you said, for the physical address and functional address coexistence, how to use a client to complete all the requests? 3.The current problem is that the canalyzer log is no problem, but in the udsoncan logging log, 8501 and 1001 have timeout problems, how to enable the "isotp" logger in debug mode,can you share some code?

pylessard commented 11 months ago

Ah ok, I did not noticed that you change the address as you go. you can just change the address on the stack with set_address(). The client will keep using the same stack and everything will be wonderful.

to enable isotp log: logging.getLogger('isotp').setLevel(logging.DEBUG)

I don'T see the problem in the canalyzer log you shared.

hanlfa commented 11 months ago

it is vary good,thank you.

pylessard commented 11 months ago

Do you still need help with that issue?

hanlfa commented 11 months ago

The problem is resolved, please close it