Hi Gao
As Mark already wrote, better use the dedicated Modbus driver, but for
completeness here is the answer: Use format "%.4R"
%R is the "floating point raw" format and can be used with precision .4 or .8
for float or double. By default it used big endian byte order but if needed that
can be changed to little endian with "%#.4R".
https://urldefense.us/v3/__https://paulscherrerinstitute.github.io/StreamDevice/formats.html*rawdouble__;Iw!!G_uCfscf7eWS!YPu7MZfgs8VAOm3wAtNSUfcy2Lr84r4_MbjAcI9J-ZBg0-qnnB1btmrlWdWX89n1qdeVmjWHYI1dThGj46br-EOfcQ$
BTW: The Modbus checksum is "%<modbus>".
https://urldefense.us/v3/__https://paulscherrerinstitute.github.io/StreamDevice/formats.html*chksum__;Iw!!G_uCfscf7eWS!YPu7MZfgs8VAOm3wAtNSUfcy2Lr84r4_MbjAcI9J-ZBg0-qnnB1btmrlWdWX89n1qdeVmjWHYI1dThGj46Z9g3_EMg$
Dirk
On Wed, 2026-01-07 at 17:53 +0800, 高振华 via Tech-talk wrote:
>
> Hi all,
>
>
>
> I am conducting Modbus RTU communication with a device and need to convert a 32-bit floating-point number into 4 bytes of hexadecimal data and then send it to the device.
>
> For example: 3.15 converted to 4 bytes is 40 49 99 9A (in hexadecimal, big-endian order, ABCD order).
>
> Using StreamDevice, how should I convert to the CDAB order? (For example, the CDAB order corresponding to 3.15 is 99 9A 40 49).
>
> Does StreamDevice have a corresponding conversion symbol?
>
>
>
>
> Best regards,
>
>
> Gao Zhenhua
>
>
> BSRF
>
> Email:gaozh at ihep.ac.cn
>
>
- Replies:
- Re: Re: The problem of converting floating-point numbers to 4-byte format (in CDAB order) under StreamDevice 高振华 via Tech-talk
- References:
- The problem of converting floating-point numbers to 4-byte format (in CDAB order) under StreamDevice 高振华 via Tech-talk
- Navigate by Date:
- Prev:
Re: Re: Re: The problem of converting floating-point numbers to 4-byte format (in CDAB order) under StreamDevice 高振华 via Tech-talk
- Next:
Re: Re: The problem of converting floating-point numbers to 4-byte format (in CDAB order) under StreamDevice 高振华 via Tech-talk
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
<2026>
- Navigate by Thread:
- Prev:
Re: Re: Re: The problem of converting floating-point numbers to 4-byte format (in CDAB order) under StreamDevice 高振华 via Tech-talk
- Next:
Re: Re: The problem of converting floating-point numbers to 4-byte format (in CDAB order) under StreamDevice 高振华 via Tech-talk
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
<2026>
|