On 10/2/22 03:29, Abdalla Ahmad via Tech-talk wrote:
Hi
I am trying to write an EPICS driver by using the device support model explained in the app developer guide.
Rather than spending a lot of time getting confused while
looking through the appdev guide, I would very much recommend
setting up GDB (or your debugger of choice), then placing a
break point in your code to see how it is reached. You could
then continue on to see how the return value is used.
imo. this is a great way to start with a large and unfamiliar
code base. I didn't learn about Base by reading the appdev
guide.
I attached a preliminary code for the ai record which only increments the record’s value by a value passed in the INP field. My question is, for the read_ai function I had to return 2 in order for the driver to work, otherwise the record’s value will not change. Why is that?
Ah, the magic "return 2"...
Firstly, with current Base 7.0, the aiRecord call into your
device support read function is made from the local readValue()
function.
https://github.com/epics-base/epics-base/blob/0f8ea3aa3671cb0433b4350020430a7740d6fdc6/modules/database/src/std/rec/aiRecord.c#L482
Which is called from the record support process() function,
where the magic number "2" is treated as success (like "0"),
but also bypasses calling the local convert() function.
status=readValue(prec); /* read the new value */
...
if (status==0) convert(prec);
else if (status==2) status=0;
https://github.com/epics-base/epics-base/blob/0f8ea3aa3671cb0433b4350020430a7740d6fdc6/modules/database/src/std/rec/aiRecord.c#L151-L159
The essential work of convert() is to read RVAL (an integer)
and write VAL (floating point).
val = (double)prec->rval + (double)prec->roff;
...
prec->val = val;
https://github.com/epics-base/epics-base/blob/0f8ea3aa3671cb0433b4350020430a7740d6fdc6/modules/database/src/std/rec/aiRecord.c#L418-L444
In returning "2", your device support claims to have updated
VAL already.
In page 192 of the developer guide, return 2 means do not convert, what does it mean in this case? Also, is implementing a callback to process the record necessary? Or can I lock/unlock the record directly in the read_ai function?
Thanks!
Abdalla.
One of my attempts to explain some aspects of device support.
It doesn't mention the magic 2 either, but it does go over
some different strategies for asynchronous support.
http://mdavidsaver.github.io/epics-doc/epics-devsup.html
- References:
- Understanding EPICS DSET-based driver Abdalla Ahmad via Tech-talk
- Navigate by Date:
- Prev:
Understanding EPICS DSET-based driver Abdalla Ahmad via Tech-talk
- Next:
mbbo & calcout for drive position management Crisp, Daniel 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
- Navigate by Thread:
- Prev:
Understanding EPICS DSET-based driver Abdalla Ahmad via Tech-talk
- Next:
mbbo & calcout for drive position management Crisp, Daniel 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
|