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: CA Gateway converts int/float value to hex |
From: | "Johnson, Andrew N. via Tech-talk" <tech-talk at aps.anl.gov> |
To: | "andrej.manojlovic at cosylab.com" <andrej.manojlovic at cosylab.com> |
Cc: | EPICS tech-talk <tech-talk at aps.anl.gov> |
Date: | Wed, 28 Jul 2021 23:34:57 +0000 |
Hi Andrej,
On Jul 28, 2021, at 3:41 PM, andrej.manojlovic--- via Tech-talk <tech-talk at aps.anl.gov> wrote:
Interesting, I agree that this is strange behavior.
It is happening because caput sends the value as a string, and the gateway is apparently converting the string to a double to match the target PV before forwarding the put operation. Unfortunately the C++ code in what I assume is the gateway’s conversion
routine (in pcas/src/gdd/aitConvert.cc) looks like this:
The epicsScanDouble() call returns 0 if there any extraneous characters are found in the string, and in that case the code tries again using the “%x” format, and as long as that manages to convert some of the string it accepts the hex version. An older
version of this code (pre-2004) called sscanf() with a “%lf” format instead of using epicsScanDouble(). With that version extraneous characters would not have caused the first conversion attempt to fail, so the hex conversion would not have been attempted.
The switch to epicsScanDouble() happened in this commit to the pcas module:
At that time some EPICS architectures (probably Windows) didn’t convert Inf and Nan properly, so I can understand
why the change was done, but I suspect it could be undone here (the other changes in the same commit were outside of the pcas & gdd code).
At this point Ralph Lange will need to comment and decide what to do about this, and in the meantime you could undo that change, rebuild the gateway and report back whether that fixes the problem.
Thanks for the bug report!
- Andrew
--
Complexity comes for free, simplicity you have to work for.
|