-
-
Notifications
You must be signed in to change notification settings - Fork 29
/
fpa_dataset_save.1sc
121 lines (96 loc) · 5 KB
/
fpa_dataset_save.1sc
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
//--------------------------------------
//--- 010 Editor v9.0 Binary Template
//
// File: fpa_dataset_save.1sc
// Author: Jille, MrHonki
// Revision: 5
// Purpose: VAG MQB FPA (fahrprofilauswahl / driving profile) dataset checksum correcting and saving to "0x00," format
// Will output to either VCP or ODIS XML format.
// Currently only useful for 3Q0907530AD FPA datasets.
//--------------------------------------
int saveFormat, saveAddress, saveGeneration, checksumposition;
string saveFolder;
string editName, saveTool, saveName, preData, postData, preDataAddress, footer;
saveFormat = 1; // 0 = VCP 1 = ODIS
saveAddress = 0; // 0 = 0x0B80 1 = 0x2388
saveGeneration = 0; // 0 = MQB (Golf mk7, Leon mk3) 1 = Golf mk8, Leon mk4.
//Uncomment the following to ask what output format to use, each time you run the script:
saveFormat = InputRadioButtonBox("Output Format", "Choose output format", 0, "VCP", "ODIS");
//Uncomment the following to ask which address to use, each time you run the script:
saveAddress = InputRadioButtonBox("Address", "Choose address", 0, "0x0B80", "0x2388");
saveGeneration = InputRadioButtonBox("Generation", "Choose generation", 0, "Golf mk7", "Golf mk8");
saveFolder = InputDirectory("Save dataset to", "%UserProfile%\\Desktop\\");
editName = FileNameGetBase( GetFileName(), false );
saveName = InputString("Dataset name", "Dataset name", "19_3Q0907530Ax_only_FPA-" + editName);
if (saveAddress == 0) {
preDataAddress = "0x0000B80";
} else {
preDataAddress = "0x0002388";
}
if (saveGeneration == 0) {
checksumposition = 4348;
LittleEndian();
} else {
checksumposition = 4084;
BigEndian();
}
if (saveFormat == 0) {
preData = "<SW-CNT>\n<IDENT>\n<LOGIN>20103</LOGIN>\n<DATEIID>MQBCODING_FPA</DATEIID>\n<VERSION-INHALT>"+ GetCurrentDateTime("yyMMddhhmm") +"</VERSION-INHALT>\n</IDENT>\n<DATENBEREICHE>\n<DATENBEREICH>\n<DATEN-NAME>" + saveName + "</DATEN-NAME>\n<DATEN-FORMAT-NAME>DFN_HEX</DATEN-FORMAT-NAME>\n<START-ADR>" + preDataAddress + "</START-ADR>\n<GROESSE-DEKOMPRIMIERT>0x1100</GROESSE-DEKOMPRIMIERT>\n<DATEN>";
postData = "</DATEN>\n</DATENBEREICH>\n</DATENBEREICHE>\n</SW-CNT>";
//footer = "\n\n<!--Generated by fpa_dataset_save.1sc on " + GetCurrentDateTime("yyyy/MM/dd at hh:mm:ss") + " -->"; // will not work with ODIS, it makes the flash file corrupt!
saveTool = "_VCP";
} else {
preData = "<?xml version='1.0' encoding='UTF-8'?>\n<MESSAGE DTD='XMLMSG' VERSION='1.1'>\n<RESULT>\n<RESPONSE NAME='GetParametrizeData' DTD='RepairHints' VERSION='1.4.7.1' ID='0'>\n<DATA>\n<REQUEST_ID>" + GetCurrentDateTime("yyMMddhhmmss") + "</REQUEST_ID>\n<PARAMETER_DATA DIAGNOSTIC_ADDRESS='0x0019' START_ADDRESS='" + preDataAddress + "' PR_IDX='' ZDC_NAME='SET_FPA_MOD' ZDC_VERSION='0001' LOGIN='20103' LOGIN_IND='' DSD_TYPE='1' SESSIONNAME='' FILENAME=''>";
postData = "</PARAMETER_DATA>\n<COMPOUNDS>\n<COMPOUND COMPOUND_ID='1'>\n<SW_NAME />\n<SW_VERSION />\n<SW_PART_NO />\n</COMPOUND>\n<COMPOUND COMPOUND_ID='2'>\n<SW_NAME />\n<SW_VERSION />\n<SW_PART_NO />\n</COMPOUND>\n<COMPOUND COMPOUND_ID='3'>\n<SW_NAME />\n<SW_VERSION />\n<SW_PART_NO />\n</COMPOUND>\n<COMPOUND COMPOUND_ID='4'>\n<SW_NAME />\n<SW_VERSION />\n<SW_PART_NO />\n</COMPOUND>\n<COMPOUND COMPOUND_ID='5'>\n<SW_NAME />\n<SW_VERSION />\n<SW_PART_NO />\n</COMPOUND>\n</COMPOUNDS>\n<INFORMATION>\n<CODE />\n</INFORMATION>\n<DSD_DATA>\n<COMPRESSED_DATA CONTENT='DSD-Files' CONTENT_TYPE='application/tar' CONTENT_TRANSFER_ENCODING='base64' BYTES_UNCOMPRESSED='0' BYTES_COMPRESSED='0'>\n</COMPRESSED_DATA>\n</DSD_DATA>\n</DATA>\n</RESPONSE>\n</RESULT>\n</MESSAGE>";
//footer = "\n\n<!--Generated by fpa_dataset_save.1sc on " + GetCurrentDateTime("yyyy/MM/dd at hh:mm:ss") + " -->"; // will not work with ODIS, it makes the flash file corrupt!
saveTool = "_ODIS";
}
LittleEndian(); // go to littleendian mode because of checksum format
local int calculated_checksum;
calculated_checksum = Checksum(CHECKSUM_CRC32, 0, checksumposition);
FSeek(checksumposition);
WriteInt(checksumposition, calculated_checksum);
SetSelection(0, checksumposition+4);
const string title = "Hex To Ascii String";
string s;
string sDataset;
int64 adr, siz, out;
int actfile, newfile, bits;
char tmp;
unsigned char rnibbles;
if (FileCount() == 0) {
MessageBox(idOk, title, "No file is open.");
return -1;
}
adr = 0;
siz = FileSize();
if (siz == 0) {
MessageBox(idOk, title, "No bytes to process.");
return -1;
}
actfile = GetFileNum();
newfile = FileNew();
FileSelect(actfile);
bits = 0;
out = 0;
int index = adr;
while (index <= adr + siz - 1) {
s = "";
FileSelect(actfile);
tmp = ReadByte(index);
FileSelect(newfile);
if (index == 0) {
SPrintf(s, "0x%.2X", tmp & 0xFF);
} else {
SPrintf(s, ",0x%.2X", tmp & 0xFF);
}
sDataset += s;
index++;
}
sDataset = preData + sDataset + postData + footer;
WriteString(0, sDataset);
FileSelect(newfile);
SetCursorPos(FileSize());
string filename = saveFolder + saveName + "_" + GetCurrentDateTime("yyyyMMdd_hhmmss") + saveTool + ".xml";
FileSave(filename);
FileClose();