Experimental Physics and
| |||||||||||||||||
|
Hi Andrew, thanks for your help. Replacing epicsScanDouble() with sscanf() does fix the problem. I'm not sure if this change will break any other Gateway functionality relying on the use of epicsScanDouble(). I'll follow up with a new issue on Github. Thanks, Andrej From: "Johnson, Andrew N." <anj at anl.gov> To: "andrej manojlovic" <andrej.manojlovic at cosylab.com> Cc: "tech-talk" <tech-talk at aps.anl.gov> Sent: Thursday, July 29, 2021 1:34:57 AM Subject: Re: CA Gateway converts int/float value to hex
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.
| ||||||||||||||||
ANJ, 25 Aug 2021 |
·
Home
·
News
·
About
·
Base
·
Modules
·
Extensions
·
Distributions
·
Download
·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing · |