Skip to content

Commit

Permalink
Fix pc isotp rx issue
Browse files Browse the repository at this point in the history
  • Loading branch information
parai committed Jan 14, 2024
1 parent 236c207 commit 7e2cb15
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
11 changes: 11 additions & 0 deletions infras/communication/CanIf/CanIf.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,21 @@ void CanIf_RxIndication(const Can_HwType *Mailbox, const PduInfoType *PduInfoPtr
} else if (var->canid < Mailbox->CanId) {
l = m + 1;
} else {
/* TODO: add logic here to handle 2 or more CANs receive the message with the same CANID */
break; /* should not reach here */
}
}

#if defined(linux) || defined(_WIN32)
/* For the host PC tools, the CanIf table is not sorted */
for (l = 0; (l < config->numOfRxPdus) && (NULL == rxPdu); l++) {
var = &config->rxPdus[l];
if ((var->hoh == Mailbox->Hoh) && (var->canid == (Mailbox->CanId & var->mask))) {
rxPdu = var;
}
}
#endif

if (NULL != rxPdu) {
if (NULL != rxPdu->rxInd) {
rxPdu->rxInd(rxPdu->rxPduId, PduInfoPtr);
Expand Down
8 changes: 7 additions & 1 deletion tools/libraries/isotp/config/CanIf_Cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ const CanIf_ConfigType CanIf_Config = {
};

/* ================================ [ LOCALS ] ============================================== */
static void __attribute__((constructor)) _isotp_canif_init(void) {
int i;
for (i = 0; i < ARRAY_SIZE(CanIf_RxPdus); i++) {
CanIf_RxPdus[i].mask = 0xFFFFFFFF;
}
}
/* ================================ [ FUNCTIONS ] ============================================== */
void CanIf_CanTpReconfig(uint8_t Channel, CanTp_ParamType *params) {
CanIf_RxPdus[Channel].rxInd = CanTp_RxIndication;
Expand Down Expand Up @@ -53,4 +59,4 @@ uint32_t CanIf_CanTpGetTxCanId(uint8_t Channel) {

uint32_t CanIf_CanTpGetRxCanId(uint8_t Channel) {
return CanIf_RxPdus[Channel].canid;
}
}

0 comments on commit 7e2cb15

Please sign in to comment.