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. configPtr MUST be NULL_PTR — a non-null pointer raises a development error (CHI-LIN-MUST-16). The configuration is selected at build time.

  • Calling Lin_Wakeup on an operational channel. It is valid only in SLEEP and raises LIN_DEVERR_INVALID_CH_STATE (CHI-LIN-MUST-07). To go operational without a pulse (e.g. after an external wakeup), use Lin_WakeupInternal.

  • Reacting on the wrong PID. LinIf_OnHeader fires for every header on the bus; set reaction = LIN_REACTION_IGNORE for frames you do not handle, or you will transmit or expect a response you should not.

  • Keeping the callback buffer. The sduPtr data in LinIf_OnHeader / LinIf_OnReception is 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 Polling you must call Lin_PollFunction cyclically, or no LinIf_On* callback ever fires.

  • Assuming a checksum model. Set cs per frame (LIN_CS_CLASSIC or LIN_CS_ENHANCED) — a mismatch with the commander shows up as LIN_ERR_CHECKSUM.