I'm trying to get information from the ECU but haven't succeeded. I tried two ways:
the first way. my code:
bus = can.Bus(interface='pcan', channel='PCAN_USBBUS1', bitrate=250000)
tp_addr = isotp.Address(isotp.AddressingMode.Normal_29bits, txid=0x1C440019, rxid=0x1C460019)
stack = isotp.CanStack(bus=bus, address=tp_addr, params=isotp_params) # Network/Transport layer (IsoTP protocol)
stack.set_sleep_timing(0, 0) # Speed First (do not sleep)
conn = PythonIsoTpConnection(stack) # interface between Application and Transport layer
if __name__ == '__main__':
with Client(conn, request_timeout=1) as client: # Application layer (UDS protocol)
try:
# temp_boot_loader_check_alive()
client.tester_present()
except NegativeResponseException as e:
print('Server refused our request for service %s with code "%s" (0x%02x)' % (
e.response.service.get_name(), e.response.code_name, e.response.code))
except (InvalidResponseException, UnexpectedResponseException) as e:
print('Server sent an invalid payload : %s' % e.response.original_payload)
except TimeoutException as e:
print('Server Response Timeout')
except ValueError as e:
bus.shutdown()
print(e.args)
bus.shutdown()
the first way. my console:
C:\workspace\venv_3.8_64\Scripts\python.exe C:/workspace/companion_chip_automation/source_files/pcan_connection.py
Bus error: an error counter reached the 'heavy'/'warning' limit
Bus error: an error counter reached the 'heavy'/'warning' limit
Server Response Timeout
[TimeoutException] : Did not receive response in time. Global request timeout time has expired (timeout=1.000 sec)
the second way. my code:
mycan = can.interfaces.pcan.PcanBus(channel='PCAN_USBBUS1', fd=True, f_clock_mhz=20, nom_brp=1, nom_tseg1=55, nom_tseg2=24, nom_sjw=12,data_brp=1, data_tseg1=27, data_tseg2=12, data_sjw=6,auto_reset=True, receive_own_messages=True)
msg = can.Message(timestamp=0.0, arbitration_id=0x1C440019, is_extended_id=True, is_remote_frame=False, is_error_frame=False, channel=None, dlc=3, data=[0x22, 0x02, 0x06], is_fd=True, is_rx=False, bitrate_switch=True, error_state_indicator=False, check=False)
mycan.send(msg)
time.sleep(5)
data = mycan.recv(timeout=1)
print(msg)
print(data)
exit()
The second way. my console:
Timestamp: 0.000000 ID: 1c440019 X Tx F BS DL: 3 22 02 06
Timestamp: 1710689623.385791 ID: 001 S Rx DL: 4 00 00 00 00
my questions:
1. why do I get the error?
2. why do I get an empty response?
3. how do I fix this?