Skip to content

Commit

Permalink
can: add counter to last byte of StandartData and DiagData
Browse files Browse the repository at this point in the history
  • Loading branch information
dron0gus committed Dec 6, 2023
1 parent 72d5a0d commit ce172e0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions firmware/can.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ void InitCan()

void SendRusefiFormat(uint8_t ch)
{
uint8_t counter = 0;
auto baseAddress = WB_DATA_BASE_ADDR + 2 * (ch + configuration->CanIndexOffset);

const auto& sampler = GetSampler(ch);
Expand All @@ -158,6 +159,7 @@ void SendRusefiFormat(uint8_t ch)
bool heaterClosedLoop = heater.IsRunningClosedLoop();
bool nernstValid = nernstDc > (NERNST_TARGET - 0.1f) && nernstDc < (NERNST_TARGET + 0.1f);
frame.get().Valid = (heaterClosedLoop && nernstValid) ? 0x01 : 0x00;
frame.get().counter = counter;
}

{
Expand All @@ -170,7 +172,10 @@ void SendRusefiFormat(uint8_t ch)
frame.get().PumpDuty = GetPumpOutputDuty(ch) * 255;
frame.get().Status = GetCurrentFault(ch);
frame.get().HeaterDuty = GetHeaterDuty(ch) * 255;
frame.get().counter = counter;
}

counter++;
}

// Weak link so boards can override it
Expand Down
6 changes: 4 additions & 2 deletions for_rusefi/wideband_can.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ struct StandardData
uint16_t Lambda;
uint16_t TemperatureC;

uint16_t pad;
uint8_t pad;

uint8_t counter;
};

struct DiagData
Expand All @@ -63,7 +65,7 @@ struct DiagData
Fault Status;

uint8_t HeaterDuty;
uint8_t pad;
uint8_t counter;
};

static inline const char* describeFault(Fault fault) {
Expand Down

0 comments on commit ce172e0

Please sign in to comment.