• Sets a "pending transmit" handler for CAN messages used by jobs/diagnostics.

    Allows test frameworks or diagnostic jobs to temporarily override outgoing CAN message transmission. The provided callback is invoked before each CAN transmit.

    Parameters

    • func: (
          msg: CanMessage,
      ) =>
          | undefined
          | Buffer<ArrayBufferLike>
          | Promise<undefined | Buffer<ArrayBufferLike>>

      Callback taking a CanMessage and returning:

      • a Buffer (to override and send as transmit data),
      • msg.data (to send the message unchanged),
      • undefined (to suppress/disable this transmission),
      • or a Promise resolving to any of the above.

    Returns void

    setTxPending(async (msg) => {
    // E2E test: intercept message with ID 0x200
    if (msg.id === 0x200) {
    // Replace transmit data for E2E injection
    return Buffer.from([0xE2, 0xE2, 0xCA, 0xT1]);
    }
    // Block this transmission (do not send)
    return undefined;
    });
    setTxPending((msg) => {
    // Only log, transmit as usual
    console.log("CAN TX:", msg);
    return msg.data; // will not alter data
    });