parent
e7895f80d5
commit
5f964aa9dd
|
@ -11,7 +11,8 @@
|
|||
#include "global.h"
|
||||
#include "engine.h"
|
||||
|
||||
EXTERN_ENGINE;
|
||||
EXTERN_ENGINE
|
||||
;
|
||||
|
||||
typedef float fsio_table_8x8_f32t_linear[FSIO_TABLE_8 * FSIO_TABLE_8];
|
||||
|
||||
|
@ -20,17 +21,17 @@ bool acceptCanRx(int sid DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
|||
// accept anything if filtering is not enabled
|
||||
return true;
|
||||
}
|
||||
/*
|
||||
// the whole table reuse and 2D table cast to 1D array is a major hack, but it's OK for prototyping
|
||||
|
||||
|
||||
fsio_table_8x8_f32t_linear * array = (fsio_table_8x8_f32t_linear *)(void*)&config->fsioTable1;
|
||||
fsio_table_8x8_f32t_linear *array =
|
||||
(fsio_table_8x8_f32t_linear*) (void*) &config->fsioTable1;
|
||||
|
||||
int arraySize = efi::size(*array);
|
||||
|
||||
int showOnlyCount = (int)array[arraySize - 1];
|
||||
if (showOnlyCount > 0) {
|
||||
for (int i = 0;i<showOnlyCount;i++) {
|
||||
if (sid == (int)array[arraySize - 2 - i]) {
|
||||
int showOnlyCount = (int) array[arraySize - 1];
|
||||
if (showOnlyCount > 0 && showOnlyCount < arraySize) {
|
||||
for (int i = 0; i < showOnlyCount; i++) {
|
||||
if (sid == (int) array[arraySize - 2 - i]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -38,15 +39,16 @@ bool acceptCanRx(int sid DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
int ignoreListCount = (int)array[0];
|
||||
for (int i = 0;i<ignoreListCount;i++) {
|
||||
if (sid == (int)array[1 + i]) {
|
||||
// element is in ignore list
|
||||
return false;
|
||||
int ignoreListCount = (int) array[0];
|
||||
if (ignoreListCount > 0 && ignoreListCount < arraySize) {
|
||||
for (int i = 0; i < ignoreListCount; i++) {
|
||||
if (sid == (int) array[1 + i]) {
|
||||
// element is in ignore list
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -61,7 +63,7 @@ bool acceptCanRx(int sid DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
|||
/**
|
||||
* this build-in CAN sniffer is very basic but that's our CAN sniffer
|
||||
*/
|
||||
static void printPacket(const CANRxFrame& rx, Logging* logger) {
|
||||
static void printPacket(const CANRxFrame &rx, Logging *logger) {
|
||||
bool accept = acceptCanRx(rx.SID);
|
||||
if (!accept) {
|
||||
return;
|
||||
|
@ -70,31 +72,32 @@ static void printPacket(const CANRxFrame& rx, Logging* logger) {
|
|||
// only print info if we're in can debug mode
|
||||
|
||||
// internet people use both hex and decimal to discuss packed IDs, for usability it's better to print both right here
|
||||
scheduleMsg(logger, "CAN_rx %x %d %x, %x %x %x %x %x %x %x %x", rx.SID, rx.SID, rx.DLC,
|
||||
rx.data8[0], rx.data8[1],
|
||||
rx.data8[2], rx.data8[3], rx.data8[4], rx.data8[5], rx.data8[6], rx.data8[7]);
|
||||
scheduleMsg(logger, "CAN_rx %x %d %x, %x %x %x %x %x %x %x %x", rx.SID,
|
||||
rx.SID, rx.DLC, rx.data8[0], rx.data8[1], rx.data8[2], rx.data8[3],
|
||||
rx.data8[4], rx.data8[5], rx.data8[6], rx.data8[7]);
|
||||
|
||||
}
|
||||
|
||||
volatile float canMap = 0;
|
||||
|
||||
CanSensorBase* cansensors_head = nullptr;
|
||||
CanSensorBase *cansensors_head = nullptr;
|
||||
|
||||
void serviceCanSubscribers(const CANRxFrame& frame, efitick_t nowNt) {
|
||||
CanSensorBase* current = cansensors_head;
|
||||
void serviceCanSubscribers(const CANRxFrame &frame, efitick_t nowNt) {
|
||||
CanSensorBase *current = cansensors_head;
|
||||
|
||||
while (current) {
|
||||
current = current->processFrame(frame, nowNt);
|
||||
}
|
||||
}
|
||||
|
||||
void registerCanSensor(CanSensorBase& sensor) {
|
||||
void registerCanSensor(CanSensorBase &sensor) {
|
||||
sensor.setNext(cansensors_head);
|
||||
cansensors_head = &sensor;
|
||||
sensor.Register();
|
||||
}
|
||||
|
||||
void processCanRxMessage(const CANRxFrame& frame, Logging* logger, efitick_t nowNt) {
|
||||
void processCanRxMessage(const CANRxFrame &frame, Logging *logger,
|
||||
efitick_t nowNt) {
|
||||
if (CONFIG(debugMode) == DBG_CAN) {
|
||||
printPacket(frame, logger);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue