Only big endian order (ABCD) or little endian (DCBA) but no mixed endian (CDBA
or BACD).
On Thu, 2026-01-08 at 20:09 +0800, 高振华 wrote:
> Hi Dirk,
> Could "%#.4R" convert the 4-byte value 40 49 99 9A (in hexadecimal, big-endian order, ABCD order) corresponding to 3.15 into 99 9A 40 49 (in CDAB order)?
>
> Thanks,
>
> Gao Zhenhua
>
> > -----原始邮件-----
> > 发件人: "Zimoch, Dirk" <dirk.zimoch at psi.ch>
> > 发送时间:2026-01-08 16:33:27 (星期四)
> > 收件人: "gaozh at ihep.ac.cn" <gaozh at ihep.ac.cn>, "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov>
> > 主题: Re: The problem of converting floating-point numbers to 4-byte format (in CDAB order) under StreamDevice
> >
> > 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!eQZ-R8PHyYm1v6bxt6-dkwcOhSq6hFA0xrVo9m-OUXD8wd_6zt0IEWHiuhyUR9YeiW8a-z6p1V0PNvlT30JqNdwpGw$
> >
> > BTW: The Modbus checksum is "%<modbus>".
> > https://urldefense.us/v3/__https://paulscherrerinstitute.github.io/StreamDevice/formats.html*chksum__;Iw!!G_uCfscf7eWS!eQZ-R8PHyYm1v6bxt6-dkwcOhSq6hFA0xrVo9m-OUXD8wd_6zt0IEWHiuhyUR9YeiW8a-z6p1V0PNvlT30JDfk-0lA$
> >
> >
> > 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
> > >
> > >
>
> ------------------------------
>
> 祝好!
> 高振华
>
> 电话:010-88235426
> 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 Zimoch, Dirk via Tech-talk
- References:
- The problem of converting floating-point numbers to 4-byte format (in CDAB order) under StreamDevice 高振华 via Tech-talk
- Re: The problem of converting floating-point numbers to 4-byte format (in CDAB order) under StreamDevice Zimoch, Dirk via Tech-talk
- Re: Re: 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: 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 Zimoch, Dirk 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: 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 Zimoch, Dirk 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>
|