EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

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 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
<== Date ==> <== Thread ==>

Subject: Re: Re: Re: The problem of converting floating-point numbers to 4-byte format (in CDAB order) under StreamDevice
From: 高振华 via Tech-talk <tech-talk at aps.anl.gov>
To: "Zimoch, Dirk" <dirk.zimoch at psi.ch>
Cc: "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov>
Date: Fri, 9 Jan 2026 09:32:51 +0800 (GMT+08:00)
OK, I see. Thanks a lot, Dirk.

Gao Zhenhua


> -----原始邮件-----
> 发件人: "Zimoch, Dirk" <dirk.zimoch at psi.ch>
> 发送时间:2026-01-08 20:40:19 (星期四)
> 收件人: "gaozh at ihep.ac.cn" <gaozh at ihep.ac.cn>
> 抄送: "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov>
> 主题: Re: Re: The problem of converting floating-point numbers to 4-byte format (in CDAB order) under StreamDevice
> 
> On Thu, 2026-01-08 at 13:38 +0100, Zimoch Dirk wrote:
> > Only big endian order (ABCD) or little endian (DCBA) but no mixed endian (CDBA
> > or BACD).
> 
> I mean: no mixed (CDAB or BADC).
> 
> > 
> > 
> > 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!e6Db1wUpZwLKEdt4Sf3GvbfQpETHTiAVjjTZu-3NmFgaMIYYBco4kIE8w8TlHedTV2ZRuI5H7b2zA8mqLYBa$ 
> > > > 
> > > > BTW: The Modbus checksum is "%<modbus>".
> > > > https://urldefense.us/v3/__https://paulscherrerinstitute.github.io/StreamDevice/formats.html*chksum__;Iw!!G_uCfscf7eWS!e6Db1wUpZwLKEdt4Sf3GvbfQpETHTiAVjjTZu-3NmFgaMIYYBco4kIE8w8TlHedTV2ZRuI5H7b2zA22IV1pO$ 
> > > > 
> > > > 
> > > > 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
> > >


------------------------------
      
祝好!
高振华

电话:010-88235426
Email:gaozh at ihep.ac.cn


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
Re: 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 Zimoch, Dirk via Tech-talk

Navigate by Date:
Prev: RE: problems with SNL - sevr=minor ca_array_get_callback [...]: Virtual circuit disconnect Žiga Oven via Tech-talk
Next: The motor module is unable to control the PM600 motor. LONG FENG 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 Zimoch, Dirk via Tech-talk
Next: Gatan K3 Camera EPICS Support? Foster, Andrew (OBS,RAL,TEC) 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
ANJ, 19 Mar 2026 · Home · News · About · Talk · Base · Modules · Extensions ·
· Distributions · Download · Documents · Links · Licensing ·