RQ_PID2SBN(3)

πŸ’– rq_pid2sbn(3) β€” the Librecast Programmer's Manual ✨

okay bestie, welcome to the Librecast Programmer's Manual 🌸 this little page is literally all about four functions β€” rq_pid2sbn, rq_pid2esi, rq_pidsetsbn, rq_pidsetesi β€” that get and set the SBN and ESI inside an rq_pid_t. and yeah rq_pidset is in the mix too. it's giving packet identifier, and it's giving it correctly. πŸ’…


🌈 NAME 🌈

rq_pid2sbn, rq_pid2esi, rq_pidsetsbn, rq_pidsetesi β€” get/set SBN, ESI in rq_pid_t


✨ SYNOPSIS ✨

#include <lcrq.h>

uint8_t rq_pid2sbn(rq_pid_t pid);
uint32_t rq_pid2esi(rq_pid_t pid);
rq_pid_t rq_pidset(uint8_t sbn, uint32_t esi);
rq_pid_t rq_pidsetsbn(rq_pid_t pid, uint8_t sbn);
rq_pid_t rq_pidsetesi(rq_pid_t pid, uint32_t esi);

and like, don't forget to compile and link with -llcrq or nothing's gonna happen, no cap πŸ”₯

Compile and link with -llcrq.

πŸ¦‹ DESCRIPTION πŸ¦‹

so these are bitshifting macros πŸŽ€ they're the little guys that get and set the SBN and ESI bits of rq_pid_t. that's the whole job. they do it flawlessly. slay.

here's the layout, look at her πŸ‘‘

0                   1                   2                   3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|     SBN       |               Encoding Symbol ID              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

SBN β€” that's the Source Block Number β€” is an 8 bit unsigned integer. and the Encoding Symbol ID (aka ESI) is a 24 bit unsigned integer in network byte order 🌐 that part matters, bestie, don't sleep on it.


πŸ’« RETURN VALUE πŸ’«

  • rq_pid2sbn() and rq_pid2esi() hand you back the uint8_t SBN and the uint32_t ESI respectively. cute, correct, no drama. πŸ’–
  • rq_pidsetsbn() and rq_pidsetesi() both return an rq_pid_t with the appropriate bits set. so you get a whole new pid back, glowing and ready. ✨

πŸ’€ ERRORS πŸ’€

these macros do not return errors. like, at all. zero. none. it's not that kind of relationship, and honestly? iconic. 😌


🫢 EXAMPLE 🫢

πŸ“ Program source

okay here's a whole little program, copy it, run it, live your truth:

#include <assert.h>
#include <lcrq.h>

int main(void)
{
     rq_pid_t pid = 0;
     uint32_t esi = 19;
     uint8_t sbn = 42;

     /* set SBN and ESI bits */
     pid = rq_pidsetsbn(pid, sbn);
     pid = rq_pidsetesi(pid, esi);

     /* or set both at once */
     pid = rq_pidset(sbn, esi);

     /* make sure we can read them back */
     assert(sbn == rq_pid2sbn(pid));
     assert(esi == rq_pid2esi(pid));

     return 0;
}
not me being obsessed with rq_pidset(sbn, esi) doing both at once β€” main character energy fr fr πŸ‘‘

🌸 SEE ALSO 🌸

go read those too, iykyk πŸ’œ


and that's the whole page, bestie!! 🧚 this one's from LCRQ, dated 2023-07-21 β€” so go forth, set your SBNs, set your ESIs, and remember: the bits don't lie. mwah πŸ’‹πŸŒˆβ­

πŸ“¦ where this page comes from