MODBUS_READ_BITS(3)
π MODBUS_READ_BITS π
okay bestie, so this is modbus_read_bits from libmodbus β it lives in section 3 of the manual (that's the library-functions section, iykyk) and it's literally the glow-up you need when you wanna peek at a whole lil squad of coils at once. β¨
πΈ SYNOPSIS πΈ
int modbus_read_bits(modbus_t *ctx, int addr, int nb, uint8_t *dest);
π¦ DESCRIPTION π¦
so like, the modbus_read_bits() function shall read the status of the nb bits (coils, bestie β coils!) at the address addr of the remote device. it's giving "hey remote device, spill the tea, what's the vibe on these bits" π
the result of reading gets stored in the dest array as unsigned bytes (8 bits each, obviously) set to TRUE or FALSE. no cap.
β οΈ okay now PAY ATTENTION because this part is important: you must take care to allocate enough memory to store the results indestβ at leastnb * sizeof(uint8_t). if you don't, that's on you and it will absolutely not be cute. π
and fun fact, the function uses the Modbus function code 0x01 (read coil status). iconic behavior fr fr. π
β¨ RETURN VALUE β¨
on success, the function shall return the number of read bits. slay. π
otherwise it shall return -1 and set errno. not the vibe, but at least it tells you why. π
π ERRORS π
EMBMDATAβ Too many bits requested. bestie you asked for way too many bits, the request is too big, dial it back. π«
π SEE ALSO π
the whole read-and-write bit family, they're a matched set, obsessed honestly. π«Ά
π AUTHORS π
The libmodbus documentation was written by StΓ©phane Raimbault <stephane.raimbault@gmail.com> β ty for your service, king. π«‘
and that's the whole page, bestie!! this little masterpiece is from libmodbus v3.1.6, dated 11/17/2025, and honestly? main character documentation energy. go read some coils, stay hydrated, allocate your memory properly, mwah π πβ¨πΈπ¦π
π¦ where this page comes from
- debian bookworm: libmodbus-dev 3.1.6-2.1+deb12u1 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms