I am looking for a free API (in C or C++) for decoding CAN messages. I have all the information about the layout of data (Id, length, start bit, byte order, ... ) and I need now some functions to decode the hexadecimal values into human readable numbers.
Thank for your help.
Didn't find your answer? Ask the community — no account required.
P
Paul Keinanen
What is the difference between hexadecimal values and human readable numbers ?
Seriously, without knowing the exact protocol and what data is assigned to which _bit_ , you are not going to make much sense of these messages.
Paul
S
sequoia
Paul,
As I said I have the layout of the data, I know the protocol and the assignment of each bit. I have the description of the CAN data in a DBC file (Vector Informatik GmbH format). So I am able to say that the bits 11 to 16 of the message Id 0x305 represents the measurement of the temperature for example.
We can think that the decoding is very easy but it is not the case, you have to deal with the problem of endianess, a data can be represented by n bits where n is not a multiple of 8, etc. And the amount of messages can be very heavy.
So before writing some C code, I would like to know if there is a library that can help me and/or do that directly. I think that this problem occurs very often for each person that wants to analyse binary data (not in an Ascii representation for giving an answer to your question).
Gerald
D
Dave
Gerald,
You haven't made it exactly clear what you want, but I am going to assume you want something that takes the vector DBC file information and use it to generate the C for decoding the CAN signals.
Yes there is a tool that can do this from Vector Informatik, it produces all necessary code you need so that in your example the temperature is stored into a declared variable. It is useful if you are in the early stages and the database is undergoing a lot of change, you can automatically rebuild the code modules very quickly.
It however doesn't apply scaling. It doesn't convert your numbers into an ASCII representation so you can fire it out the serial port to a terminal program, you have to do this yourself. And finally it costs a very large amount of money.
I think the best you can do is to get on with the bit bashing. If your database is not changing much, if at all, then it's not really that big a problem to hand code it. To make it a bit easier it's worth making sure the layout of the signals in the CAN messages align as much as possible with byte boundaries and don't cross them without good reason.
As a matter of interest, how many messages and signals do you have?
Hope this helps.
Dave.
S
stephen
I think you mean something like Vector's CANdbLib
formatting link
I've never seen a free alternative.
stephen
S
sequoia
Hi Dave and Stephen Thanks for your answers. This is a bad news that a free library seems not to exist. I think I will try to decode messages myself. Dave, about your question, the DB is stable and contains about 200 signals. Gerald
S
sequoia
Hi Dave and Stephen
Thanks for your answers. This is a bad news that a free library seems not to exist. I think I will try to decode messages myself. Dave, about your question, the DB is stable and contains about 200 signals.
Gerald
D
Dave
OK, that's why you wanted an automated solution!
Join the Discussion
Have something to add? Share your thoughts — no account required.
Didn't find your answer?
Ask the community — no account required
Report Content
You are reporting this content to the moderators. They will look at it
ASAP.