-5

I'm getting a CAN message 8 bytes length and that's it format

spreadsheet with format details

I'm getting Lat and Long as

a9 00 ff 0f 32 ff cf 7f

Hope I get a C code that interprets the value.

The expected values, 53.3, 10.0

andreahmed
  • 29
  • 5
  • @P__J__ I don't want code at least, I want the math – andreahmed Jun 20 '19 at 17:49
  • really? `Hope I get a C code that interprets the value.` – 0___________ Jun 20 '19 at 17:50
  • If you have a device, you should have the data sheet for it. It probably tells you exactly what to do. Is it NMEA 2000? – yhyrcanus Jun 20 '19 at 17:51
  • @yhyrcanus I don't know about which device is it, I have the hex values as it is – andreahmed Jun 20 '19 at 17:58
  • 1
    GPS receivers with a CAN interface might be using their own protocol. Without the datasheet or some other description of the protocol it's using, there's no way to know how to interpret those bytes. – Lee Daniel Crocker Jun 20 '19 at 18:16
  • Are you sure that the binary data and the expected values are matching? I.e. si the binary data generated exactly for these coordinates? Also is it 53.3 North or South? Is it 10.0 West or East? Do you have any information on whether the data is transferred little-endian or big endian? – MSpiller Jun 24 '19 at 13:08
  • @M.Spiller he's from germany (look at the excel doc), so it's north and east. I spent around 2 hours last week playing around with it as a fixed point number (how i'd design it: longitude is out of 180, lat is 90) and got nowhere with it. I'd suggest he drives around the autobahn and record more points. – yhyrcanus Jun 24 '19 at 16:25

1 Answers1

-1

That message you posted is hexadecimal, so it can be easily translated into values. Remembering that hex is a base 16 number, to convert to decimals we do for example:

cf = (12 * 16^1) + (15 * 16^0) = 12*16 + 15*1 = 207

The exponent is the position of the digit starting from the right, while the number that is multiplied by is the decimal equivalent of the hex.

More on hex here.

philoez98
  • 493
  • 4
  • 13
  • How is that related to my can message example ? Can you do your solution on the CAN message example and show how the expected values are calculated ? – andreahmed Jun 20 '19 at 17:44
  • 2
    I suspect those values are not binary integers but probably 32-bit floats. – Lee Daniel Crocker Jun 20 '19 at 17:52
  • Based on the expected result I think it's possible. But this might still be useful, as it seems that the question is more about the math behind it than actual code. – philoez98 Jun 20 '19 at 17:54