Common mistakes
Informative
Pitfalls when using the LIN driver, and how to avoid them. Each maps to a rule in Lin — Requirements or an error in Errors.
Passing a real pointer to
Lin_Init.configPtrMUST beNULL_PTR— a non-null pointer raises a development error (CHI-LIN-MUST-16). The configuration is selected at build time.Calling
Lin_Wakeupon an operational channel. It is valid only inSLEEPand raisesLIN_DEVERR_INVALID_CH_STATE(CHI-LIN-MUST-07). To go operational without a pulse (e.g. after an external wakeup), useLin_WakeupInternal.Reacting on the wrong PID.
LinIf_OnHeaderfires for every header on the bus; setreaction = LIN_REACTION_IGNOREfor frames you do not handle, or you will transmit or expect a response you should not.Keeping the callback buffer. The
sduPtrdata inLinIf_OnHeader/LinIf_OnReceptionis valid only until the callback returns (CHI-LIN-MUST-10). Copy what you need; do not stash the pointer.Wrong byte order. Response data maps byte 0 first (CHI-LIN-MUST-09); do not assume the driver reorders bytes.
Forgetting to service polled events. If a channel is configured for
Pollingyou must callLin_PollFunctioncyclically, or noLinIf_On*callback ever fires.Assuming a checksum model. Set
csper frame (LIN_CS_CLASSICorLIN_CS_ENHANCED) — a mismatch with the commander shows up asLIN_ERR_CHECKSUM.