Skip to content

Commit

Permalink
Fix inaccurate DTC parsing (2)
Browse files Browse the repository at this point in the history
  • Loading branch information
jglim committed Apr 11, 2021
1 parent 49af36c commit 27369e9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
5 changes: 3 additions & 2 deletions Caesar/Diogenes/DiagnosticProtocol/UDS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ public override List<DTCContext> ReportDtcsByStatusMask(ECUConnection connection
{
byte[] dtcRow = new byte[4];
Array.ConstrainedCopy(response, i, dtcRow, 0, 4);
long dtcIdRaw = (dtcRow[3] << 24) | (dtcRow[2] << 16) | (dtcRow[1] << 8) | dtcRow[0];
byte statusMask = dtcRow[3];
long dtcIdRaw = ((dtcRow[0] << 16) | (dtcRow[1] << 8) | dtcRow[2]);
// issue raised in https://github.com/jglim/CaesarSuite/discussions/21#discussioncomment-587029
// no idea which part of the spec requires ANDing 3FFFFF; what do the upper 2+8 bits do?
dtcIdRaw &= 0x3FFFFF;
Expand All @@ -234,7 +235,7 @@ public override List<DTCContext> ReportDtcsByStatusMask(ECUConnection connection
}
else
{
dtcCtx.Add(new DTCContext() { DTC = foundDtc, StatusByte = dtcRow[3], EnvironmentContext = new List<string[]>() });
dtcCtx.Add(new DTCContext() { DTC = foundDtc, StatusByte = statusMask, EnvironmentContext = new List<string[]>() });
}
}
return dtcCtx;
Expand Down
4 changes: 2 additions & 2 deletions Caesar/Diogenes/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.5.2.0")]
[assembly: AssemblyFileVersion("1.5.2.0")]
[assembly: AssemblyVersion("1.5.2.1")]
[assembly: AssemblyFileVersion("1.5.2.1")]
18 changes: 14 additions & 4 deletions Caesar/Diogenes/Simulation/Simulated_CRD3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Text;
using System.Threading.Tasks;
using System.IO;
using Caesar;

namespace Diogenes.Simulation
{
Expand Down Expand Up @@ -246,7 +247,8 @@ public Simulated_CRD3()
}


ushort ECU_VARIANT = 0x2131;
//ushort ECU_VARIANT = 0x2131;
ushort ECU_VARIANT = 0x1000; // pretend to be eis166 for a while
byte ECU_SUPPLIER_IDENTIFIER = (byte)Vendor.VENDOR_Delphi;

byte ECU_SESSION = 1; // default
Expand All @@ -259,7 +261,7 @@ public Simulated_CRD3()
byte[] ECU_SoftwareCalibrationNumber = { 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38 };
byte[] ECU_EROTAN = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };

byte[] EnvTest = { 0x00, 0x90, 0x00, 0x2F, 0x01, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x06, 0x28, 0x02, 0x00, 0x24, 0x00, 0x93, 0x00, 0x38, 0x02, 0x0F, 0x01, 0x04, 0x7F, 0x7C, 0x00, 0x88, 0x8E, 0xA5, 0x3C, 0x0A, 0x00, 0x00, 0x00, 0x5F, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x53, 0x00, 0x03, 0x00, 0x24, 0x00, 0x93, 0x00, 0x38, 0x02, 0x0F, 0x01, 0x04, 0x7F, 0x7C, 0x00, 0x88, 0x8E, 0xA5, 0x3C, 0x0A, 0x00, 0x00, 0x00, 0x5F, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x53, 0x00 };
byte[] EnvTest = {0x00, 0x90, 0x00, 0x2F, 0x01, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x06, 0x28, 0x02, 0x00, 0x24, 0x00, 0x93, 0x00, 0x38, 0x02, 0x0F, 0x01, 0x04, 0x7F, 0x7C, 0x00, 0x88, 0x8E, 0xA5, 0x3C, 0x0A, 0x00, 0x00, 0x00, 0x5F, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x53, 0x00, 0x03, 0x00, 0x24, 0x00, 0x93, 0x00, 0x38, 0x02, 0x0F, 0x01, 0x04, 0x7F, 0x7C, 0x00, 0x88, 0x8E, 0xA5, 0x3C, 0x0A, 0x00, 0x00, 0x00, 0x5F, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x53, 0x00 };

// this behaves a bit more like my uC implementation
// performance is generally poorer, though the IO is fairly minimal
Expand Down Expand Up @@ -371,18 +373,26 @@ public override byte[] ReceiveRequest(IEnumerable<byte> request)
WriteByte(infoType);

byte mask = requestBytes[2];
WriteByte(0xFF); // mask

if (infoType == 0x02)
{
/*
// mask should go here?
WriteByte(0xFF); // mask
WriteByte(0x00);
WriteByte(0x90);
WriteByte(0x00);
WriteByte(0x2F);
*/
WriteByteArray(BitUtility.BytesFromHex("5B D0 3D 2A 0B D0 32 2A 0B C0 19 2A 0B D0 38 2A 08 C1 22 87 0B D1 82 00 0B D1 80 00 0B 06 10 00 0B D1 81 00 03 D1 83 00 03 D1 98 00 41")); // eis166
}
else if (infoType == 0x06)
else if (infoType == 0x06)
{
/*
WriteByte(0xFF); // mask
WriteByteArray(EnvTest);
*/
WriteByteArray(BitUtility.BytesFromHex("D0 3D 2A 0B 01 00 2A C0 2A C0 09 00 ")); // eis166
}
}
else
Expand Down

0 comments on commit 27369e9

Please sign in to comment.