Previous Top 
VehicleProfileHash XT3

The XT3 features Vehicle Profiles. Something that was already observed for the Tread2. In the Trip files these items must be filled, or the XT3 will not accept it as a valid trip file.

·   mVehicleProfileTruckType
·   mVehicleProfileName
·   mVehicleProfileHash
·   mVehicleId
·   mVehicleProfileGuid

The data for these items can be found in the vehicle_profile.db, except for mVehicleProfileHash. Only recently, using a lot of tests, it has been discovered how this Hash value can be computed. The calculation is only valid for the XT3. The XT does not have profiles, the XT2 only has two profiles (metric/imperial), and accepts a value 0. The Tread2 may be working similarly, but the profiles allow more configuration options, and the computed values do not match.

If a correct Hash is not supplied in the trip file, the XT3 will popup a message when opening the trip, that the selected profile is out of date, often resulting in duplicated profile names, causing confusion.

Known limitations:
- Road use. 'Street Legal' should be enabled.

Additional limitations for Car profiles:
- The 'Traction Method' should only be set to '...2WD', or  '...4WD'.

Tested for Locales: NL, DE, UK and US.

This calculation has been implemented in UnitVehProfile.pas.


1. Execute SQL statement to get the data from the active profile

select
(select act."description:1" from properties_dbg act where act.value = v.vehicle_id and act."description:1" = 'active_profile' ) as Status,
Hex(g.description) as GUID,
e.value as Environmental,
0 as Proposed_Hash,
0 as Overridden_Hash,
v.*
from vehicle_profile v
join properties_dbg g on (g.value = v.vehicle_id and g."description:1" = 'guid')
join properties_dbg e on (e.key_id = g.key_id and e."description:1" like 'environmental%')
order by Status desc, v.vehicle_id asc;

graphic
Fields Vehicle_Id, Truck_Type, Name, GUID_Data are copied into the corresponding items.

Fields Truck_Type, Adventurous_Route_Mode, Environmental, Calc_Method, Max_Vehicle_Speed, Traction, Width, Width_Metric, Road_Legality are needed to compute the hash.









Results:
Truck_Type: 9
Adventurous_Route_Mode: 0
Environmental: 1
Calc_Method: 0
Max_Vehicle_Speed: 0
Traction: 4
Width: 120
Width_Metric: 1
Road_Legality: 2


2. Lookup the 'base value' in the table 'XT3_Motor_Hashes' ('XT3_Car_Hashes'  for Cars) using the fields Calc_method, Adventurous_Route_mode, and Traction.
XT3_Motor_Hashes: array[0..6] of TKnownHash = (
(CM: cmFaster;              HashT2: $0A4F0000 HashT3: $0A1F0000),
(CM: cmShorter;             HashT2: $07E00000;  HashT3: $07D00000),
(CM: cmStraight;            HashT2: $079B0000;  HashT3: $07CB0000),
(CM: cmAdv; AdvLvl: advL1;  HashT2: $0A4A0000;  HashT3: $0A1A0000),
(CM: cmAdv; AdvLvl: advL2;  HashT2: $0A7A0000;  HashT3: $0A6A0000),
(CM: cmAdv; AdvLvl: advL3;  HashT2: $0AAA0000;  HashT3: $0A3A0000),
(CM: cmAdv; AdvLvl: advL4;  HashT2: $0A5A0000;  HashT3: $0A0A0000)
);
TProfCalcMethod  = (cmFaster = 0, cmShorter = 1, cmStraight = 4, cmAdv = 7);
Note: for Faster Adventurous_Route_mode is not used.

TTraction = (tr2WD = 1, tr4WD = 2, tr3Wheels = 3, tr2Wheels = 4);


The lookup gives the base value: $0A4F0000
3. Use the high nibble of Width, Env_Data and Road_Legality to add the value for 'Legal_Environments' to the Base_Hash.
XT3_Legal_Environments: array[0..$f, TRoadLegality, TProfEnvironment] of Cardinal =
  (
    // Not legal, Not impl.     Not Highway legal      Legal
    // Avoid   Allow  Ask       Avoid  Allow  Ask      Avoid  Allow  Ask
    ( ($0000, $0000, $0000),  ($0000, $0000, $0000), ($0000, $0000, $0000) ),
    ( ($0000, $0000, $0000),  ($0000, $0000, $0000), ($0000, $0000, $0000) ),
    ( ($0000, $0000, $0000),  ($0000, $0000, $0000), ($0000, $0000, $0000) ),
    ( ($0000, $0000, $0000),  ($0000, $0000, $0000), ($0000, $0000, $0000) ),
    ( ($0000, $0000, $0000),  ($0000, $0000, $0000), ($0000, $0000, $0000) ),
    ( ($0000, $0000, $0000),  ($0000, $0000, $0000), ($0000, $0000, $0000) ),
    ( ($0000, $0000, $0000),  ($9000, $8000, $b000), ($a000, $b000, $8000) ),
    ( ($0000, $0000, $0000),  ($8000, $9000, $a000), ($b000, $a000, $9000) ),
    ( ($0000, $0000, $0000),  ($7000, $6000, $5000), ($4000, $5000, $6000) ),
    ( ($0000, $0000, $0000),  ($6000, $7000, $4000), ($5000, $4000, $7000) ),
    ( ($0000, $0000, $0000),  ($5000, $4000, $7000), ($6000, $7000, $4000) ),
    ( ($0000, $0000, $0000),  ($4000, $5000, $6000), ($7000, $6000, $5000) ),
    ( ($0000, $0000, $0000),  ($3000, $2000, $1000), ($0000, $1000, $2000) ),
    ( ($0000, $0000, $0000),  ($2000, $3000, $0000), ($1000, $0000, $3000) ),
    ( ($0000, $0000, $0000),  ($1000, $0000, $3000), ($2000, $3000, $0000) ),
    ( ($0000, $0000, $0000),  ($0000, $0000, $0000), ($0000, $0000, $0000) )
  );
For Width use only the high nibble.

TRoadLegality = (rlNone = 0, rlNoHighway = 1, rlLegal = 2);

TProfEnvironment = (enAvoid = 0, enAllow = 1, enAsk = 2);

Width: 120 = 0x78 => 7
Legal: 2
Environment: 1








$0A4F0000 + $A000 = $0A4FA000


4. Use the values of the low nibble of Width and Max_Vehicle_Speed, to complete the calculation.

Background info. The value Max_Vehicle_Speed in the Vehicle profile is expressed as Decimeters/Sec. In the Sample data Max_Vehicle_Speed = 0, meaning no restriction. See below for an example of max speed 60 kmh.

Step 1: Write the value as 3 nibbles.
0 = > 0x000
Nibble1: 0. Add this to the 2nd Nibble of HashValue: $0A4FA000

Note: Need values 90kmh or higher for a value > 0.
Nibble 1 Speed: 0

$0A4FA000 + $0=$0A4FA000
Nibble:2 0. Use the low nibble of Width and the 2nd nibble of  Max_Vehicle_Speed to lookup the value in table Speed2Tab and add that value to the 6th Nibble: $0A4FA000
Speed2Tab: array[0..$f, 0..$f] of byte =
  (
    ($7  ,$6  ,$5  ,$4  ,$3  ,$2  ,$1  ,$0  ,$f  ,$e  ,$d  ,$c  ,$b  ,$a  ,$9  ,$8),
    ($6  ,$7  ,$4  ,$5  ,$2  ,$3  ,$0  ,$1  ,$e  ,$f  ,$c  ,$d  ,$a  ,$b  ,$8  ,$9),
    ($5  ,$4  ,$7  ,$6  ,$1  ,$0  ,$3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,$9  ,$a  ,$b  ,$c  ,$d  ,$e  ,$f  ,$0  ,$1  ,$2  ,$3  ,$4  ,$5  ,$6  ,$7)
  );
Low nibble Width: 8
Nibble 2 Speed: 0















$0A4FA000 + $F00 = $0A4FAF00
Nibble:3 0. Use one of the lookup tables Bike/Car Speed3Tab Metric/Imperial and add that value to the 7th Nibble: $0A4FA000
BikeSpeed3TabImperial: array[0..$f] of byte =
  ($e, $f, $c, $d, $a, $b, $8, $9, $6, $7, $4, $5, $2, $3, $0, $1);
BikeSpeed3TabMetric: array[0..$f] of byte =
  ($2, $3, $0, $1, $6, $7, $4, $5, $a, $b, $8, $9, $e, $f, $c, $d);
CarSpeed3TabImperial: array[0..$f] of byte =
  ($d, $c, $f, $e, $9, $8, $b, $a, $5, $4, $7, $6, $1, $0, $3, $2);
CarSpeed3TabMetric: array[0..$f] of byte =
  ($1, $0, $3, $2, $5, $4, $7, $6, $9, $8, $b, $a, $d, $c, $f, $e);

Because Truck_type=9 and Width_metric=1, we need to use the BikeSpeed3TabMetric  table.
Nibble 3 speed: 0









$0A4FAF00 +  $20 = $0A4FAF20
4. 60 kmh example.
60 kmh corresponds to 166 m/sec in the vehicle profile.
166 => 0x0a6
Width 120 => 0x78
Nibble 1 speed: 0

$0A4FA000 + $0=$0A4FA000
Low nibble width: 0x08
Nibble 2 speed: 0x0a

Speed2Tab[0x08, 0x0a] = 5



$0A4FA000 + $500 = $0A4FA500
Nibble: 3 speed: 0x06

BikeSpeed3Metric[0x06] = 4


$0A4FA500 + $40 = $0A4FA540
Screenshots defining the profile
graphic
graphic
graphic
graphic
graphic
graphic
graphic