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  <20162017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: stream protocol question: ASCII hex to 32-bit float
From: Eric Norum <[email protected]>
To: Kevin Peterson <[email protected]>
Cc: EPICS tech talk <[email protected]>
Date: Thu, 10 Mar 2016 09:03:41 -0800
If you don’t need to worry about NaNs or Infinities I think that this calc record will do what you need:

record(calc, "floatMap") {
    field(A, "0x3F800000")
    field(CALC, "B:=A?((A&0x7FFFFF)+0x800000)*2**(((A>>23)&255)-150):0;A&0x80000000?-B:B")
}


On Mar 10, 2016, at 8:28 AM, Kevin Peterson <[email protected]> wrote:

I have a helium sensor that responds to a query with this reply:

 :80gv<VVVVVVVV><FFFFFFFF><CCCC><cr>

Where the non-constant parts of the response are ASCII hex characters
representing the following values:

 <VVVVVVVV> = (32 bit floating point) The current gas value
 <FFFFFFFF> = (32 bit unsigned integer) The sensor status
 <CCCC> = (16 bit unsigned integer) The message checksum

Is there a straightforward way to parse the floating point value using
StreamDevice format converters?

The raw double converter %R doesn't work, presumably because it is
interpreting the ASCII chars as bytes, rather than hex values.

The value can be read as an int with %08X, but it isn't obvious how to
then cast that value as a float.

Thanks,

Kevin

--
Kevin M. Peterson
(630) 252-8644
[email protected]

-- 
Eric Norum
[email protected]





Replies:
Re: stream protocol question: ASCII hex to 32-bit float Kevin Peterson
References:
stream protocol question: ASCII hex to 32-bit float Kevin Peterson

Navigate by Date:
Prev: Re: stream protocol question: ASCII hex to 32-bit float Florian Feldbauer
Next: Re: mbbo/mbbi and bits subset Andrew Johnson
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: stream protocol question: ASCII hex to 32-bit float Kevin Peterson
Next: Re: stream protocol question: ASCII hex to 32-bit float Kevin Peterson
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 15 Jul 2016 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·