It's the same like on www.ms4x.net just as Excel
Announcement
Collapse
No announcement yet.
SMG CAN Bus Decoding
Collapse
X
-
Hi guys,
I've got it
First of all, the description of Byte3 on www.ms4x.net is not absolutely correct... As I said before, there are two signals with 4 bits each in here.
That means:
Byte3:- ALIVE_COUNTER[0 - 3]
- GEAR_INFO_CHECKSUM[4 - 7]
- Nibble by Nibble:
- Set the ALIVE_COUNTER signal in Byte3 (lower nibble)
- calculate and set CHECKSUM signal in Byte3 (higher nibble)
- whole byte:
- put GEAR_INFO and ALIVE_COUNTER into calculation function and set the whole Byte3 at once.
Code:int calculateChecksum(int l_gear_info, int l_alive_counter) { tmp1 = (l_alive_counter ^ l_gear_info); tmp2 = ~(tmp1); tmp3 = (tmp2 & 0x0f); tmp4 = (tmp3 << 4); // here says www.ms4x.net: CHKSM_GEAR_INFO = Or CHKSM_GEAR_INFO , GEAR_INFO // and it is wrong, because we don't have the counter value in Byte3. // the correct value is: tmp5 = (tmp4 | l_alive_counter); return tmp5; }
- Likes 3
Comment
-
Thank you!
Originally posted by Tomba View PostI suppose there are many other calculations manufacturers can choose for this checksum.
With the E65 (for example) the checksum (at least in the PT_CAN) is calculated over the whole message by adding the single bytes to each other, then adding with overflow and so on. The checksum is 8bit long.
Comment
-
Originally posted by HeinrichG_V12 View PostThank you!
Well, there is no "general formula" for calculating the checksum, every manufacturer does it somehow differently. The checksum also does not exist in every message.
With the E65 (for example) the checksum (at least in the PT_CAN) is calculated over the whole message by adding the single bytes to each other, then adding with overflow and so on. The checksum is 8bit long.
Comment
-
Originally posted by HeinrichG_V12 View PostThank you!
Well, there is no "general formula" for calculating the checksum, every manufacturer does it somehow differently. The checksum also does not exist in every message.
With the E65 (for example) the checksum (at least in the PT_CAN) is calculated over the whole message by adding the single bytes to each other, then adding with overflow and so on. The checksum is 8bit long.…under construction.
Comment
Comment