-
Notifications
You must be signed in to change notification settings - Fork 1
/
MSA15FileParser.cs
1340 lines (1261 loc) · 72.3 KB
/
MSA15FileParser.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace VAGSuite
{
public class MSA15FileParser : IEDCFileParser
{
public override string ExtractInfo(byte[] allBytes)
{
// assume info will be @ 0x53452 12 bytes
string retval = string.Empty;
try
{
int partnumberAddress = Tools.Instance.findSequence(allBytes, 0, new byte[5] { 0x45, 0x44, 0x43, 0x20, 0x20 }, new byte[5] { 1, 1, 1, 1, 1 });
if (partnumberAddress > 0)
{
retval = System.Text.ASCIIEncoding.ASCII.GetString(allBytes, partnumberAddress - 8, 12).Trim();
}
}
catch (Exception)
{
}
return retval;
}
public override string ExtractPartnumber(byte[] allBytes)
{
// assume info will be @ 0x53446 12 bytes
string retval = string.Empty;
try
{
int partnumberAddress = Tools.Instance.findSequence(allBytes, 0, new byte[5] { 0x45, 0x44, 0x43, 0x20, 0x20 }, new byte[5] { 1, 1, 1, 1, 1 });
if (partnumberAddress > 0)
{
retval = System.Text.ASCIIEncoding.ASCII.GetString(allBytes, partnumberAddress - 20, 12).Trim();
}
}
catch (Exception)
{
}
return retval;
}
public override string ExtractSoftwareNumber(byte[] allBytes)
{
string retval = string.Empty;
try
{
int partnumberAddress = Tools.Instance.findSequence(allBytes, 0, new byte[5] { 0x45, 0x44, 0x43, 0x20, 0x20 }, new byte[5] { 1, 1, 1, 1, 1 });
if (partnumberAddress > 0)
{
retval = System.Text.ASCIIEncoding.ASCII.GetString(allBytes, partnumberAddress + 5, 8).Trim();
retval = retval.Replace(" ", "");
}
}
catch (Exception)
{
}
return retval;
}
public override string ExtractBoschPartnumber(byte[] allBytes)
{
return Tools.Instance.ExtractBoschPartnumber(allBytes);
/*string retval = string.Empty;
try
{
int partnumberAddress = Tools.Instance.findSequence(allBytes, 0, new byte[5] { 0x45, 0x44, 0x43, 0x20, 0x20 }, new byte[5] { 1, 1, 1, 1, 1 });
if (partnumberAddress > 0)
{
retval = System.Text.ASCIIEncoding.ASCII.GetString(allBytes, partnumberAddress + 23, 10).Trim();
}
}
catch (Exception)
{
}
return retval;*/
}
private string DetermineNumberByFlashBank(long address, List<CodeBlock> currBlocks)
{
foreach (CodeBlock cb in currBlocks)
{
if (cb.StartAddress <= address && cb.EndAddress >= address)
{
/*if (cb.CodeID == 1) return "codeblock 1";// - MAN";
if (cb.CodeID == 2) return "codeblock 2";// - AUT (hydr)";
if (cb.CodeID == 3) return "codeblock 3";// - AUT (elek)";
return cb.CodeID.ToString();*/
if (cb.BlockGearboxType == GearboxType.Automatic)
{
return "codeblock " + cb.CodeID.ToString() + " AUT";
}
return "codeblock " + cb.CodeID.ToString();
}
}
long bankNumber = address / 0x10000;
return "flashbank " + bankNumber.ToString();
}
private int DetermineCodeBlockByByAddress(long address, List<CodeBlock> currBlocks)
{
foreach (CodeBlock cb in currBlocks)
{
if (cb.StartAddress <= address && cb.EndAddress >= address)
{
return cb.CodeID;
}
}
return 0;
}
public override SymbolCollection parseFile(string filename, out List<CodeBlock> newCodeBlocks, out List<AxisHelper> newAxisHelpers)
{
newCodeBlocks = new List<CodeBlock>();
SymbolCollection newSymbols = new SymbolCollection();
newAxisHelpers = new List<AxisHelper>();
byte[] allBytes = File.ReadAllBytes(filename);
string boschnumber = ExtractBoschPartnumber(allBytes);
string softwareNumber = ExtractSoftwareNumber(allBytes);
partNumberConverter pnc = new partNumberConverter();
VerifyCodeBlocks(allBytes, newSymbols, newCodeBlocks);
for (int t = 0; t < allBytes.Length - 1; t++)
{
CheckMap(t, allBytes, newSymbols, newCodeBlocks);
}
newSymbols.SortColumn = "Flash_start_address";
newSymbols.SortingOrder = GenericComparer.SortOrder.Ascending;
newSymbols.Sort();
NameKnownMaps(allBytes, newSymbols, newCodeBlocks);
BuildAxisIDList(newSymbols, newAxisHelpers);
MatchAxis(newSymbols, newAxisHelpers);
FindSVBL(allBytes, filename, newSymbols, newCodeBlocks);
FindMAPMAFSwitch(allBytes, filename, newSymbols, newCodeBlocks);
SymbolTranslator strans = new SymbolTranslator();
foreach (SymbolHelper sh in newSymbols)
{
sh.Description = strans.TranslateSymbolToHelpText(sh.Varname);
}
// check for must have maps... if there are maps missing, report it
return newSymbols;
}
private void MatchAxis(SymbolCollection newSymbols, List<AxisHelper> newAxisHelpers)
{
foreach (SymbolHelper sh in newSymbols)
{
if (!sh.YaxisAssigned)
{
foreach (AxisHelper ah in newAxisHelpers)
{
if (sh.X_axis_ID == ah.AxisID)
{
sh.Y_axis_descr = ah.Description;
sh.YaxisUnits = ah.Units;
sh.Y_axis_offset = ah.Offset;
sh.Y_axis_correction = ah.Correction;
break;
}
}
}
if (!sh.XaxisAssigned)
{
foreach (AxisHelper ah in newAxisHelpers)
{
if (sh.Y_axis_ID == ah.AxisID)
{
sh.X_axis_descr = ah.Description;
sh.XaxisUnits = ah.Units;
sh.X_axis_offset = ah.Offset;
sh.X_axis_correction = ah.Correction;
break;
}
}
}
}
}
private void BuildAxisIDList(SymbolCollection newSymbols, List<AxisHelper> newAxisHelpers)
{
foreach (SymbolHelper sh in newSymbols)
{
if (!sh.Varname.StartsWith("2D") && !sh.Varname.StartsWith("3D"))
{
AddToAxisCollection(newAxisHelpers, sh.Y_axis_ID, sh.X_axis_descr, sh.XaxisUnits, sh.X_axis_correction, sh.X_axis_offset);
AddToAxisCollection(newAxisHelpers, sh.X_axis_ID, sh.Y_axis_descr, sh.YaxisUnits, sh.Y_axis_correction, sh.Y_axis_offset);
}
}
}
private void AddToAxisCollection(List<AxisHelper> newAxisHelpers, int ID, string descr, string units, double correction, double offset)
{
if (ID == 0) return;
foreach (AxisHelper ah in newAxisHelpers)
{
if (ah.AxisID == ID) return;
}
AxisHelper ahnew = new AxisHelper();
ahnew.AxisID = ID;
ahnew.Description = descr;
ahnew.Units = units;
ahnew.Correction = correction;
ahnew.Offset = offset;
newAxisHelpers.Add(ahnew);
}
private void FindMAPMAFSwitch(byte[] allBytes, string filename, SymbolCollection newSymbols, List<CodeBlock> newCodeBlocks)
{
foreach (CodeBlock cb in newCodeBlocks)
{
if (cb.CodeID > 0)
{
Console.WriteLine("codeblock " + cb.CodeID.ToString() + " address " + cb.StartAddress.ToString("X8") + " adrid " + cb.AddressID.ToString("X8"));
int MAPMAFSwitch = cb.AddressID - 8;
// read data
if ((allBytes[MAPMAFSwitch] == 0x01 && allBytes[MAPMAFSwitch + 1] == 0x01) || (allBytes[MAPMAFSwitch ] == 0x00 && allBytes[MAPMAFSwitch + 1] == 0x00))
{
// verify validity
SymbolHelper mapmafsh = new SymbolHelper();
//mapmafsh.BitMask = 0x0101;
mapmafsh.Category = "Detected maps";
mapmafsh.Subcategory = "Switches";
mapmafsh.Flash_start_address = MAPMAFSwitch;
mapmafsh.Varname = "MAP/MAF switch (0 = MAF, 257/0x0101 = MAP)" + DetermineNumberByFlashBank(MAPMAFSwitch, newCodeBlocks);
mapmafsh.Length = 2;
mapmafsh.CodeBlock = DetermineCodeBlockByByAddress(mapmafsh.Flash_start_address, newCodeBlocks);
newSymbols.Add(mapmafsh);
}
}
}
}
public override void FindSVBL(byte[] allBytes, string filename, SymbolCollection newSymbols, List<CodeBlock> newCodeBlocks)
{
if (!FindSVBLSequenceOne(allBytes, filename, newSymbols, newCodeBlocks))
{
FindSVBLSequenceTwo(allBytes, filename, newSymbols, newCodeBlocks);
}
}
private bool FindSVBLSequenceTwo(byte[] allBytes, string filename, SymbolCollection newSymbols, List<CodeBlock> newCodeBlocks)
{
bool found = true;
int offset = 0;
bool svblfound = false;
while (found)
{
int SVBLAddress = Tools.Instance.findSequence(allBytes, offset, new byte[10] { 0xDF, 0x7A, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDF, 0x7A }, new byte[10] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 });
if (SVBLAddress > 0)
{
//Console.WriteLine("Alternative SVBL " + SVBLAddress.ToString("X8"));
svblfound = true;
SymbolHelper shsvbl = new SymbolHelper();
shsvbl.Category = "Detected maps";
shsvbl.Subcategory = "Limiters";
shsvbl.Flash_start_address = SVBLAddress - 2;
// if value = 0xC3 0x00 -> two more back
int[] testValue = Tools.Instance.readdatafromfileasint(filename, (int)shsvbl.Flash_start_address, 1, EDCFileType.MSA15);
if (testValue[0] == 0xC300) shsvbl.Flash_start_address -= 2;
shsvbl.Varname = "SVBL Boost limiter [" + DetermineNumberByFlashBank(shsvbl.Flash_start_address, newCodeBlocks) + "]";
shsvbl.Length = 2;
shsvbl.CodeBlock = DetermineCodeBlockByByAddress(shsvbl.Flash_start_address, newCodeBlocks);
newSymbols.Add(shsvbl);
offset = SVBLAddress + 1;
}
else found = false;
}
return svblfound;
}
private bool FindSVBLSequenceOne(byte[] allBytes, string filename, SymbolCollection newSymbols, List<CodeBlock> newCodeBlocks)
{
bool found = true;
int offset = 0;
bool svblfound = false;
while (found)
{
int SVBLAddress = Tools.Instance.findSequence(allBytes, offset, new byte[10] { 0x2B, 0x7D, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2B, 0x7D }, new byte[10] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 });
if (SVBLAddress > 0)
{
//Console.WriteLine("Alternative SVBL " + SVBLAddress.ToString("X8"));
svblfound = true;
SymbolHelper shsvbl = new SymbolHelper();
shsvbl.Category = "Detected maps";
shsvbl.Subcategory = "Limiters";
shsvbl.Flash_start_address = SVBLAddress - 2;
// if value = 0xC3 0x00 -> two more back
int[] testValue = Tools.Instance.readdatafromfileasint(filename, (int)shsvbl.Flash_start_address, 1, EDCFileType.MSA15);
if (testValue[0] == 0xC300) shsvbl.Flash_start_address -= 2;
shsvbl.Varname = "SVBL Boost limiter [" + DetermineNumberByFlashBank(shsvbl.Flash_start_address, newCodeBlocks) + "]";
shsvbl.Length = 2;
shsvbl.CodeBlock = DetermineCodeBlockByByAddress(shsvbl.Flash_start_address, newCodeBlocks);
newSymbols.Add(shsvbl);
offset = SVBLAddress + 1;
}
else found = false;
}
return svblfound;
}
public override void NameKnownMaps(byte[] allBytes, SymbolCollection newSymbols, List<CodeBlock> newCodeBlocks)
{
//N146 Pump Voltage map:
SymbolAxesTranslator st = new SymbolAxesTranslator();
foreach (SymbolHelper sh in newSymbols)
{
//sh.X_axis_descr = st.TranslateAxisID(sh.X_axis_ID);
//sh.Y_axis_descr = st.TranslateAxisID(sh.Y_axis_ID);
if (sh.Length == 544)
{
if (sh.X_axis_length == 16 && sh.Y_axis_length == 17)
{
if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xC2)
{
sh.Category = "Detected maps";
sh.Subcategory = "Fuel";
sh.Varname = "N146 Pump voltage map [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
//sh.Correction = 0.001221001; // ?1.221001
//Todo: N146 correction factor for MSA15
sh.X_axis_correction = 0.01;
sh.Z_axis_descr = "Pump voltage (V)";
sh.X_axis_descr = "IQ (mg/stroke)";
sh.Y_axis_descr = "Engine speed (rpm)";
sh.YaxisUnits = "rpm";
sh.XaxisUnits = "mg/st";
}
}
}
if (sh.Length == 448)
{
if (sh.X_axis_length == 16 && sh.Y_axis_length == 14)
{
if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xC2)
{
sh.Category = "Detected maps";
sh.Subcategory = "Fuel";
sh.Varname = "N146 Pump voltage map [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
//sh.Correction = 0.001221001; // ?1.221001
//Todo: N146 correction factor for MSA15
sh.X_axis_correction = 0.01;
sh.Z_axis_descr = "Pump voltage (V)";
sh.X_axis_descr = "IQ (mg/stroke)";
sh.Y_axis_descr = "Engine speed (rpm)";
sh.YaxisUnits = "rpm";
sh.XaxisUnits = "mg/st";
}
}
}
//12x13 E0 DD = EGR
if (sh.Length == 416)
{
if (sh.X_axis_length == 16 && sh.Y_axis_length == 13)
{
if (sh.X_axis_ID == 0xE08A && sh.Y_axis_ID == 0xDDD8)
{
sh.Category = "Detected maps";
sh.Subcategory = "Turbo";
sh.Varname = "N75 duty cycle [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
sh.Z_axis_descr = "Duty cycle %";
sh.Correction = -0.01;
sh.Offset = 100;
sh.X_axis_correction = 0.01;
sh.X_axis_descr = "IQ (mg/stroke)";
sh.Y_axis_descr = "Engine speed (rpm)";
sh.YaxisUnits = "rpm";
sh.XaxisUnits = "mg/st";
}
else if (sh.X_axis_ID == 0xE08A && sh.Y_axis_ID == 0xDD30)
{
sh.Category = "Detected maps";
sh.Subcategory = "Misc";
int egrCount = GetMapNameCountForCodeBlock("EGR", sh.CodeBlock, newSymbols, false);
sh.Varname = "EGR " + egrCount.ToString("D2") + " [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
sh.Correction = 0.1;
sh.X_axis_correction = 0.01;
sh.Z_axis_descr = "Mass Air Flow (mg/stroke)";
sh.X_axis_descr = "IQ (mg/stroke)";
sh.Y_axis_descr = "Engine speed (rpm)";
sh.YaxisUnits = "rpm";
sh.XaxisUnits = "mg/st";
}
else if (sh.X_axis_ID == 0xE08A && sh.Y_axis_ID == 0xDEDC)
{
sh.Category = "Detected maps";
sh.Subcategory = "Fuel";
int injDurCount = GetMapNameCountForCodeBlock("Start of injection (N108 SOI)", sh.CodeBlock, newSymbols, false);
sh.Varname = "Start of injection (N108 SOI) " + injDurCount.ToString() + " [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";// " + sh.Flash_start_address.ToString("X8") + " " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");
sh.Correction = 0.023437;
sh.Y_axis_descr = "Engine speed (rpm)";
sh.YaxisUnits = "rpm";
sh.X_axis_descr = "IQ (mg/stroke)";
sh.X_axis_correction = 0.01; // TODODONE : Check for x or y
sh.XaxisUnits = "mg/st";
}
else if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xDE)
{
sh.Category = "Detected maps";
sh.Subcategory = "Misc";
int egrCount = GetMapNameCountForCodeBlock("EGR", sh.CodeBlock, newSymbols, false);
sh.Varname = "EGR " + egrCount.ToString("D2") + " [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
sh.Correction = 0.1;
sh.X_axis_correction = 0.01;
sh.Z_axis_descr = "Mass Air Flow (mg/stroke)";
sh.X_axis_descr = "IQ (mg/stroke)";
sh.Y_axis_descr = "Engine speed (rpm)";
sh.YaxisUnits = "rpm";
sh.XaxisUnits = "mg/st";
}
else if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xDD)
{
sh.Category = "Detected maps";
sh.Subcategory = "Fuel";
int injDurCount = GetMapNameCountForCodeBlock("Start of injection (N108 SOI)", sh.CodeBlock, newSymbols, false);
sh.Varname = "Start of injection (N108 SOI) " + injDurCount.ToString() + " [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";// " + sh.Flash_start_address.ToString("X8") + " " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");
sh.Correction = 0.023437;
sh.Y_axis_descr = "Engine speed (rpm)";
sh.YaxisUnits = "rpm";
sh.X_axis_correction = 0.01; // TODODONE : Check for x or y
sh.X_axis_descr = "IQ (mg/stroke)";
sh.XaxisUnits = "mg/st";
sh.Z_axis_descr = "Start position (degrees BTDC)";
}
else if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xDC)
{
// IQ by MAP
sh.Category = "Detected maps";
sh.Subcategory = "Limiters";
sh.Varname = "IQ by MAP limiter [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";// " + sh.Flash_start_address.ToString("X8") +" " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");
sh.Correction = 0.01;
sh.X_axis_descr = "Boost pressure";
sh.Y_axis_descr = "Engine speed (rpm)";
sh.Z_axis_descr = "Maximum IQ (mg)";
sh.YaxisUnits = "rpm";
sh.XaxisUnits = "mbar";
}
}
}
else if (sh.Length == 384)
{
if (sh.X_axis_length == 12 && sh.Y_axis_length == 16)
{
if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xC2)
{
sh.Category = "Detected maps";
sh.Subcategory = "Misc";
sh.Varname = "Inverse driver wish [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
sh.Correction = 0.01;
sh.X_axis_correction = 0.01;
sh.Z_axis_descr = "Throttle position";
sh.X_axis_descr = "IQ (mg/stroke)";
sh.Y_axis_descr = "Engine speed (rpm)";
//sh.Z_axis_descr = "Requested IQ (mg)";
sh.YaxisUnits = "rpm";
sh.XaxisUnits = "mg/st";
}
}
else if (sh.X_axis_length == 16 && sh.Y_axis_length == 12)
{
int smCount = GetMapNameCountForCodeBlock("Smoke limiter", sh.CodeBlock, newSymbols, false);
sh.Category = "Detected maps";
sh.Subcategory = "Limiters";
sh.Varname = "Smoke limiter [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
sh.Z_axis_descr = "Maximum IQ (mg)";
sh.Y_axis_descr = "Engine speed (rpm)";
sh.X_axis_descr = "Airflow mg/stroke";
sh.Correction = 0.01;
sh.X_axis_correction = 0.1;
sh.YaxisUnits = "rpm";
sh.XaxisUnits = "mg/st";
}
}
else if (sh.Length == 320)
{
if (sh.X_axis_length == 16 && sh.Y_axis_length == 10)
{
if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xDC)
{
int smCount = GetMapNameCountForCodeBlock("Smoke limiter", sh.CodeBlock, newSymbols, false);
sh.Category = "Detected maps";
sh.Subcategory = "Limiters";
sh.Varname = "Smoke limiter [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
sh.Z_axis_descr = "Maximum IQ (mg)";
sh.Y_axis_descr = "Engine speed (rpm)";
sh.X_axis_descr = "Airflow mg/stroke";
sh.Correction = 0.01;
sh.X_axis_correction = 0.1;
sh.YaxisUnits = "rpm";
sh.XaxisUnits = "mg/st";
}
else if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xC3)
{
sh.Category = "Detected maps";
sh.Subcategory = "Turbo";
int boostTargetCount = GetMapNameCountForCodeBlock("Boost target map", sh.CodeBlock, newSymbols, false);
sh.Varname = "Boost target map (" + boostTargetCount.ToString() + ") [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";// " + sh.Flash_start_address.ToString("X8") + " " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");
sh.X_axis_correction = 0.01;
sh.X_axis_descr = "IQ (mg/stroke)";
sh.Y_axis_descr = "Engine speed (rpm)";
sh.Z_axis_descr = "Boost target (mbar)";
sh.YaxisUnits = "rpm";
sh.XaxisUnits = "mg/st";
}
else if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xC2)
{
sh.Category = "Detected maps";
sh.Subcategory = "Turbo";
int boostTargetCount = GetMapNameCountForCodeBlock("Boost target map", sh.CodeBlock, newSymbols, false);
sh.Varname = "Boost target map (" + boostTargetCount.ToString() + ") [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";// " + sh.Flash_start_address.ToString("X8") + " " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");
sh.X_axis_correction = 0.01;
sh.X_axis_descr = "IQ (mg/stroke)";
sh.Y_axis_descr = "Engine speed (rpm)";
sh.Z_axis_descr = "Boost target (mbar)";
sh.YaxisUnits = "rpm";
sh.XaxisUnits = "mg/st";
}
else if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xDD)
{
sh.Category = "Detected maps";
sh.Subcategory = "Fuel";
sh.Varname = "IQ to airmass [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
sh.Z_axis_descr = "Required airmass";
sh.Correction = 0.1;
sh.X_axis_correction = 0.01;
sh.X_axis_descr = "IQ (mg/stroke)";
sh.Y_axis_descr = "Engine speed (rpm)";
sh.YaxisUnits = "rpm";
sh.XaxisUnits = "mg/st";
}
else if (sh.X_axis_ID == 0xE08A && sh.Y_axis_ID == 0xDEDC)
{
sh.Category = "Detected maps";
sh.Subcategory = "Fuel";
sh.Varname = "IQ to airmass [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
sh.Z_axis_descr = "Required airmass";
sh.Correction = 0.1;
sh.X_axis_correction = 0.01;
sh.X_axis_descr = "IQ (mg/stroke)";
sh.Y_axis_descr = "Engine speed (rpm)";
sh.YaxisUnits = "rpm";
sh.XaxisUnits = "mg/st";
}
else if (sh.X_axis_ID == 0xE08A && sh.Y_axis_ID == 0xC2D0)
{
sh.Category = "Detected maps";
sh.Subcategory = "Turbo";
int boostTargetCount = GetMapNameCountForCodeBlock("Boost target map", sh.CodeBlock, newSymbols, false);
sh.Varname = "Boost target map (" + boostTargetCount.ToString() + ") [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";// " + sh.Flash_start_address.ToString("X8") + " " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");
sh.X_axis_correction = 0.01;
sh.X_axis_descr = "IQ (mg/stroke)";
sh.Y_axis_descr = "Engine speed (rpm)";
sh.Z_axis_descr = "Boost target (mbar)";
sh.YaxisUnits = "rpm";
sh.XaxisUnits = "mg/st";
}
}
}
else if (sh.Length == 256)
{
if (sh.X_axis_length == 16 && sh.Y_axis_length == 8)
{
if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xC2)
{
sh.Category = "Detected maps";
sh.Subcategory = "Misc";
sh.Varname = "Driver wish [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
sh.Correction = 0.01;
sh.X_axis_correction = 0.01;
sh.X_axis_descr = "Throttle position";
sh.Z_axis_descr = "Requested IQ (mg)";
sh.Y_axis_descr = "Engine speed (rpm)";
sh.YaxisUnits = "rpm";
sh.XaxisUnits = "TPS %";
}
if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xC1)
{
sh.Category = "Detected maps";
sh.Subcategory = "Misc";
sh.Varname = "Driver wish [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
sh.Correction = 0.01;
sh.X_axis_correction = 0.01;
sh.X_axis_descr = "Throttle position";
sh.Z_axis_descr = "Requested IQ (mg)";
sh.Y_axis_descr = "Engine speed (rpm)";
sh.YaxisUnits = "rpm";
sh.XaxisUnits = "TPS %";
}
if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xC0)
{
sh.Category = "Detected maps";
sh.Subcategory = "Misc";
sh.Varname = "Driver wish [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
sh.Correction = 0.01;
sh.X_axis_correction = 0.01;
sh.X_axis_descr = "Throttle position";
sh.Z_axis_descr = "Requested IQ (mg)";
sh.Y_axis_descr = "Engine speed (rpm)";
sh.YaxisUnits = "rpm";
sh.XaxisUnits = "TPS %";
}
}
}
else if (sh.Length == 200)
{
if (sh.X_axis_ID / 256 == 0xC2 && sh.Y_axis_ID / 256 == 0xE0)
{
sh.Category = "Detected maps";
sh.Subcategory = "Limiters";
sh.Varname = "Boost limit map [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";// " + sh.Flash_start_address.ToString("X8") + " " + sh.X_axis_ID.ToString("X4") + " " + sh.Y_axis_ID.ToString("X4");
// sh.Correction = 0.01;
//sh.X_axis_correction = 0.01;
sh.Y_axis_descr = "Atmospheric pressure (mbar)";
sh.Z_axis_descr = "Maximum boost pressure (mbar)";
sh.X_axis_descr = "Engine speed (rpm)";
sh.XaxisUnits = "rpm";
sh.YaxisUnits = "mbar";
}
}
else if (sh.Length == 192)
{
if (sh.X_axis_length == 12 && sh.Y_axis_length == 8)
{
if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xC2)
{
sh.Category = "Detected maps";
sh.Subcategory = "Misc";
sh.Varname = "Driver wish [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
sh.Correction = 0.01;
sh.X_axis_correction = 0.01;
sh.X_axis_descr = "Throttle position";
sh.Z_axis_descr = "Requested IQ (mg)";
sh.Y_axis_descr = "Engine speed (rpm)";
sh.YaxisUnits = "rpm";
sh.XaxisUnits = "TPS %";
}
if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xC1)
{
sh.Category = "Detected maps";
sh.Subcategory = "Misc";
sh.Varname = "Driver wish [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
sh.Correction = 0.01;
sh.X_axis_correction = 0.01;
sh.X_axis_descr = "Throttle position";
sh.Z_axis_descr = "Requested IQ (mg)";
sh.Y_axis_descr = "Engine speed (rpm)";
sh.YaxisUnits = "rpm";
sh.XaxisUnits = "TPS %";
}
}
}
else if (sh.Length == 182) // 7*13
{
if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xC1)
{
sh.Category = "Detected maps";
sh.Subcategory = "Misc";
sh.Varname = "Driver wish [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
sh.Correction = 0.01;
sh.X_axis_correction = 0.01;
sh.X_axis_descr = "Throttle position";
sh.Z_axis_descr = "Requested IQ (mg)";
sh.Y_axis_descr = "Engine speed (rpm)";
sh.YaxisUnits = "rpm";
sh.XaxisUnits = "TPS %";
}
if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xC2)
{
if (IsValidTemperatureAxis(allBytes, sh, MapViewerEx.AxisIdent.Y_Axis))
{
sh.Category = "Detected maps";
sh.Subcategory = "Limiters";
//sh.Varname = "Boost limiter (temperature) [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
sh.Varname = "SOI limiter (temperature) [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
sh.Correction = 0.023437;
sh.Y_axis_descr = "Engine speed (rpm)";
sh.X_axis_descr = "Temperature"; //IAT, ECT or Fuel temp?
sh.X_axis_correction = 0.1;
sh.X_axis_offset = -273.1;
sh.Z_axis_descr = "SOI limit (degrees)";
sh.YaxisUnits = "rpm";
sh.XaxisUnits = "°C";
}
}
}
else if (sh.Length == 144)
{
if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID / 256 == 0xC0)
{
sh.Category = "Detected maps";
sh.Subcategory = "Fuel";
int sIQCount = GetMapNameCountForCodeBlock("Start IQ ", sh.CodeBlock, newSymbols, false);
sh.Varname = "Start IQ (" + sIQCount.ToString() + ") [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
sh.Correction = 0.01;
sh.X_axis_descr = "CT (celcius)";
sh.X_axis_correction = 0.1;
sh.X_axis_offset = -273.1;
sh.Z_axis_descr = "Requested IQ (mg)";
sh.Y_axis_descr = "Engine speed (rpm)";
sh.YaxisUnits = "rpm";
sh.XaxisUnits = "degC";
}
}
else if (sh.Length == 128)
{
if (sh.X_axis_ID / 256 == 0xE0 && sh.Y_axis_ID == 0xC002)
{
// check for valid axis data on temp data
if (IsValidTemperatureAxis(allBytes, sh, MapViewerEx.AxisIdent.Y_Axis))
{
sh.Category = "Detected maps";
sh.Subcategory = "Limiters";
int maflimTempCount = GetMapNameCountForCodeBlock("MAF correction by temperature", sh.CodeBlock, newSymbols, false);
maflimTempCount--;
sh.Varname = "MAF correction by temperature " + maflimTempCount.ToString("D2") + " [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
sh.Z_axis_descr = "Limit";
sh.Y_axis_descr = "Engine speed (rpm)";
sh.X_axis_descr = "Intake air temperature"; //IAT, ECT or Fuel temp?
sh.X_axis_correction = 0.1;
sh.X_axis_offset = -273.1;
sh.Correction = 0.01;
sh.YaxisUnits = "rpm";
sh.XaxisUnits = "°C";
}
}
}
else if (sh.Length == 64)
{
if (sh.X_axis_length == 32 && sh.Y_axis_length == 1)
{
sh.Category = "Detected maps";
sh.Subcategory = "Misc";
sh.Varname = "MAF linearization [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
}
}
else if (sh.Length == 114)
{
if (sh.X_axis_length == 3 && sh.Y_axis_length == 19)
{
sh.Category = "Detected maps";
sh.Subcategory = "Limiters";
sh.Varname = "Torque limiter [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
sh.Z_axis_descr = "Maximum IQ (mg)";
sh.Y_axis_descr = "Atm. pressure (mbar)";
sh.X_axis_descr = "Engine speed (rpm)";
sh.Correction = 0.01;
sh.XaxisUnits = "rpm";
sh.YaxisUnits = "mbar";
}
}
else if (sh.Length == 38)
{
if (sh.X_axis_length == 19 && sh.Y_axis_length == 1)
{
if (sh.X_axis_ID / 256 == 0xE0)
{
sh.Category = "Detected maps";
sh.Subcategory = "Limiters";
int lmCount = GetMapNameCountForCodeBlock("Torque limiter", sh.CodeBlock, newSymbols, false);
sh.Varname = "Torque limiter (" + lmCount.ToString() + ") [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
sh.Z_axis_descr = "Maximum IQ (mg)";
//sh.Y_axis_descr = "Atm. pressure (mbar)";
sh.Y_axis_descr = "Engine speed (rpm)";
sh.Correction = 0.01;
sh.YaxisUnits = "rpm";
}
}
}
else if (sh.Length == 4)
{
if (sh.X_axis_length == 2 && sh.Y_axis_length == 1)
{
//if (sh.X_axis_ID >= 0xEBA0 && sh.X_axis_ID <= 0xEBAF)
if (sh.X_axis_ID == 0xDF4A)
{
sh.Category = "Detected maps";
sh.Subcategory = "Misc";
sh.Varname = "MAP linearization [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
}
}
if (sh.X_axis_length == 2 && sh.Y_axis_length == 1)
{
if (sh.X_axis_ID == 0xC002) // idle RPM
{
sh.Category = "Detected maps";
sh.Subcategory = "Misc";
int lmCount = GetMapNameCountForCodeBlock("Idle RPM", sh.CodeBlock, newSymbols, false);
sh.Varname = "Idle RPM (" + lmCount.ToString() + ") [" + DetermineNumberByFlashBank(sh.Flash_start_address, newCodeBlocks) + "]";
sh.Y_axis_descr = "Coolant temperature";
sh.Y_axis_correction = 0.1;
sh.Y_axis_offset = -273.1;
sh.Z_axis_descr = "Target engine speed";
sh.YaxisUnits = "°C";
}
}
}
}
}
private bool IsValidTemperatureAxis(byte[] allBytes, SymbolHelper sh, MapViewerEx.AxisIdent axisIdent)
{
bool retval = true;
if (axisIdent == MapViewerEx.AxisIdent.X_Axis)
{
//read x axis values
int offset = sh.X_axis_address;
for (int i = 0; i < sh.X_axis_length; i++)
{
int val = Convert.ToInt32(allBytes[offset]) + Convert.ToInt32(allBytes[offset + 1]) * 256;
double tempVal = (Convert.ToDouble(val) * 0.1) - 273.1;
if (tempVal < -80 || tempVal > 200) retval = false;
offset += 2;
}
}
else if (axisIdent == MapViewerEx.AxisIdent.Y_Axis)
{
//read x axis values
int offset = sh.Y_axis_address;
for (int i = 0; i < sh.Y_axis_length; i++)
{
int val = Convert.ToInt32(allBytes[offset]) + Convert.ToInt32(allBytes[offset + 1]) * 256;
double tempVal = (Convert.ToDouble(val) * 0.1) - 273.1;
if (tempVal < -80 || tempVal > 200) retval = false;
offset += 2;
}
}
return retval;
}
private bool MapContainsNegativeValues(byte[] allBytes, SymbolHelper sh)
{
for (int i = 0; i < sh.Length; i += 2)
{
int currval = Convert.ToInt32(allBytes[sh.Flash_start_address + i + 1]) * 256 + Convert.ToInt32(allBytes[sh.Flash_start_address + i]);
if (currval > 0xF000) return true;
}
return false;
}
private int GetMapNameCountForCodeBlock(string varName, int codeBlock, SymbolCollection newSymbols, bool debug)
{
int count = 0;
if (debug) Console.WriteLine("Check " + varName + " " + codeBlock);
foreach (SymbolHelper sh in newSymbols)
{
if (debug)
{
if (!sh.Varname.StartsWith("2D") && !sh.Varname.StartsWith("3D"))
{
Console.WriteLine(sh.Varname + " " + sh.CodeBlock);
}
}
if (sh.Varname.StartsWith(varName) && sh.CodeBlock == codeBlock)
{
if (debug) Console.WriteLine("Found " + sh.Varname + " " + sh.CodeBlock);
count++;
}
}
count++;
return count;
}
private int CheckCodeBlock(int offset, byte[] allBytes, SymbolCollection newSymbols, List<CodeBlock> newCodeBlocks)
{
int codeBlockID = 0;
try
{
int endOfTable = Convert.ToInt32(allBytes[offset ]) + Convert.ToInt32(allBytes[offset + 1]) * 256 + offset;
int codeBlockAddress = Convert.ToInt32(allBytes[offset + 2]) + Convert.ToInt32(allBytes[offset + 3]) * 256 + offset;
if (endOfTable == offset + 0xC3C3) codeBlockAddress = 0x1530 + offset;
codeBlockAddress -= 0xc00;
codeBlockID = Convert.ToInt32(allBytes[codeBlockAddress]) + Convert.ToInt32(allBytes[codeBlockAddress + 1]) * 256;
foreach (CodeBlock cb in newCodeBlocks)
{
if (cb.StartAddress <= codeBlockAddress && cb.EndAddress >= codeBlockAddress)
{
cb.CodeID = codeBlockID;
cb.AddressID = codeBlockAddress;
}
}
}
catch (Exception)
{
}
return codeBlockID;
}
private bool AddToSymbolCollection(SymbolCollection newSymbols, SymbolHelper newSymbol, List<CodeBlock> newCodeBlocks)
{
if (newSymbol.Length >= 800) return false;
foreach (SymbolHelper sh in newSymbols)
{
if (sh.Flash_start_address == newSymbol.Flash_start_address)
{
// Console.WriteLine("Already in collection: " + sh.Flash_start_address.ToString("X8"));
return false;
}
}
newSymbols.Add(newSymbol);
newSymbol.CodeBlock = DetermineCodeBlockByByAddress(newSymbol.Flash_start_address, newCodeBlocks);
return true;
}
private bool isValidLength(int length, int id)
{
int idstrip = id / 256;
if (idstrip == 0xEB || idstrip == 0xDF)
{
if (length > 0 && length <= 32) return true;
}
else
{
if (length > 0 && length < 32) return true;
}
// if (length == 32 || length == 48 || length == 64) Console.WriteLine("seen id " + id.ToString("X4") + " with len " + length.ToString());
return false;
}
private bool isAxisID(int id)
{
int idstrip = id / 256;
if (idstrip == 0xDB) return true;
if (idstrip == 0xC0 || idstrip == 0xC1 || idstrip == 0xC2 || idstrip == 0xC4 || idstrip == 0xC5) return true;
if (idstrip == 0xE0 || idstrip == 0xE4 || idstrip == 0xE5 || idstrip == 0xE9 || idstrip == 0xEA || idstrip == 0xEB || idstrip == 0xEC) return true;
if (idstrip == 0xDA || idstrip == 0xDC || idstrip == 0xDD || idstrip == 0xDE || idstrip == 0xDF) return true;
if (idstrip == 0xF9 || idstrip == 0xFE || idstrip == 0xFC) return true;
if (idstrip == 0xD7 || idstrip == 0xE6) return true;
if (idstrip == 0xD5) return true;
if (idstrip == 0xC3 || idstrip == 0xE7) return true;
return false;
}
// we need to check AHEAD for selector maps
// if these are present we may be facing a complex map structure
// which we need to handle in a special way (selectors always have data like 00 01 00 02 00 03 00 04 etc)
private bool CheckMap(int t, byte[] allBytes, SymbolCollection newSymbols, List<CodeBlock> newCodeBlocks)
{
bool retval = false;
bool _dontGenMaps = false;
List<MapSelector> mapSelectors = new List<MapSelector>();
if (t < allBytes.Length - 0x100)
{
if (CheckAxisCount(t, allBytes, out mapSelectors) > 3)
{
// check for selectors as well, and count them in the process
Console.WriteLine("Offset " + t.ToString("X8") + " has more than 3 consecutive axis");
/*foreach (MapSelector ms in mapSelectors)
{
Console.WriteLine("selector: " + ms.StartAddress.ToString("X8") + " " + ms.MapLength.ToString() + " " + ms.NumRepeats.ToString());
}*/
_dontGenMaps = true;
}
int xaxisid = (Convert.ToInt32(allBytes[t + 1]) * 256) + Convert.ToInt32(allBytes[t]);
if (isAxisID(xaxisid))
{
int xaxislen = (Convert.ToInt32(allBytes[t + 3]) * 256) + Convert.ToInt32(allBytes[t + 2]);
// Console.WriteLine("Valid XID: " + xaxisid.ToString("X4") + " @" + t.ToString("X8") + " len: " + xaxislen.ToString("X2"));
if (isValidLength(xaxislen, xaxisid))
{
//Console.WriteLine("Valid XID: " + xaxisid.ToString("X4") + " @" + t.ToString("X8") + " len: " + xaxislen.ToString("X2"));
// misschien is er nog een as
int yaxisid = (Convert.ToInt32(allBytes[t + 5 + (xaxislen * 2)]) * 256) + Convert.ToInt32(allBytes[t + 4 + (xaxislen * 2)]);
int yaxislen = (Convert.ToInt32(allBytes[t + 7 + (xaxislen * 2)]) * 256) + Convert.ToInt32(allBytes[t + 6 + (xaxislen * 2)]);
if (isAxisID(yaxisid) && isValidLength(yaxislen, yaxisid))
{
// 3d map