@flux-control/effect-modbus-rs
    Preparing search index...

    Function planWrites

    • Packs register writes into the fewest transactions that cover them.

      The planner sorts by address, groups contiguous addresses into runs, splits each run at maxRegistersPerWrite, and emits FC16 for a run of at least minRunLength registers or FC06 for anything shorter.

      When the same address appears more than once, the last write wins. This matches a caller that supersedes a pending value rather than queueing behind it, and it is the only rule under which the plan is order-independent for distinct addresses.

      Parameters

      Returns readonly WritePlanStep[]

      Transactions to issue, in ascending address order.

      RangeError - An address, a value, or an option is out of range.

      // 2000..2003 contiguous, 2010 alone
      planWrites([
      { address: 2003, value: 40 },
      { address: 2000, value: 10 },
      { address: 2010, value: 99 },
      { address: 2001, value: 20 },
      { address: 2002, value: 30 },
      ]);
      // [
      // { kind: 'multiple', address: 2000, values: Uint16Array [10, 20, 30, 40] },
      // { kind: 'single', address: 2010, value: 99 },
      // ]