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

Subject: Re: Parse Hex into signed number with streamdevice?
From: "Zimoch, Dirk via Tech-talk" <tech-talk at aps.anl.gov>
To: "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov>
Date: Mon, 15 Sep 2025 13:20:04 +0000
Hello Eddy

I have implemented your request. See latest commit 5ae38a08.
https://urldefense.us/v3/__https://github.com/paulscherrerinstitute/StreamDevice/commit/5ae38a08__;!!G_uCfscf7eWS!cAw9XzrsbzJkeIaTJbCHGITiBrLKBpAF9UPGNJsfAFSd7i_i4yL_A9_NL8SDU87mR-hs6DRqHgTTqdb0ORwuRDxFFQ$ 

Now, if using the + flag ("%+x" or "%+X"), the value will be interpreted as a
signed hex number. That means it will be sign extended if the most significant
hex digit is 8 or higher. But if width is given, width characters must have been
read:

in "%+x";  sign extends "80", " 9", "0xf", "abcd" but not "0x0f" or "0fed"
in "%+4x"; sign extends "abcd" and "0xf0" but not "abc" or "0xf"

Dirk


On Mon, 2025-09-15 at 10:28 +0200, Zimoch Dirk wrote:
> Hello Eddy
> 
> Signed %x input is currently not supported by StreamDevice but it is definitely
> useful to have. I have to think how to implement it and which flag to use to
> signal the switch from normal unsigned %x.
> 
> Dirk
> 
> On Mon, 2025-09-15 at 08:04 +0000, Blomley, Edmund (IBPT) via Tech-talk wrote:
> > Hey,
> >  
> > So my device sends me a 4 bit hex which I convert to a float using an ai record and linear conversion with ESLO.
> > Let’s ignore the conversion for now, the number needs to be treated as a signed long, so I need to get the 2’s complement:
> >  
> > 07D0 -> 2000
> > F6F5 -> -2315
> >  
> > Is there a way to do this directly with streamdevice?
> > If not, I would need to read in the raw long and convert it myself. What is the best approach to do the conversion with records?
> > So far I would do:
> >  
> > field(CALC, "65535 - A + 1") with A being the raw long.
> > Cheers
> > eddy
> >  

References:
Parse Hex into signed number with streamdevice? Blomley, Edmund (IBPT) via Tech-talk
Re: Parse Hex into signed number with streamdevice? Zimoch, Dirk via Tech-talk

Navigate by Date:
Prev: Re: Parse Hex into signed number with streamdevice? Zimoch, Dirk via Tech-talk
Next: Re: Parse Hex into signed number with 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
Navigate by Thread:
Prev: Re: Parse Hex into signed number with streamdevice? Zimoch, Dirk via Tech-talk
Next: Re: Parse Hex into signed number with 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
ANJ, 15 Sep 2025 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions ·
· Download · Search · IRMIS · Talk · Documents · Links · Licensing ·