• humanspiral@lemmy.ca
    link
    fedilink
    arrow-up
    2
    ·
    edit-2
    9 hours ago

    0 based indexing of course, so what’s the joke? oh, mixing up count and max index is a hardship you get over after a couple of years, but it comes back sometimes.

    • RustySharp@programming.dev
      link
      fedilink
      arrow-up
      1
      ·
      54 minutes ago

      The more you move through the networking stack, the more you start seeing OB1 error potentials.

      Many protocols have packet ids starting from (and wrapping back to) 1. Modbus registers start from 1, but stored in memory offset 0.

      Packet lengths can either include or exclude the length itself. E.g. packet length 200 in a protocol could either mean the length is followed by 200 bytes of data; or 1 byte containing the length + 199 data; or even 4 bytes length + 196 data (off by four!)

      It’s a wild world out there.