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: Florian Feldbauer <[email protected]>
To: Kevin Peterson <[email protected]>, EPICS tech talk <[email protected]>
Date: Thu, 10 Mar 2016 17:39:03 +0100
Hey Kevin,

I had the same problem once with a HV power supply.
I solved the problem this way:

- Read the value via StreamDevice into a longin record
- Use a sub-record to convert 32bit-int to 32bit-float

The subroutine is quiet easy:

union ficonv{
  float float_val;
  unsigned int  int_val;
};

static long intToFloat(subRecord *prec) {
  union ficonv myconf;
myconf.int_val = prec->a;
prec->b = myconf.float_val;
return 0;
}

I hope this helps!

Cheers
Florian

On 03/10/2016 05:28 PM, Kevin Peterson 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


--
----------------------------------------
| Dr. Florian Feldbauer                |
|                                      |
| Helmholtz-Institut Mainz /           |
| Johannes Gutenberg-Universität Mainz |
| Johann-Joachim-Becher-Weg 36         |
| D-55128 Mainz                        |
|                                      |
| Office: SB1 / 00-213                 |
| Phone:  (+49)6131 / 39-29608         |
----------------------------------------


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: stream protocol question: ASCII hex to 32-bit float Kevin Peterson
Next: Re: stream protocol question: ASCII hex to 32-bit float Eric Norum
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: 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 ·