This commit is contained in:
rusefillc 2021-12-21 01:17:02 -05:00
parent 4ad1f887fd
commit a2bf7616ae
3 changed files with 8 additions and 6 deletions

View File

@ -61,7 +61,7 @@ bool acceptCanRx(int sid) {
/** /**
* this build-in CAN sniffer is very basic but that's our CAN sniffer * this build-in CAN sniffer is very basic but that's our CAN sniffer
*/ */
static void printPacket(const CANRxFrame &rx) { static void printPacket(const size_t busIndex, const CANRxFrame &rx) {
bool accept = acceptCanRx(CAN_SID(rx)); bool accept = acceptCanRx(CAN_SID(rx));
if (!accept) { if (!accept) {
return; return;
@ -70,7 +70,9 @@ static void printPacket(const CANRxFrame &rx) {
// only print info if we're in can debug mode // 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 // internet people use both hex and decimal to discuss packed IDs, for usability it's better to print both right here
efiPrintf("CAN_rx %x(%d) %d: %02x %02x %02x %02x %02x %02x %02x %02x", CAN_SID(rx), efiPrintf("CAN_rx bus=%d %x(%d) %d: %02x %02x %02x %02x %02x %02x %02x %02x",
busIndex,
CAN_SID(rx),
CAN_SID(rx), rx.DLC, rx.data8[0], rx.data8[1], rx.data8[2], rx.data8[3], CAN_SID(rx), 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]); rx.data8[4], rx.data8[5], rx.data8[6], rx.data8[7]);
@ -160,7 +162,7 @@ static void processCanRxImu(const CANRxFrame& frame, efitick_t nowNt) {
void processCanRxMessage(const size_t busIndex, const CANRxFrame &frame, efitick_t nowNt) { void processCanRxMessage(const size_t busIndex, const CANRxFrame &frame, efitick_t nowNt) {
if (engineConfiguration->verboseCan) { if (engineConfiguration->verboseCan) {
printPacket(frame); printPacket(busIndex, frame);
} }
serviceCanSubscribers(frame, nowNt); serviceCanSubscribers(frame, nowNt);
@ -172,7 +174,7 @@ void processCanRxMessage(const size_t busIndex, const CANRxFrame &frame, efitick
// todo: convert to CanListener or not? // todo: convert to CanListener or not?
processCanRxImu(frame, nowNt); processCanRxImu(frame, nowNt);
processLuaCan(frame); processLuaCan(busIndex, frame);
#if EFI_CANBUS_SLAVE #if EFI_CANBUS_SLAVE
if (CAN_EID(frame) == engineConfiguration->verboseCanBaseAddress + CAN_SENSOR_1_OFFSET) { if (CAN_EID(frame) == engineConfiguration->verboseCanBaseAddress + CAN_SENSOR_1_OFFSET) {

View File

@ -28,7 +28,7 @@ chibios_rt::Mailbox<CANRxFrame*, canFrameCount> freeBuffers;
// CAN frame buffers that are waiting to be processed by the lua thread // CAN frame buffers that are waiting to be processed by the lua thread
chibios_rt::Mailbox<CANRxFrame*, canFrameCount> filledBuffers; chibios_rt::Mailbox<CANRxFrame*, canFrameCount> filledBuffers;
void processLuaCan(const CANRxFrame& frame) { void processLuaCan(const size_t busIndex, const CANRxFrame& frame) {
// Filter the frame if we aren't listening for it // Filter the frame if we aren't listening for it
if (!shouldRxCanFrame(frame)) { if (!shouldRxCanFrame(frame)) {
return; return;

View File

@ -62,5 +62,5 @@ void addLuaCanRxFilter(int32_t eid);
// Called from the Lua loop to process any pending CAN frames // Called from the Lua loop to process any pending CAN frames
void doLuaCanRx(LuaHandle& ls); void doLuaCanRx(LuaHandle& ls);
// Called from the CAN RX thread to queue a frame for Lua consumption // Called from the CAN RX thread to queue a frame for Lua consumption
void processLuaCan(const CANRxFrame& frame); void processLuaCan(const size_t busIndex, const CANRxFrame& frame);
#endif // not EFI_CAN_SUPPORT #endif // not EFI_CAN_SUPPORT