S12X Serial Monitor communication quirks

A place to discuss software and code that isn't automotive related. Free and open source preferred but not compulsory.
Post Reply
malcom2073
LQFP112 - Up with the play
Posts: 211
Joined: Tue May 01, 2012 4:17 pm
Location: Shrewsbury PA
Contact:

S12X Serial Monitor communication quirks

Post by malcom2073 »

Several people have noticed, that when using FreeEMS-Loader, you have to hit load twice to get it to actually load a file. This is most noticable when you first power up in SM mode, subsequent tries typically succeed.

I have managed to track down the reason for this, as the fact that the SM will send an indeterminant amount of null characters (0x0), before its response to the first command you send.

Typical command sequence according to the documentation

Code: Select all

PC -> 0xD //Check to see if SM is alive
SM -> 0xE0 0x08 0x3E
This is indeed true, for all except the first communication. That goes more like this

Code: Select all

PC -> 0xD
SM -> 0x0 0x0 0x0 (... some random number of 0's) 0xE0 0x08 0x3E
Where the SM waits for the PC to send its awake message before sending the 0's. Handling this by blindly reading after sending the first command, and then trying again seems to work every time.

Code: Select all

PC -> 0xD
SM -> 0x0 0x0 0x0 (... some random number of 0's) 0xE0 0x08 0x3E
PC -> (Reads chars until 50-100ms timeout)
PC -> 0xD
SM -> 0xE0 0x08 0x3E
User avatar
Fred
Moderator
Posts: 15431
Joined: Tue Jan 15, 2008 2:31 pm
Location: Home sweet home!
Contact:

Re: S12X Serial Monitor communication quirks

Post by Fred »

These tactics only *appeared* to help for me in UL. There are still initial connection issues even with this approach. As you mentioned to me in a PM recently, it's the driver that's at fault, though I'm yet to prove it (busy dealing with other stuff right now).
DIYEFI.org - where Open Source means Open Source, and Free means Freedom
FreeEMS.org - the open source engine management system
FreeEMS dev diary and its comments thread and my turbo truck!
n00bs, do NOT PM or email tech questions! Use the forum!
The ever growing list of FreeEMS success stories!
Post Reply