Skip to content

Commit 8a63dfc

Browse files
committed
Add UDS hex editor, fixup uint parsing issues
1 parent c3e64d4 commit 8a63dfc

File tree

10 files changed

+975
-39
lines changed

10 files changed

+975
-39
lines changed

Caesar/Caesar/DiagPresentation.cs

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ public string InterpretData(byte[] inBytes, DiagPreparation inPreparation)
164164
{
165165
return "BitOffset was outside byte boundary (skipped)";
166166
}
167-
168167
int dataType = GetDataType();
169168
string humanReadableType = $"UnhandledType:{dataType}";
170169
string parsedValue = BitUtility.BytesToHex(workingBytes, true);
@@ -218,50 +217,51 @@ public int GetDataType()
218217
{
219218
return 20;
220219
}
220+
221+
// does the value have scale structures attached to it?
222+
// supposed to parse scale struct and check if we can return 20
221223
if (ScaleTableOffset != -1)
222224
{
223-
// scale value
224-
// integer
225-
return (ScaleTableOffset == -1) ? 6 : 20;
226-
// supposed to parse scale struct and check if we can return 20
225+
return 20; // scaled value
227226
}
228227
else
229228
{
230229
if (unk5 != -1)
231230
{
232-
// hexdump raw
233-
return 18;
231+
return 18; // hexdump raw
234232
}
235233
if (unk17 != -1)
236234
{
237-
// hexdump raw
238-
return 18;
235+
return 18; // hexdump raw
239236
}
240237
if (unk19 != -1)
241238
{
242-
// hexdump raw
243-
return 18;
239+
return 18; // hexdump raw
244240
}
245241
if (unk22 != -1)
246242
{
247-
// hexdump raw
248-
return 18;
243+
return 18; // hexdump raw
249244
}
250245
if (unk1b != -1)
251246
{
252247
if (unk1b == 6)
253248
{
254-
// ascii dump
255-
return 17;
249+
return 17; // ascii dump
256250
}
257251
else if (unk1b == 7)
258252
{
259-
return 22;
253+
return 22; // ?? haven't seen this one around
260254
}
261255
else if (unk1b == 8)
262256
{
263-
// integer
264-
result = 6;
257+
result = 6; // integer
258+
}
259+
else if (unk1b == 5)
260+
{
261+
// UNSIGNED integer (i haven't seen a const for uint around, sticking it into a regular int for now)
262+
// this will be an issue for 32-bit+ uints
263+
// see DT_STO_Zaehler_Programmierversuche_Reprogramming and DT_STO_ID_Aktive_Diagnose_Information_Version
264+
result = 6;
265265
}
266266
}
267267
else
@@ -273,20 +273,13 @@ public int GetDataType()
273273
}
274274
if ((unk1e == 1) || (unk1e == 2))
275275
{
276-
result = 5;
276+
result = 5; // ?? haven't seen this one around
277277
}
278278
else
279279
{
280-
result = 2;
280+
result = 2; // ?? haven't seen this one around
281281
}
282282
}
283-
284-
// jg: this isn't official, but if it is a single byte at this point, it's probably an unsigned 1byte
285-
// see UDS DT_STO* for examples (e.g. variant query)
286-
if ((result == -1) && (TypeLength_1a == 1))
287-
{
288-
result = 18;
289-
}
290283
return result;
291284
}
292285
}
@@ -296,7 +289,7 @@ public void PrintDebug()
296289
Console.WriteLine("Presentation: ");
297290
Console.WriteLine($"{nameof(Qualifier)}: {Qualifier}");
298291

299-
/*
292+
300293
//Console.WriteLine($"{nameof(Description_CTF)}: {Description_CTF}");
301294
Console.WriteLine($"{nameof(ScaleTableOffset)}: {ScaleTableOffset}");
302295
Console.WriteLine($"{nameof(ScaleCountMaybe)}: {ScaleCountMaybe}");
@@ -341,7 +334,7 @@ public void PrintDebug()
341334

342335
Console.WriteLine($"{nameof(unk25)}: {unk25}");
343336
Console.WriteLine($"{nameof(unk26)}: {unk26}");
344-
*/
337+
/**/
345338

346339

347340
Console.WriteLine($"{nameof(DescriptionString)}: {DescriptionString}");

Caesar/Caesar/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.4.0.0")]
36-
[assembly: AssemblyFileVersion("1.4.0.0")]
35+
[assembly: AssemblyVersion("1.4.1.0")]
36+
[assembly: AssemblyFileVersion("1.4.1.0")]

Caesar/Diogenes/Diogenes.csproj

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,14 @@
5454
<ApplicationIcon>diogenes-256.ico</ApplicationIcon>
5555
</PropertyGroup>
5656
<ItemGroup>
57+
<Reference Include="Be.Windows.Forms.HexBox, Version=1.6.1.0, Culture=neutral, processorArchitecture=MSIL">
58+
<HintPath>..\packages\Be.Windows.Forms.HexBox.1.6.1\lib\net40\Be.Windows.Forms.HexBox.dll</HintPath>
59+
</Reference>
5760
<Reference Include="J2534-Sharp, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
5861
<HintPath>..\packages\J2534-Sharp.1.0.0-CI00026\lib\net46\J2534-Sharp.dll</HintPath>
5962
</Reference>
63+
<Reference Include="PresentationCore" />
64+
<Reference Include="PresentationFramework" />
6065
<Reference Include="System" />
6166
<Reference Include="System.Core" />
6267
<Reference Include="System.Xml.Linq" />
@@ -68,6 +73,7 @@
6873
<Reference Include="System.Net.Http" />
6974
<Reference Include="System.Windows.Forms" />
7075
<Reference Include="System.Xml" />
76+
<Reference Include="WindowsFormsIntegration" />
7177
</ItemGroup>
7278
<ItemGroup>
7379
<Compile Include="DiagnosticProtocol\KW2C3PE.cs" />
@@ -129,6 +135,12 @@
129135
<Compile Include="Forms\TraceForm.Designer.cs">
130136
<DependentUpon>TraceForm.cs</DependentUpon>
131137
</Compile>
138+
<Compile Include="Forms\UDSHexEditor.cs">
139+
<SubType>Form</SubType>
140+
</Compile>
141+
<Compile Include="Forms\UDSHexEditor.Designer.cs">
142+
<DependentUpon>UDSHexEditor.cs</DependentUpon>
143+
</Compile>
132144
<Compile Include="UnmanagedUtility.cs" />
133145
<Compile Include="Forms\VCForm.cs">
134146
<SubType>Form</SubType>
@@ -174,6 +186,9 @@
174186
<EmbeddedResource Include="Forms\VCForm.resx">
175187
<DependentUpon>VCForm.cs</DependentUpon>
176188
</EmbeddedResource>
189+
<EmbeddedResource Include="Forms\UDSHexEditor.resx">
190+
<DependentUpon>UDSHexEditor.cs</DependentUpon>
191+
</EmbeddedResource>
177192
<None Include="packages.config" />
178193
<None Include="Properties\Settings.settings">
179194
<Generator>SettingsSingleFileGenerator</Generator>

Caesar/Diogenes/Forms/MainForm.Designer.cs

Lines changed: 24 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Caesar/Diogenes/Forms/MainForm.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,5 +1004,22 @@ private void copyConsoleToolStripMenuItem_Click(object sender, EventArgs e)
10041004
{
10051005
Clipboard.SetText(txtLog.Text);
10061006
}
1007+
1008+
private void uDSHexEditorToolStripMenuItem_Click(object sender, EventArgs e)
1009+
{
1010+
if (Connection.ConnectionProtocol is null)
1011+
{
1012+
MessageBox.Show("Please initiate contact with a target first.");
1013+
return;
1014+
}
1015+
string protocolName = Connection.ConnectionProtocol.GetProtocolName();
1016+
if (protocolName != "UDS")
1017+
{
1018+
MessageBox.Show($"Only UDS targets are officially supported (current protocol: {protocolName}). \r\n\r\n" +
1019+
$"The editor will still open, however please ensure that the ECU accepts UDS-like read and write commands");
1020+
}
1021+
UDSHexEditor editor = new UDSHexEditor(Connection);
1022+
editor.ShowDialog();
1023+
}
10071024
}
10081025
}

0 commit comments

Comments
 (0)