I've written a quick and dirty C# app that can correctly implement the algorithm that was posted in this forum and in the recently posted spreadsheet. It can be downloaded at: http://www.kkmfg.com/CRC_Nissan.zip there is an executable in there as well as the source code.

I will upload it to my github account as well. I'm Collin80 on github: https://github.com/collin80 I don' t have a Nissan Leaf but I am heavily into canbus and reverse engineering so there should still be relevant stuff there.

You can enter in the CRC polynomial and the first 7 bytes and it will return the correct CRC byte. I have tested this on the examples from the spreadsheet.

JeremyW wrote:Weber and all, you might wanna take a look at EV can messages 1DB, 1DC, and 55B to see if 0x85 works for those too. The last byte looks like a CRC (values all over the place).

CRC stuff isn't clicking for me yet. I'll have to read that paper for like the 3rd or 4th time.

The posted security byte algorithm does in fact work for very many of the other frames. I think I only found a couple that didn't match and they probably were non-command frames that they didn't bother to secure.

1DA works1DB works1DC works11A works1D4 works1F2 does not check out284 does not check out55B works

So, mostly things that work out show up as having a possible CRC in the last byte in the spreadsheet. The odd one out is 1DA which someone guessed to have phase current in that byte. It doesn't - it's a security byte.

Hmm. I was confident that 1DA byte 7 had the phase currents with the mux on byte 6. The signals were periodic in nature and were steady when stationary.

11F is VCM state and has at least command charge power on it (for 2012's). Considering pumping in extra amps doesn't seem to bother things, not surprised this isn't secured.

284 is a relay via the VCM from the ABS module (which handles wheel speeds). It's for the shift selector so that it can decide whether to allow parking or change of direction. It would be really bad to fake this and well shift into reverse or park at speed. Not sure if everything else would comply or not. Wouldn't test it!

If you guys get this working I have another request... Aside from upping the off-the-line torque, I'd like to have the B-mode feel of 2011/12 Eco mode without making the accelerator sluggish. Ie, I'd like to UN-map the the eco sluggishness accelerator pedal remapping while keeping the extra regen!

I checked all the packets I have logged on EV-CAN to identify valid 0x85 checksum bytes and agree that Collin has already found all the 8-byte ones (11A 1D4 1DA 1DB 1DC 55B), but there is also one shorter packet, 0x50C of length 6, which also seem to consistently have a valid checksum in the last byte. I don't have any idea what this message is for, and it's unexcitingly repetitive: byte 3 cycles 0, 1, 2, 3 every 4 packets and byte 4 toggles between 5D and B2 every 5 packets (almost inverted bits %01011101 and %10110010, except for bit 4 which is always 1).

I also spotted one packet of length 7 on the CAR-CAN which has a valid checksum in the last byte: 0x1CB - which makes sense if it is indeed commanded brake/regen as TickTock's spreadsheet suggests.

Sorry to resurrect this thread but I'm interested in the leaf CANBUS crc and security type code formulae. I'm doing a similar project on another system and some sample repeating CANBUS data is below.

I'm struggling to work out how the two bytes at the end of the packet are generated. I assume the last is a CRC and the penultimate one some sort of security check as it is may not be data related. Any leads would be appreciated. Sadly polynomials is not my strong point.

Hi retepsnikrep. The fact that the last 16 bit number cycles through 12 different values while the preceding 6 bytes remain all zero, means that it is not simply a CRC. Nor can the last 8 bit number be a CRC since we see four different values when the 7 preceding bytes are all zero. So I'm sorry, I don't know what's going on there.

Ok a slightly different problem. The canbus sends me the following hex data from a battery management system.

Just to summarise the 12 bit hex voltage data obtained from the 10 cell Lithium BMS. I have grouped it as required. The test voltages I used are not 100% accurate but should be pretty near the number quoted below. e.g. 4v quoted could be 3.95 or 4.05 etc etc

Ignore the zero volt readings. It looks like it can't measure anything below about 0.4. V. Average the readings for each of the other voltages and fit a straight line to it. In decimal, it looks like approximately voltage = (reading + 64) / 648.