Page 8 of 9

Re: Protocol j1587

Posted: Wed Mar 20, 2024 4:20 pm
by bios33
This is brilliant :)
I'll be home tonight and try it with a controller.

Re: Protocol j1587

Posted: Wed Mar 20, 2024 4:30 pm
by mnfisher
Let us know how it goes... Remote debugging is notoriously tricky :cry:

I think the one piece of error checking it needs is to check the length of the message - if it's greater than 21 bytes then reset and start looking for MID again.

As it stands - is the end isn't found then it will trample over memory and crash (using the position mod 10 would solve this)

Martin

Re: Protocol j1587

Posted: Wed Mar 20, 2024 9:30 pm
by bios33
Hi!
Regarding the row of two byte PIDs, for example: engine speed - PID 190, data 087 009 - PID_data[0] /; 087;/ + (PID_data[1] /;009;/<<8) I get a 16-bit value and multiply it by 0.25 (res/bit)

Re: Protocol j1587

Posted: Wed Mar 20, 2024 9:47 pm
by bios33
In this only option, it displays on the screen and after a few seconds the values ​​​​hang on the screen, but at the same time the diode (port B7) on the board blinks synchronously with the diode on the rs485 transceiver

Re: Protocol j1587

Posted: Wed Mar 20, 2024 9:55 pm
by bios33
bios33 wrote:
Wed Mar 20, 2024 9:47 pm
In this only option, it displays on the screen and after a few seconds the values ​​​​hang on the screen, but at the same time the diode (port B7) on the board blinks synchronously with the diode on the rs485 transceiver

Re: Protocol j1587

Posted: Wed Mar 20, 2024 10:02 pm
by bios33
bios33 wrote:
Wed Mar 20, 2024 9:55 pm
bios33 wrote:
Wed Mar 20, 2024 9:47 pm
In this only option, it displays on the screen and after a few seconds the values ​​​​hang on the screen, but at the same time the diode (port B7) on the board blinks synchronously with the diode on the rs485 transceiver

Re: Protocol j1587

Posted: Wed Mar 20, 2024 10:49 pm
by mnfisher
Regarding the row of two byte PIDs, for example: engine speed - PID 190, data 087 009 - PID_data[0] /; 087;/ + (PID_data[1] /;009;/<<8) I get a 16-bit value and multiply it by 0.25 (res/bit)
So - the PID - get from PID[0] - if this is >= 128 then the 16 bit value is PID_Data[0] (NOT PID_Data[0] + PID_Data[1]) As mentioned - the value might have the MSB and LSB swapped. If PID[n] <= 127 then PID_Data[n] = 8 bit value (padded to 16 bits with 0 in MSB)

The PID PID[1] has it's value in PID_Data[1]

There should be PID[n] and PID_Data[n] where n = 0..ISR_POS

However - it does sound like it is then crashing - see notes above about error checking - I'll add a couple of checks - max message size is trickier - but where "ISR_Pos = ISR_Pos+1" -> change to ISR_Pos = (ISR_Pos + 1) % 10 (Two places in the ISR) It might just be the reset needs a tweak too?

Can you step through in simulation using some of the data from above.

Re: Protocol j1587

Posted: Thu Mar 21, 2024 9:30 am
by mnfisher
The reset needs the checksum resetting too. So will only receive one message as is...

V2. 0 this evening 🙄

Re: Protocol j1587

Posted: Thu Mar 21, 2024 10:47 am
by bios33
Hi all !
I understand that if the checksum = 0, this means the end of the line formation

Re: Protocol j1587

Posted: Thu Mar 21, 2024 11:01 am
by mnfisher
Yes, and no.

It actually stores a 16bit sum - the twos complement of this (% 256) needs to be 0.

Martin