• Control the baud rate of a LIN device

    This function calculates the optimal prescale and bitMap combination to achieve the closest possible baud rate to the target value. The calculation uses the formula: baudRate = 5_500_000 / (2^(prescale + 1) * bitMap)

    Parameters

    • baudRate: number

      The target baud rate (e.g., 19200, 9600)

    • Optionaldevice: string

      The optional device name when multiple devices are connected

    Returns Promise<number>

    • Returns a promise that resolves with the actual baud rate achieved

    This function is only available on LinCable devices (https://app.whyengineer.com/docs/um/hardware/lincable.html)

    The function automatically calculates the best combination of: - lincableCustomBaudRatePrescale (range: 0-7, corresponding to /2, /4, /8, /16, /32, /64, /128, /256) - lincableCustomBaudRateBitMap (range: 1-32) to minimize the difference between target and actual baud rate.

    // Set baud rate to 19200
    const actualBaudRate = await linBaudRateCtrl(19200);
    console.log(`Actual baud rate: ${actualBaudRate}`);

    // Set baud rate on specific device
    const actualBaudRate = await linBaudRateCtrl(9600, 'Device1');