diff --git a/data/obd2.dbc b/data/obd2.dbc index 80440c6..c650576 100644 --- a/data/obd2.dbc +++ b/data/obd2.dbc @@ -213,12 +213,18 @@ BO_ 2024 OBD2: 8 Vector__XXX SG_ S1_PID_A6_Odometer m166 : 31|32@0+ (0.1,0) [0|429496729.5] "km" Vector__XXX SG_ S1_PID_C0_PIDsSupported_C1_E0 m192 : 31|32@0+ (1,0) [0|4294967295] "" Vector__XXX SG_ S2_PID_02_FreezeDTC m2 : 31|16@0+ (1,0) [0|65535] "" Vector__XXX + SG_ S35_PID_01_Blinkers_Highbeams m1 : 39|8@0+ (1,0) [0|255] "" Vector__XXX + SG_ S35_PID_02_Gear m2 : 31|16@0+ (1,0) [-127|127] "" Vector__XXX + SG_ S35_PID_03_Oil_Pressure m3 : 31|16@0+ (1,0) [0|65535] "psi" Vector__XXX + SG_ S35_PID_04_Tripmeter m4 : 31|32@0+ (0.1,0) [0|429496729.5] "km" Vector__XXX SG_ ParameterID_Service01 m1M : 23|8@0+ (1,0) [0|255] "" Vector__XXX SG_ ParameterID_Service02 m2M : 23|8@0+ (1,0) [0|255] "" Vector__XXX - SG_ service M : 13|6@0+ (1,0) [0|15] "" Vector__XXX + SG_ ParameterID_Service35 m35M : 23|8@0+ (1,0) [0|255] "" Vector__XXX + SG_ service M : 13|6@0+ (1,0) [0|63] "" Vector__XXX SG_ response : 15|2@0+ (1,0) [0|15] "" Vector__XXX SG_ length : 7|8@0+ (1,0) [0|255] "" Vector__XXX +VAL_ 2024 ParameterID_Service35 1 "S35_PID_01_Blinkers_Highbeams" 2 "S35_PID_02_Gear" 3 "S35_PID_03_Oil_Pressure" 4 "S35_PID_04_Tripmeter"; CM_ BO_ 2024 "OBD2 DBC developed by canmatrix & CSS Electronics - for questions contact us at www.csselectronics.com"; @@ -242,7 +248,8 @@ VAL_ 2024 S1_PID_1C_OBDStandard 1 "OBD-II as defined by the CARB" 2 "OBD as defi VAL_ 2024 S1_PID_51_FuelType 0 "Not available" 1 "Gasoline" 2 "Methanol" 3 "Ethanol" 4 "Diesel" 5 "LPG" 6 "CNG" 7 "Propane" 8 "Electric" 9 "Bifuel running Gasoline" 10 "Bifuel running Methanol" 11 "Bifuel running Ethanol" 12 "Bifuel running LPG" 13 "Bifuel running CNG" 14 "Bifuel running Propane" 15 "Bifuel running Electricity" 16 "Bifuel electric/comb. eng." 17 "Hybrid gasoline" 18 "Hybrid Ethanol" 19 "Hybrid Diesel" 20 "Hybrid Electric" 21 "Hybrid running electric/comb." 22 "Hybrid Regenerative" 23 "Bifuel running diesel" ; VAL_ 2024 ParameterID_Service01 0 "S1_PID_00_PIDsSupported_01_20" 1 "S1_PID_01_MonitorStatus" 2 "S1_PID_02_FreezeDTC" 3 "S1_PID_03_FuelSystemStatus" 4 "S1_PID_04_CalcEngineLoad" 5 "S1_PID_05_EngineCoolantTemp" 6 "S1_PID_06_ShortFuelTrimBank1" 7 "S1_PID_07_LongFuelTrimBank1" 8 "S1_PID_08_ShortFuelTrimBank2" 9 "S1_PID_09_LongFuelTrimBank2" 10 "S1_PID_0A_FuelPressure" 11 "S1_PID_0B_IntakeManiAbsPress" 12 "S1_PID_0C_EngineRPM" 13 "S1_PID_0D_VehicleSpeed" 14 "S1_PID_0E_TimingAdvance" 15 "S1_PID_0F_IntakeAirTemperature" 16 "S1_PID_10_MAFAirFlowRate" 17 "S1_PID_11_ThrottlePosition" 18 "S1_PID_12_CmdSecAirStatus" 20 "S1_PID_14_OxySensor1" 21 "S1_PID_15_OxySensor2" 22 "S1_PID_16_OxySensor3" 23 "S1_PID_17_OxySensor4" 24 "S1_PID_18_OxySensor5" 25 "S1_PID_19_OxySensor6" 26 "S1_PID_1A_OxySensor7" 27 "S1_PID_1B_OxySensor8" 28 "S1_PID_1C_OBDStandard" 31 "S1_PID_1F_TimeSinceEngStart" 32 "S1_PID_20_PIDsSupported_21_40" 33 "S1_PID_21_DistanceMILOn" 34 "S1_PID_22_FuelRailPres" 35 "S1_PID_23_FuelRailGaug" 36 "S1_PID_24_OxySensor1" 37 "S1_PID_25_OxySensor2" 38 "S1_PID_26_OxySensor3" 39 "S1_PID_27_OxySensor4" 40 "S1_PID_28_OxySensor5" 41 "S1_PID_29_OxySensor6" 42 "S1_PID_2A_OxySensor7" 43 "S1_PID_2B_OxySensor8" 44 "S1_PID_2C_CmdEGR" 45 "S1_PID_2D_EGRError" 46 "S1_PID_2E_CmdEvapPurge" 47 "S1_PID_2F_FuelTankLevel" 48 "S1_PID_30_WarmUpsSinceCodeClear" 49 "S1_PID_31_DistanceSinceCodeClear" 50 "S1_PID_32_EvapSysVaporPres" 51 "S1_PID_33_AbsBaroPres" 52 "S1_PID_34_OxySensor1" 53 "S1_PID_35_OxySensor2" 54 "S1_PID_36_OxySensor3" 55 "S1_PID_37_OxySensor4" 56 "S1_PID_38_OxySensor5" 57 "S1_PID_39_OxySensor6" 58 "S1_PID_3A_OxySensor7" 59 "S1_PID_3B_OxySensor8" 60 "S1_PID_3C_CatTempBank1Sens1" 61 "S1_PID_3D_CatTempBank2Sens1" 62 "S1_PID_3E_CatTempBank1Sens2" 63 "S1_PID_3F_CatTempBank2Sens2" 64 "S1_PID_40_PIDsSupported_41_60" 65 "S1_PID_41_MonStatusDriveCycle" 66 "S1_PID_42_ControlModuleVolt" 67 "S1_PID_43_AbsLoadValue" 68 "S1_PID_44_FuelAirCmdEquiv" 69 "S1_PID_45_RelThrottlePos" 70 "S1_PID_46_AmbientAirTemp" 71 "S1_PID_47_AbsThrottlePosB" 72 "S1_PID_48_AbsThrottlePosC" 73 "S1_PID_49_AbsThrottlePosD" 74 "S1_PID_4A_AbsThrottlePosE" 75 "S1_PID_4B_AbsThrottlePosF" 76 "S1_PID_4C_CmdThrottleAct" 77 "S1_PID_4D_TimeRunMILOn" 78 "S1_PID_4E_TimeSinceCodeClear" 79 "S1_PID_4F_MaxMultiple" 80 "S1_PID_50_Max_AirFlowMAF" 81 "S1_PID_51_FuelType" 82 "S1_PID_52_EthanolFuelPct" 83 "S1_PID_53_AbsEvapSysVapPres" 84 "S1_PID_54_EvapSysVapPres" 85 "S1_PID_55_ShortSecOxyTrimBankX" 86 "S1_PID_56_LongSecOxyTrimBankX" 87 "S1_PID_57_ShortSecOxyTrimBankX" 88 "S1_PID_58_LongSecOxyTrimBankX" 89 "S1_PID_59_FuelRailAbsPres" 90 "S1_PID_5A_RelAccelPedalPos" 91 "S1_PID_5B_HybrBatPackRemLife" 92 "S1_PID_5C_EngineOilTemp" 93 "S1_PID_5D_FuelInjectionTiming" 94 "S1_PID_5E_EngineFuelRate" 95 "S1_PID_5F_EmissionReq" 96 "S1_PID_60_PIDsSupported_61_80" 97 "S1_PID_61_DemandEngTorqPct" 98 "S1_PID_62_ActualEngTorqPct" 99 "S1_PID_63_EngRefTorq" 100 "S1_PID_64_EngPctTorq" 101 "S1_PID_65_AuxInputOutput" 102 "S1_PID_66_MAFSensor" 103 "S1_PID_67_EngineCoolantTemp" 104 "S1_PID_68_IntakeAirTempSens" 105 "S1_PID_69_CmdEGR_EGRError" 106 "S1_PID_6A_CmdDieselIntAir" 107 "S1_PID_6B_ExhaustGasTemp" 108 "S1_PID_6C_CmdThrottleActRel" 109 "S1_PID_6D_FuelPresContrSys" 110 "S1_PID_6E_InjPresContrSys" 111 "S1_PID_6F_TurboComprPres" 112 "S1_PID_70_BoostPresCntrl" 128 "S1_PID_80_PIDsSupported_81_A0" 142 "S1_PID_8E_EngFrictionPctTorq" 160 "S1_PID_A0_PIDsSupported_A1_C0" 166 "S1_PID_A6_Odometer" 192 "S1_PID_C0_PIDsSupported_C1_E0" ; VAL_ 2024 ParameterID_Service02 2 "S2_PID_02_FreezeDTC" ; -VAL_ 2024 service 10 "Permanent DTCs (Cleared DTCs) " 9 "Request vehicle information " 8 "Control on-board system " 7 "Show pending DTCs " 6 "Other system monitoring " 5 "Oxygen sensor monitoring " 4 "Clear DTCs and stored values" 3 "Show stored DTCs " 2 "Show freeze frame data " 1 "Show current data " ; +VAL_ 2024 ParameterID_Service35 1 "S35_PID_01_Blinkers_Highbeams" 2 "S35_PID_02_Gear" 3 "S35_PID_03_Oil_Pressure" 4 "S35_PID_04_Tripmeter"; +VAL_ 2024 service 53 "Custom Service EDL " 10 "Permanent DTCs (Cleared DTCs) " 9 "Request vehicle information " 8 "Control on-board system " 7 "Show pending DTCs " 6 "Other system monitoring " 5 "Oxygen sensor monitoring " 4 "Clear DTCs and stored values" 3 "Show stored DTCs " 2 "Show freeze frame data " 1 "Show current data " ; SG_MUL_VAL_ 2024 S1_PID_00_PIDsSupported_01_20 ParameterID_Service01 0-0; SG_MUL_VAL_ 2024 S1_PID_01_MonitorStatus ParameterID_Service01 1-1; @@ -395,5 +402,10 @@ SG_MUL_VAL_ 2024 S1_PID_A0_PIDsSupported_A1_C0 ParameterID_Service01 160-160; SG_MUL_VAL_ 2024 S1_PID_A6_Odometer ParameterID_Service01 166-166; SG_MUL_VAL_ 2024 S1_PID_C0_PIDsSupported_C1_E0 ParameterID_Service01 192-192; SG_MUL_VAL_ 2024 S2_PID_02_FreezeDTC ParameterID_Service02 2-2; +SG_MUL_VAL_ 2024 S35_PID_01_Blinkers_Highbeams ParameterID_Service35 1-1; +SG_MUL_VAL_ 2024 S35_PID_02_Gear ParameterID_Service35 2-2; +SG_MUL_VAL_ 2024 S35_PID_03_Oil_Pressure ParameterID_Service35 3-3; +SG_MUL_VAL_ 2024 S35_PID_04_Tripmeter ParameterID_Service35 4-4; SG_MUL_VAL_ 2024 ParameterID_Service01 service 1-1; SG_MUL_VAL_ 2024 ParameterID_Service02 service 2-2; +SG_MUL_VAL_ 2024 ParameterID_Service35 service 53-53; diff --git a/data/realdash_obd2.xml b/data/realdash_obd2.xml index 8a89165..89d52ea 100644 --- a/data/realdash_obd2.xml +++ b/data/realdash_obd2.xml @@ -107,7 +107,8 @@ Requires RealDash version 1.5.8 or newer - + + diff --git a/src/can.cpp b/src/can.cpp index d3ae734..4ee2e40 100644 --- a/src/can.cpp +++ b/src/can.cpp @@ -595,7 +595,7 @@ int obd2_process(const can_frame &frame, bike_data &log_data, const int can_s) } } - else if ( obd2Request.mode == 53u ) { // Custom Service + else if ( obd2Request.mode == 0x35 ) { // Custom Service switch (obd2Request.pid) { case 1u: { _status = EXIT_SUCCESS; @@ -664,6 +664,27 @@ int obd2_process(const can_frame &frame, bike_data &log_data, const int can_s) } break; + case 4u: { + _status = EXIT_SUCCESS; + error_message(DEBUG, "OBD2: Trip A"); + struct can_frame _response; + uint32_t fixed_trip ( log_data.trip * 1.609344 / 10.0 ); // convert to tenths (0.1) + _response.data[0]= 6u; + _response.data[1]= 0x75; // Custom Service + _response.data[2]= 4u; // Custom PID + _response.data[3]= fixed_trip >> 24 ; + _response.data[4]= fixed_trip >> 16 ; + _response.data[5]= fixed_trip >> 8 ; + _response.data[6]= fixed_trip ; + _response.can_dlc = 8; + _response.can_id = OBD2_OBD2_FRAME_ID; + if (write(can_s, &_response, sizeof(struct can_frame)) != sizeof(struct can_frame)) { + error_message(ERROR, "OBD2: Response Write failed"); + return EXIT_FAILURE; + } + } + break; + default: error_message(WARN, "WARN:Unknown OBD2 MODE:PID: %X:%X", obd2Request.mode, obd2Request.pid); } diff --git a/src/main.cpp b/src/main.cpp index 0ba6698..d66d82f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -986,7 +986,7 @@ int main(int argc, char *argv[]) log_data.alt_rpm = enData.rpm; log_data.speed = enData.speed; log_data.odometer = enData.odometer; - log_data.trip = enData.trip; + log_data.trip = (log_data.odometer - enData.trip) ; //enData.trip marks trip reset // log_data.systemvoltage = fcData.systemVoltage; log_data.batteryvoltage = enData.batteryVoltage; log_data.power = trailing_average_power(log_data);