MODBUS_GET_FLOAT_BAD(3)

πŸ“¦
version 3.1.6 Β· 3 versions
, in debian bookworm

πŸ’– MODBUS_GET_FLOAT_BAD(3) πŸ’–

okay bestie, so this one is a page from the libmodbus Manual, section 3, and it's about a little function called modbus_get_float_badc. she's niche, she's specific, and she's here to decode your byte-swapped float drama. let's get into it ✨


🌸 NAME 🌸

modbus_get_float_badc β€” get a float value from 2 registers in BADC byte order πŸ¦‹


✨ SYNOPSIS ✨

float modbus_get_float_badc(const uint16_t *src);

πŸ’… DESCRIPTION πŸ’…

okay so the way that modbus_get_float_badc() works is: it shall get a float from 4 bytes, but with the bytes swapped β€” it's giving BADC instead of ABCD. not the usual order, not the mainstream order, and honestly? iconic for that πŸ’…

the src array must be a pointer on two 16-bit values. no cap, it has to be two of them. so like, for example, if the first word is set to 0x2000 and the second to 0x47F1, then the float value will be read as 123456.0. slay. that's it, that's the whole trick πŸŽ€


🫢 RETURN VALUE 🫢

the function shall return a float. that's her whole job, and she does it well πŸ‘‘


πŸ”₯ SEE ALSO πŸ”₯

go read the whole float family bestie, they're all sisters 🌈


πŸ’œ AUTHORS πŸ’œ

the libmodbus documentation was written by StΓ©phane Raimbault <stephane.raimbault@gmail.com>. thank you legend, we owe you our lives fr fr πŸ™


and that's a wrap, bestie!! this whole page came to you from libmodbus v3.1.6, dated 11/17/2025. byte-swapped floats could never confuse us now πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from