Page 6 of 9

Re: Protocol j1587

Posted: Wed Mar 13, 2024 9:32 am
by mnfisher
You can set a character in a string to 128.as above. Each character is a byte. You can set values using a number as shown or a character (in single quotes) or set the whole string.

Re: Protocol j1587

Posted: Wed Mar 13, 2024 9:44 am
by mnfisher
Just done a quick test

I did PutArray(.test, 10)
LookForValue(.seek, 1, true, true)

Where test = {x,x,x,128,129...) where x is any value
and seek[0] = 128

LookForValue just returns 1 if the search value is found. (would the index (or -1) be better?) Then GetByte returns the 'following' data
So in this case - the GetByte returns 129

If you are using an interrupt to load the data - you could use WaitForValue as an alternative..
cb.fcfx
(9.38 KiB) Downloaded 12 times

Re: Protocol j1587

Posted: Wed Mar 13, 2024 12:28 pm
by RGV250
Hi,
When you say it works on the bench are you using live data from the tractor or some simulator? If it is live data then are you using a bench PSU and when on the tractor using the tractor supply. Does it work OK with the engine not running and then give problems when it is running?

Regards,
Bob

Re: Protocol j1587

Posted: Wed Mar 13, 2024 2:55 pm
by bios33
Thank you very much "minfisher" for the example, it helped me understand searching for data in the buffer.
Now there is a new problem: the bytes are repeated on the screen, although I display them in turn from "Mid_array[0] to Mid_attay[3]. What could be the problem?
Regards Joni!

Re: Protocol j1587

Posted: Wed Mar 13, 2024 3:07 pm
by bios33
RGV250 wrote:
Wed Mar 13, 2024 12:28 pm
Hi,
When you say it works on the bench are you using live data from the tractor or some simulator? If it is live data then are you using a bench PSU and when on the tractor using the tractor supply. Does it work OK with the engine not running and then give problems when it is running?

Regards,
Bob
Greetings! Everything is fine with the food, there are no problems, that’s for sure. The problem is that the device does not work correctly when other control units are on the bus. For example: in a certain line checksum =102 and at the same time there is PID 102 - turbo pressure and mixing the turbine readings skips unnecessary data, and so on with almost all indicators. Something like this

Re: Protocol j1587

Posted: Wed Mar 13, 2024 4:24 pm
by mnfisher
I think the issue is - your code continually searches for 128 - and as soon as it is found - attempts to read 4 bytes from 'after' the 128.
These may not have been received yet...
So - one solution is wait for 128 to be found then wait until caunt_rx >= 4 and then display the values.

Martin

Re: Protocol j1587

Posted: Wed Mar 13, 2024 5:08 pm
by mnfisher
I tried this - I've used a timer interrupt to add data if running as a simulation.
V1.7.fcfx
(23.77 KiB) Downloaded 14 times

Re: Protocol j1587

Posted: Thu Mar 14, 2024 7:39 am
by bios33
Hi all!
I tried V1.7 but the repetition is still there, I changed the delay but alas to no avail, everything is perfect in the simulator.
I’ll transfer it to the mega2560 in a minute and try, maybe there’s a problem with the controller.

Re: Protocol j1587

Posted: Thu Mar 14, 2024 8:03 am
by mnfisher
Odd, how about waiting until the value changes from 128 - it sounds as though only the start byte is being received correctly. Can you just display (or send to uart) all the data received?

Re: Protocol j1587

Posted: Thu Mar 14, 2024 9:09 am
by bios33
Here are the screenshots
The controller receives the same data as the FC