Originally Posted by
MopàrBCN
.
I know there is an offset to each value. So I suppose this is the address inside my binary file where to find my values. Then I have a base offset of hex8000. If I translate this to decimal I get at 32768 which is the file length if I get this right. Now, the table offsets translate all to numbers higher then this offset of 8000. So I guess I have to calculate dataoffset - cal offset => position of first value of table to search??? Here I am getting confused.
1. Even if this would be the starting point how would I know when the table ends?
2. I would expect to find at this address the first byte value of what I am looking for, wouldn't I???
So PLEASE HELP:
Let's suppose I look at Ladybug60.bin (which I am using for testing this prog) at the Table AdvanceWarmFullThrottle_FromMap.
Offset for this Table is a057 (hex) = > 41047 (which is greater then my file and I understand this since this is the position where it looks at the chip)
Now, the cal has an offset of 8000 = > 32768
So to search the first byte value of this table I should be searching using an offset from 41047 - 32768 ????
This is my first big question!
The second one is, once I now where to get the first byte, how do I know until where I have to look???????
Chem's calx doesn't seem to provide me with sufficient information to this. So here I need help.
Thanks!!
If I resolve this, the little tool is nearly ready!!
You're well on your way to having it figured out.
I wrote a perl script to calcualte an advance map from the various spark tables (and to force me to understand how things were laid out in the cal). So the code below is in perl, but it should be readable enough to give you an idea of what needs to be done. I can provide you the perl script if you want it as a reference. Some parts of it are *UGLY* but LMK if you want it.
I'll tackle the offset question first, since you need to know how to hit an offset to read the tables from the .bin. Basically, you can take the vaule in the .tbl or the xml and subtract 0xc00 from it. A simplified bit of code is below. Basically take the address from the .calx/.tbl, subtract 0xc00 from it, and seek to that location. That byte will be the length of your table.
Code:
$offset = hex($offset_from_tbl_file) - hex(C000);
seek( $CALFILE, $offset, SEEK_SET );
read( $CALFILE, $in, 1);
The next thing you need to know about is the table layout. The basic info is below. I took it from a comment in the program, you can ignore the part after unused in the slope comment (I'm calculating slope, not reading it).
Code:
#table entry layout is: aa bb cc dd dd bb cc dd dd.....
#where aa = number of elements in table
#bb is compare point for input (X)
#cc is output point at that input (Y)
#dd dd is slope, unused, delta(Y)/delta(X) is used to find slope and interpolate between points
So for each table, you lookup the offset, read the first byte. That first byte is the length of the table. You can then take the value of that byte you just read and read the table by reading (value of that byte * 4). This is for 8 bit tables. The 16 bit would be (value of first byte * 5) I believe. I never tried reading any of the 16 bit (fueling mostly) tables so don't quote me.