Hi,
Glad to hear it's receiving ok!
Can you post your code that's giving the errors? I used m ((msg) as an array to receive the data and x (& y) as data to be extracted.
Both were declared as local variables ( hence the '.' at the start) - it's good practice to keep a minimum number of globals to aid readability.
You can output all the data in the message using a loop: - for example to output it to UART. Note that m, i and error are defined as local (m[12] byte, byte and byte) and I don't check error (if .error & 0x80 then something has gone awry)
Martin
C-code
-
- Valued Contributor
- Posts: 1208
- Joined: Wed May 31, 2017 11:57 am
- Has thanked: 70 times
- Been thanked: 440 times
Re: C-code
For completeness:
Combined j1850 - here demo'd as if pin d4 is pulled high acts as receiver else as transmitter....
Not sure if it's worth pulling the code off as a component??
Note this code is very AVR specific (should work on any Arduino/AVR chip with Timer1) - the timing code is however very localised (start, stop timer and retrieve number of ticks) so it might be possible for some PIC/ARM whizz to convert??
Then I found this-
http://www.interfacebus.com/Automotive_ ... 0_Bus.html which gives a good description of the bus - and I've used an inverse of this from the c above.. Note that the bus may be at 20v so the signal needs to be shifted and inverted to work with the arduino. It would be fairly straightforward to invert the signal - I also don't think the send compiled with the message standard - for example there is no crc - although the code is there..
Martin
Combined j1850 - here demo'd as if pin d4 is pulled high acts as receiver else as transmitter....
Not sure if it's worth pulling the code off as a component??
Note this code is very AVR specific (should work on any Arduino/AVR chip with Timer1) - the timing code is however very localised (start, stop timer and retrieve number of ticks) so it might be possible for some PIC/ARM whizz to convert??
Then I found this-
http://www.interfacebus.com/Automotive_ ... 0_Bus.html which gives a good description of the bus - and I've used an inverse of this from the c above.. Note that the bus may be at 20v so the signal needs to be shifted and inverted to work with the arduino. It would be fairly straightforward to invert the signal - I also don't think the send compiled with the message standard - for example there is no crc - although the code is there..
Martin