Skip to content

Commit

Permalink
https://github.com/rusefi/rusefi/issues/6997
Browse files Browse the repository at this point in the history
array of classes not array inside class
  • Loading branch information
rusefillc committed Oct 23, 2024
1 parent 80c3d52 commit bb935a9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 22 deletions.
12 changes: 8 additions & 4 deletions SENT-box/firmware/sent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static struct sent_channel channels[SENT_CHANNELS_NUM];
int32_t si7215_magnetic[SENT_CHANNELS_NUM];
int32_t si7215_counter[SENT_CHANNELS_NUM];

SentGmFuelSensor sentGmFuelSensor;
SentGmFuelSensor sentGmFuelSensor[SENT_CHANNELS_NUM];

#if SENT_DEV == SENT_GM_ETB

Expand Down Expand Up @@ -481,16 +481,20 @@ static void SentDecoderThread(void*)
if (1) {
/* Sig0 occupie first 3 nibbles in MSB..LSB order
* Sig1 occupit next 3 nibbles in LSB..MSB order */
sentGmFuelSensor.gm_sig0[channleIndex] =
int32_t gm_sig0 =
(ch->nibbles[1 + 0] << 8) |
(ch->nibbles[1 + 1] << 4) |
(ch->nibbles[1 + 2] << 0);
sentGmFuelSensor.gm_sig1[channleIndex] =
int32_t gm_sig1 =
(ch->nibbles[1 + 3] << 0) |
(ch->nibbles[1 + 4] << 4) |
(ch->nibbles[1 + 5] << 8);
sentGmFuelSensor.gm_stat[channleIndex] =
int32_t gm_stat =
ch->nibbles[0];

sentGmFuelSensor[channleIndex].gm_sig0 = gm_sig0;
sentGmFuelSensor[channleIndex].gm_sig1 = gm_sig1;
sentGmFuelSensor[channleIndex].gm_stat = gm_stat;
}
}
}
Expand Down
26 changes: 11 additions & 15 deletions SENT-box/firmware/sent_gm_fuel_sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,24 @@ class SentGmFuelSensor {
public:

/* GM DI fuel pressure, temperature sensor decoded data */
int32_t gm_sig0[SENT_CHANNELS_NUM];
int32_t gm_sig1[SENT_CHANNELS_NUM];
int32_t gm_stat[SENT_CHANNELS_NUM];
int32_t gm_sig0;
int32_t gm_sig1;
int32_t gm_stat;

/* GM DI fuel pressure, temperature sensor data */
int32_t gm_GetSig0(uint32_t n)
{
return gm_sig0[n];
int32_t gm_GetSig0() {
return gm_sig0;
}

int32_t gm_GetSig1(uint32_t n)
{
return gm_sig1[n];
int32_t gm_GetSig1() {
return gm_sig1;
}

int32_t gm_GetStat(uint32_t n)
{
return gm_stat[n];
int32_t gm_GetStat() {
return gm_stat;
}

int32_t gm_GetPressure(uint32_t n)
{
int32_t gm_GetPressure() {
/* two pressure signals:
* Sig0 occupie 3 first nibbles in MSB..LSB order
* Sig1 occupit next 3 nibbles in LSB..MSB order
Expand All @@ -45,7 +41,7 @@ int32_t gm_GetPressure(uint32_t n)
*/

/* in 0.001 Atm */
return ((gm_GetSig0(n) - 198 + 10 + gm_GetSig1(n) - 202 + 10) * 100 / 2);
return ((gm_GetSig0() - 198 + 10 + gm_GetSig1() - 202 + 10) * 100 / 2);
}

};
7 changes: 4 additions & 3 deletions SENT-box/firmware/uart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "mcu-util.h"
#include "sent_gm_fuel_sensor.h"

extern SentGmFuelSensor sentGmFuelSensor;
extern SentGmFuelSensor sentGmFuelSensor[SENT_CHANNELS_NUM];

static const UARTConfig uartCfg =
{
Expand Down Expand Up @@ -71,10 +71,11 @@ static void UartThread(void*)
SENT_GetFrameCnt(0)
);
#else
uint32_t gm_pressure = sentGmFuelSensor.gm_GetPressure(0);
uint32_t gm_pressure = sentGmFuelSensor[0].gm_GetPressure();
writeCount += chsnprintf(printBuffer + writeCount, BUFFER_SIZE - writeCount,
" GM: St %x, Sig0 %04d, Sig1 %04d, %d.%03d Atm Tick = %04d nS.\r\n",
sentGmFuelSensor.gm_GetStat(0), sentGmFuelSensor.gm_GetSig0(0), sentGmFuelSensor.gm_GetSig1(0), gm_pressure / 1000, gm_pressure % 1000,
sentGmFuelSensor[0].gm_GetStat(), sentGmFuelSensor[0].gm_GetSig0(),
sentGmFuelSensor[0].gm_GetSig1(), gm_pressure / 1000, gm_pressure % 1000,
SENT_GetTickTimeNs()
);

Expand Down

0 comments on commit bb935a9

Please sign in to comment.