rnd-ash / OpenVehicleDiag

A rust based cross-platform ECU diagnostics and car hacking application, utilizing the passthru protocol
GNU General Public License v3.0
815 stars 92 forks source link

[BUG] Start UDS Diag Session over J1939 #30

Open Daniboum opened 3 years ago

Daniboum commented 3 years ago

I'm not able to start a UDS Diag Session to an ECU over J1939.

I'm trying to connect to a CPC4, Mercedes Off-Highway engine ECU. I tried to parse its CBF with CBF Parser but got an error (would probably be the topic of another bug).

I'm using with your great J2534 Firmware on the Macchina A0, the CAN Analyzer functionality is working perfectly. However while trying to start a diagnostic session in the manual mode, the frame with ID 0x18DA00F1 is not appearing on the CAN.

Here below is what I get in the log. In the first line I see a baudrate of 500k, where I need 250k. In the CAN Analyzer it is possible to change the baudrate. But in the diagnostic mode?

[DEBUG] - Requesting channel open. ID: 0, Protocol: ISO15765, baud: 500000, flags: 0x0000 [DEBUG] - Write data: COMM_MSG: ID: 17 Type: OpenChannel, Args=[00, 00, 00, 00, 06, 00, 00, 00, 20, A1, 07, 00, 00, 00, 00, 00] [M2LOG] - Standard CAN detected! [M2LOG] - Normal ISO-TP Addressing detected! [DEBUG] - Command took 19213us to execute [DEBUG] - M2 opened channel! [DEBUG] - Channel 0 writing IOCTL Param: ISO15765_STMIN. Param value: 20 [DEBUG] - Write data: COMM_MSG: ID: 18 Type: IoctlSet, Args=[00, 1F, 00, 00, 00, 14, 00, 00, 00] [DEBUG] - Command took 8929us to execute [DEBUG] - Channel 0 writing IOCTL Param: ISO15765_BS. Param value: 8 [DEBUG] - Write data: COMM_MSG: ID: 19 Type: IoctlSet, Args=[00, 1E, 00, 00, 00, 08, 00, 00, 00] [DEBUG] - Command took 7899us to execute [DEBUG] - Filter specified. Type: Mask filter, Data: [0, 0, 255, 255] [DEBUG] - Filter specified. Type: Pattern filter, Data: [24, 218, 241, 0] [DEBUG] - Filter specified. Type: Flow control filter, Data: [24, 218, 0, 241] [DEBUG] - Setting ISO-TP flow control filter (ID: 0) on channel 0. Mask: [00, 00, FF, FF], Pattern: [18, DA, F1, 00], FlowControl: [18, DA, 00, F1] [DEBUG] - Write data: COMM_MSG: ID: 1A Type: SetChannelFilter, Args=[00, 00, 00, 00, 00, 00, 00, 00, 03, 00, 00, 00, 04, 00, 00, 00, 04, 00, 00, 00, 04, 00, 00, 00, 00, 00, FF, FF, 18, DA, F1, 00, 18, DA, 00, F1] [DEBUG] - Command took 23438us to execute [DEBUG] - M2 set filter 0 on channel 0! [DEBUG] - Channel 0 writing message: Protocol: ISO 15765, RxStatus: 00000000, TxFlags: 00000040, Data: [18, DA, 00, F1, 10, 03]. Response required?: false [M2LOG] - Send frame -> 18DA00F1 (LEN: 8) [02 10 03 00 00 00 00 00]

rnd-ash commented 3 years ago

Yes this would have been my assumption. I have been assuming all UDS sessions take place on standard 500kbps CAN over the OBD port. I will go ahead and add an option to configure the baudrate