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 f338ac0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 8 additions & 0 deletions firmware/can.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,14 @@ void InitCan()

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

if (ch == 0)
{
counter++;
}

const auto& sampler = GetSampler(ch);
const auto& heater = GetHeaterController(ch);

Expand All @@ -158,6 +164,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,6 +177,7 @@ 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;
}
}

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 f338ac0

Please sign in to comment.