PcmHammer with ST1110 (sparkfun version)

User avatar
Gampy
Posts: 2331
Joined: Sat Dec 15, 2018 7:38 am

Re: PcmHammer with ST1110 (sparkfun version)

Post by Gampy »

NSFW wrote:Feel free to use the "Test Kernel" button, and the code behind it to put the PCM into whatever state you need.
I do, I have ... :)

Always like to go back to basics for proving though ...
NSFW wrote:You can remove the code in the 'finally' blocks that tells the kernel to reboot the PCM.
That I did not know ... Do now, Thank you!
NSFW wrote:Anyway, it looks like if you were patient enough it might be able to read the whole PCM, but if you can figure out why the read requests had to be sent twice you might only need half as much patience. :)
[03:43:31:916] ElmDevice initialization starting.
[04:45:12:453] Read failed, Error

I tried ... note the start/end time. :shock:
Got to 87%

I noticed the twice thing when I was in PuTTY, had to hit enter and extra time, that's where I'm going next ...
NSFW wrote:I'm not confident about the timing in the kernel code, so if you find any way to make that more reliable, I'd like to know about it.
Yea, right! As a coder I ain't up to your ankles ... But I'm here to help anyway I can so of course I would pass anything along.
NSFW wrote:The behavior with the AllPro is what matters most, though. Between the 4X capability and the large buffer sizes, it's significantly faster than anything else, and at $40 I expect it to be the most popular interface by far.
I suspect ... I'm doing this for two reasons, #1 is the Brain Food, the other is the fact I have nothing better to do!

And even if the Allpro was setting here I would still be doing the same thing, feeding the brain. :)

-Enjoy
Intelligence is in the details!

It is easier not to learn bad habits, then it is to break them!

If I was here to win a popularity contest, their would be no point, so I wouldn't be here!
User avatar
NSFW
Posts: 679
Joined: Fri Feb 02, 2018 3:13 pm

Re: PcmHammer with ST1110 (sparkfun version)

Post by NSFW »

Ah, I didn't see the timestamp... You do have patience. :)

Related to removing the 'finally' code... If you want to do a lot of testing with one kernel, you might also want to change the kernel so that it doesn't reboot after being idle for a little while. For testing lots of changes to kernel code, it is nice to have it reboot fairly quickly so that I could load a new kernel without manually rebooting, but that might not be the best thing in general. The current code has "timeout = 100;" and you could make that 10 or 10,000 if you want.
Please don't PM me with technical questions - start a thread instead, and send me a link to it. That way I can answer in public, and help other people who have the same question. Thanks!
User avatar
Gampy
Posts: 2331
Joined: Sat Dec 15, 2018 7:38 am

Re: PcmHammer with ST1110 (sparkfun version)

Post by Gampy »

NSFW wrote:Ah, I didn't see the timestamp... You do have patience. :)
I have no patience ... life is forcing patience on me without choice!
NSFW wrote:Related to removing the 'finally' code... If you want to do a lot of testing with one kernel, you might also want to change the kernel so that it doesn't reboot after being idle for a little while. For testing lots of changes to kernel code, it is nice to have it reboot fairly quickly so that I could load a new kernel without manually rebooting, but that might not be the best thing in general. The current code has "timeout = 100;" and you could make that 10 or 10,000 if you want.
Kernel reboot timeout ... Yup, seen that, haven't felt the need to change it yet.

Actually, I added a 'Test Colonel' button, copied Vehicle.TestKernel.cs to Vehicle.Colonel.cs, renamed and whittled it into shape for my testing needs ...

However, It doesn't seem to leave the kernel running ... When I exit PcmHammer and try communicating with PuTTY the kernel does not respond. It does work if I task kill PcmHammer.
I'd say I've missed some shutdown code somewhere.

On a different note ...
Having a hard time figuring out why it takes two read requests (3501...) after the first one, first request works as expected, after that it takes two requests, the first one returns NO DATA.
Even in PuTTY (after killing PcmH):
<enter>
NO DATA
> AT SH6D10F0 <enter>
> OK
> 350100F5000000 <enter>
> 6CF0107501546CF09D
6D F0 10 36 01 00 E1 00 00 E1 00 06 9A 00 00 06 9A 00 00 06 9A ... snip ... 00 00 06 9A 00 00 06 9A 00 00 24 AC
> <enter> (repeat last command)
NO DATA
<enter> (repeat last command)
> 6CF0107501546CF09D
6D F0 10 36 01 00 E1 00 00 E1 00 06 9A 00 00 06 9A 00 00 06 9A ... snip ... 00 00 06 9A 00 00 06 9A 00 00 24 AC
> <enter> (repeat last command)
NO DATA
<enter> (repeat last command)
> 6CF0107501546CF09D
6D F0 10 36 01 00 E1 00 00 E1 00 06 9A 00 00 06 9A 00 00 06 9A ... snip ... 00 00 06 9A 00 00 06 9A 00 00 24 AC

Thanks

-Enjoy
Intelligence is in the details!

It is easier not to learn bad habits, then it is to break them!

If I was here to win a popularity contest, their would be no point, so I wouldn't be here!
User avatar
NSFW
Posts: 679
Joined: Fri Feb 02, 2018 3:13 pm

Re: PcmHammer with ST1110 (sparkfun version)

Post by NSFW »

There's an issue with the ELM-based devices (AllPro and Scantool) where if the PCM sends its reply too quickly, they'll miss it. And I just noticed that there is no delay before sending the reply to the read command, so I suspect this is what you're running into. The app has logic to retry, but it would be faster if we got the timing right so it wouldn't need to retry.

I'm still not sure exactly what the delay should be, but if you insert a call to this function, with a parameter of about 5, that might solve the problem. If the delay is too long or too short, the devices will miss it.

It just needs to be called right before sending the reply message:

Code: Select all

void ElmPause(int iterations)
{
	for (int outer = 0; outer < iterations; outer++)
	{
		for (int inner = 0; inner < 100; inner++)
		{
			asm("nop");
			asm("nop");
			asm("nop");
			asm("nop");

			asm("nop");
			asm("nop");
			asm("nop");
			asm("nop");
		}

		ScratchWatchdog();
	}
}
Please don't PM me with technical questions - start a thread instead, and send me a link to it. That way I can answer in public, and help other people who have the same question. Thanks!
User avatar
Gampy
Posts: 2331
Joined: Sat Dec 15, 2018 7:38 am

Re: PcmHammer with ST1110 (sparkfun version)

Post by Gampy »

Whats your thoughts on location?

I've placed no ops in ReadMode35 before the agree packet and between the agree and payload packets only to find it makes things worse.
I then removed all delays and LongSleepWithWatchdog() and it more or less worked.

In the meantime, remember, no question is a dumb question ... what does 'DLC' stand for?

Check out the latest log though ... :-)

Code: Select all

[10:50:00:921]  Voltage: 12.7V
[10:50:00:937]  Elm ID: ELM327 v1.3a
[10:50:01:015]  ScanTool device ID: STN1110 v4.2.1
[10:50:18:515]  Querying operating system of current PCM.
.
. snip
.
[11:50:50:468]  Recieved block starting at 524055 / 0x7FF17. 99%
[11:51:20:546]  Will save to T:\Automotive\PcmHacks\PcmHacks\Apps\PcmHammer\bin\Debug\first-fullread.bin
[11:51:20:546]  Saving contents to T:\Automotive\PcmHacks\PcmHacks\Apps\PcmHammer\bin\Debug\first-fullread.bin
FirstFullRead.bin: 524288 bytes

I believe the only changes are:
  • Fix array size in common.c
  • Comment out LongSleepWithWatchdog() in ReadMode35().
  • Change MaxReceiveSize in ScanToolDeviceImplementation.cs to 245
Still have the issue with no data on every other request, not sure where to go on that at the moment, suggestions welcome.
Gotta prove what's causing that or it's going to drive me crazier then I already am!

-Enjoy
Intelligence is in the details!

It is easier not to learn bad habits, then it is to break them!

If I was here to win a popularity contest, their would be no point, so I wouldn't be here!
User avatar
antus
Site Admin
Posts: 8237
Joined: Sat Feb 28, 2009 8:34 pm
cars: TX Gemini 2L Twincam
TX Gemini SR20 18psi
Datsun 1200 Ute
Subaru Blitzen '06 EZ30 4th gen, 3.0R Spec B
Contact:

Re: PcmHammer with ST1110 (sparkfun version)

Post by antus »

I'd have expected to need it between the mode 75 response and the mode 36 response. It needs to be long enough for the data to be sent out the serial side to the pc, before it needs to bitbang the next vpw packet in.

DLC stands for Data Link Controller. See attached.
Attachments
mc68hc58.pdf
(700.8 KiB) Downloaded 403 times
Have you read the FAQ? For lots of information and links to significant threads see here: http://pcmhacking.net/forums/viewtopic.php?f=7&t=1396
User avatar
Gampy
Posts: 2331
Joined: Sat Dec 15, 2018 7:38 am

Re: PcmHammer with ST1110 (sparkfun version)

Post by Gampy »

antus wrote:I'd have expected to need it between the mode 75 response and the mode 36 response. It needs to be long enough for the data to be sent out the serial side to the pc, before it needs to bitbang the next vpw packet in.
Am I wrong in thinking that is where I already tried ...
In ReadMode35() between the two packets (agree and payload), about line 44 in develop/kernels/read-kernel.c.
antus wrote:DLC stands for Data Link Controller. See attached.
O-boy o-boy ... talk about feeling stupid!
Yup, I do ...

I happen to have the m68k programmers reference, AND I currently have it open ... Though it does not say Data Link Controller across the top.

And as the feeling stupid rule goes ... If you're feeling stupid, you've learned something you'll likely never forget!

Thank Antus.

-Enjoy
Intelligence is in the details!

It is easier not to learn bad habits, then it is to break them!

If I was here to win a popularity contest, their would be no point, so I wouldn't be here!
User avatar
NSFW
Posts: 679
Joined: Fri Feb 02, 2018 3:13 pm

Re: PcmHammer with ST1110 (sparkfun version)

Post by NSFW »

I suspect it would help to have some delay in between the mode 75 and mode 36 too, but the issue I was referring to requires a delay right before sending the mode 75 message. That's where the interface device needs to switch between sending and receiving, and if the message comes in before the switch is complete, the message gets lost.
Please don't PM me with technical questions - start a thread instead, and send me a link to it. That way I can answer in public, and help other people who have the same question. Thanks!
User avatar
Gampy
Posts: 2331
Joined: Sat Dec 15, 2018 7:38 am

Re: PcmHammer with ST1110 (sparkfun version)

Post by Gampy »

Code: Select all

void ReadMode35()
{
	unsigned length = MessageBuffer[5];
	length <<= 8;
	length |= MessageBuffer[6];

	unsigned start = MessageBuffer[7];
	start <<= 8;
	start |= MessageBuffer[8];
	start <<= 8;
	start |= MessageBuffer[9];

	// TODO: Validate the start address and length, fail if unreasonable.
// <---------------------------------------------Gampy--- Delay here
	// Send the "agree" response.
	MessageBuffer[0] = 0x6C;
	MessageBuffer[1] = 0xF0;
	MessageBuffer[2] = 0x10;
	MessageBuffer[3] = 0x75;

	MessageBuffer[4] = 0x01;
	MessageBuffer[5] = 0x54;
	MessageBuffer[6] = 0x6C;
	MessageBuffer[7] = 0xF0;

	WriteMessage(MessageBuffer, 8, Complete);

	// Give the tool time to proces that message (especially the AllPro)
	//LongSleepWithWatchdog();
// <---------------------------------------------Gampy--- Delay here
	// Send the payload
	MessageBuffer[0] = 0x6D;
	MessageBuffer[1] = 0xF0;
	MessageBuffer[2] = 0x10;
	MessageBuffer[3] = 0x36;
	MessageBuffer[4] = 0x01;
	MessageBuffer[5] = (char)(length >> 8);
	MessageBuffer[6] = (char)length;
	MessageBuffer[7] = (char)(start >> 16);
	MessageBuffer[8] = (char)(start >> 8);
	MessageBuffer[9] = (char)start;
	WriteMessage(MessageBuffer, 10, Start);

	unsigned short checksum = StartChecksum();
	checksum += AddReadPayloadChecksum((char*)start, length);

	WriteMessage((char*)start, length, Middle);

	WriteMessage((char*)&checksum, 2, End);
}
I am new here, I am starting to get a grip on things ... However to be 100% perfectly clear we are running around the same track, I included the code and have added two (2) comments to it.

Using ElmPause(...) with 5 changes nothing, 10 is a fail, in between 5 and 10 becomes hit and miss.
If the delay is prior to mode 75, the whole thing fails ... If the delay is between mode 75 and mode 36 only the mode 36 packet gets lost.

The delay of LongSleepWithWatchdog() causes the mode 36 (payload) packet to get lost ...

I am wondering, without a delay between the modes if the board sees both packets (75 and 36) as one and passes them through, any delay between them forces the board to see two packets and fail.
Something weird is happening here, no doubt ... the NO DATA between each mode 35 request says exactly that!
The board doesn't think the previous packet has completed or something like that.

-Enjoy
Intelligence is in the details!

It is easier not to learn bad habits, then it is to break them!

If I was here to win a popularity contest, their would be no point, so I wouldn't be here!
User avatar
NSFW
Posts: 679
Joined: Fri Feb 02, 2018 3:13 pm

Re: PcmHammer with ST1110 (sparkfun version)

Post by NSFW »

The first "Delay here" comment is the one I had in mind, but there does need to be a delay at the second "delay here" comment as well. That's what the "LongSleepWithWatchdog()" call was for in the code on github, however LongSleepWithWatchdog probably pauses a lot longer than necessary. If I remember right, that's about a half second. It worked for me, but I didn't experiment with shorter delays so I'm pretty sure it's not optimal. A shorter delay might work a lot better.

If you try different delays and get better results, that would be great!
Please don't PM me with technical questions - start a thread instead, and send me a link to it. That way I can answer in public, and help other people who have the same question. Thanks!
Post Reply