Page 1 of 1

Tuner Studio for custom application

Posted: Sat Oct 24, 2015 5:20 am
by E4ODnut
I realize that this is not directly connected with RusEFI, but Andrey has made considerable progress in working with TS and I'm hoping that he or others may be able to lend me a hand.

I'm working on my own simple controller using the Freescale MC9S12XEP100 (same as MS3) and coded in assembler (because I don't speak any of the higher languages). I'm self taught in these matters so progress is very slow. I have test hardware built and basic code to communicative with TS, similar to how MS does it, but I have run into a major road block.

I’ve studied the assembler source code for MS1 and MS1-Extra and tried to makes some sense out of the "C" code for MS2, MS2 Extra and Megashift, as well as and comparing the TS .ini files for them and RusEFI. I thought I had a pretty good idea of how TS works and how it communicates. Not so in practice so it turns out. I’m trying to figure out the multibyte commands that are necessary for any page related command as well as the single page value write, but this is where I have come to a halt.

I’m using the Megashift .ini as a base, same as RusEFI. I started rather ambitiously with several pages, but when I couldn’t get that to work, I went back to a single page lay out.
These are the command settings I’m using TS:
queryCommand = "H"
signature = "MShift v0.01" ; (Tuner Studio MUST have this)
endianness = big
nPages = 1
pageReadCommand = "C"
burnCommand = "B"
pageSize = 1024
pageValueWrite = "W%2o%v"
ochGetCommand = "O"

Through experimentation I was able to determine that when connected to TS the first command sent by TS is the queryCommand. When the correct “signature” is returned, it sends the pageReadCommand to get the configurable constants. When the correct amount of data is returned, it sends the ochGetCommand to get the real time variables. When these are returned communication is established and it resends the ochGetCommand at ~ 125 ms intervals. When any of the configurable constants are changed in TS it sends the pageValueWrite command which (should) write the new value to the correct offset location from the start of the page (into RAM). After the change has been sent, pressing the “Burn” button will send the burnCommand which jumps to a burner routine to burn the new page in RAM to Flash.

So far, the single byte commands work as they should and communication is good, but I can’t get any multi byte command to work. In it’s simplest form, the pageValueWrite command. It should send a “W”, then the offset Hi byte, then the offset Lo byte, then the data byte. All I receive is the “W”, no other bytes. It’s like TS doesn’t recognize anything beyond the first command byte.

Any suggestions?

Re: Tuner Studio for custom application

Posted: Sat Oct 24, 2015 10:33 am
by kb1gtt
I seem to recall FredEMS (FreeEMS.org) also uses a S12 processor. You might be able to get some TS help from them. The TS protocol is currently poorly documented. I understand we only have small bits and pieces that we have learned which allow this to work. There is an utility thing that allows rusEFI to have an INI file and firmware file generated. I understand we create the TS ini file with that and we match it in rusEFI by generating it all with this utility. I see some notes on the below web page, but that's probably not what you want.

http://rusefi.com/wiki/index.php?title=Manual:Software:User/en
http://rusefi.com/wiki/index.php?title=Manual:Software:TunerStudio_connectivity

You are probably best to ask EFI analytics these questions. It is likely we have not happened to learn the same thing you are trying to learn. As well we have very limited resources and supporting other project will likely be put below the priority of developing rusEFI. It's not that we don't want to help, it's that we have very limited resources. We would prefer to make this platform more usable which allows you access to the information you are looking for. Right now you are dealing with reverse engineering a non open system. It can be very difficult.

I should also encourage you to get a rusEFI platform :) It sounds like what you are trying to do, simply works with rusEFI stuff.

Re: Tuner Studio for custom application

Posted: Sat Oct 24, 2015 3:08 pm
by E4ODnut
Hi Jared,
Reverse engineering a non open system certainly is difficult, especially for an amateur, but I soldier on. As far as I know Fred does not, and has not used TS. LibreEMS uses the same processor that I do, but I'm pretty sure they use Megatunix and I know nothing about Linux. I have contacted EFI Analytics before with very limited results, but I'll try again.

RusEFI certainly has promise, but not speaking the language would make it impossible for me to make modifications to the firmware, which is important for me to be able to do.

Re: Tuner Studio for custom application

Posted: Sat Oct 24, 2015 3:18 pm
by AndreyB
I am racing this weekend so this response is from a mobile device.

Try multybyte read command syntax with offset just to see if it would work. Try adding chunkwrite command just to see if anything would change. Post your whole .ini file?

Most of my TS work is basedd on open5xxx protocol documentation, I am not the person who has figured the protocol originally.

Re: Tuner Studio for custom application

Posted: Sun Oct 25, 2015 5:37 pm
by E4ODnut
Hi Andrey,
Thanks for getting back to me, hope your racing went well.
I am trying the multibyte "pageValueWrite" Command because it is a simple command. No joy. I tried adding a "pageChunkWrite" at your suggestion. Still no joy. Just to re-cap what I'm doing:

When I first connect to TS, I get the "queryCommand". After I return the correct signature I get the "pageReadCommand". After I return the configurable constants, I get the "ochGetCommand". After I return the real time variables communication is established and the "ochGetCommand" is repeated at ~ 125ms intervals. Everything seems to run normally except for when I try to edit a value with the "pageValueWrite" command ("W%2o%v"). I expect to receive a "W" first, then the offset location Hi bite, then the offset location Lo byte, then the data byte. I receive the "W" correctly, but nothing after that. I've also tried the "burnCommand" with similar results. I will receive the "B" OK but if I add a page identifier, I get nothing but the "B".

I've written Brian Holzbach at EFI analytics to ask for help, hopefully I will get a reply. In the mean time I'm attaching my .ini for you to have a look at, perhaps I'm missing something obvious.

Re: Tuner Studio for custom application

Posted: Mon Oct 26, 2015 6:52 pm
by AndreyB
try multi-byte read. You know your simple read works so multi-byte should work as well?
Try

Code: Select all

   pageReadCommand     = "R\x00\x00%2o%2c"
just to me 100% same as rusEfi just to be sure.

Have you tried connecting to your serial port with something like Hyperterminal or putty just to send multiple bytes manually just to see you are handling serial properly?

Try connecting and send W123 and see if you in fact get the offset you would expect to get? Your .ini file looks good to me

Code: Select all

   signature      = "MShift 5.001" ; Changed to this, it works but don't know if it will be better
is the most risky thing I see.

Re: Tuner Studio for custom application

Posted: Tue Oct 27, 2015 4:54 am
by E4ODnut
Hi Andrey,
Thanks for your response. Since I wrote last I've done some more digging and found out that TS has a communications log file. I did some experimenting with that and, according to the file, TS is indeed sending the appropriate multibyte command. That tells me that the problem is in the way I'm processing that command. This will take some head scratching and will probably be a bit hard on the wine cellar when I can't think any more. I'll try your suggestions.

Thanks.

Re: Tuner Studio for custom application

Posted: Wed Nov 11, 2015 8:30 pm
by E4ODnut
Andrey,
I was able to talk with my assembly programming guru. He found my problem right away, a stupid newbie mistake using the wrong addressing mode. I'm plodding along again, thanks for your input.