Python Forum
ecu CAN frame vin number - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Networking (https://python-forum.io/forum-12.html)
+--- Thread: ecu CAN frame vin number (/thread-41356.html)



ecu CAN frame vin number - lebossejames - Dec-30-2023

Hello,

I try to get my VIN number from my ECU of my car with my MKS Canable v1.0 (Candlelight firmware)

I get theses traces, i get only bytearray(b'\x10\x14I\x02\x01W0L'), it missed all other characters

Message1 sent on socketcan channel 'can0'
Message2 sent on socketcan channel 'can0'
Message1 sent on socketcan channel 'can0'
Message2 sent on socketcan channel 'can0'
bytearray(b'\x10\x14I\x02\x01W0L')
Message1 sent on socketcan channel 'can0'
Message2 sent on socketcan channel 'can0'
bytearray(b'\x10\x14I\x02\x01W0L')
My python code:
import usb
import can
import time

dev = usb.core.find(idVendor=0x1D50, idProduct=0x606F)

filters = [
{"can_id": 0x7E8, "can_mask": 0x1FFFFFFF, "extended": False},


]
bus = can.Bus(channel="can0", interface="socketcan", can_filters=filters,bitrate=125000)

def send_one():
	msg1 = can.Message(arbitration_id=0x7DF, data=[0x02, 0x09, 0x02, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF], is_extended_id=False)
	


	try:
		bus.send(msg1)

		print(f"Message1 sent on {bus.channel_info}")
		time.sleep(0.5)
		msg2 = can.Message(arbitration_id=0x7DF, data=[0x30, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF], is_extended_id=False)
		bus.send(msg2)
		print(f"Message2 sent on {bus.channel_info}")
	except can.CanError:

		print("Message NOT sent")






send_one()
while True:
	send_one()
	#time.sleep(2)
	try:		
		response = bus.recv(timeout=2)
		print(response.data)
	except can.CanError:
		print("CAN error")
	
Do you know how can i resolve my problem?
My final goal is display all informations of HW from ECU.

Thank you.