Hi Stefan,
I was also going to suggest that you consider using the asynPortDriver C++ class. Doing so means you don't need to write any device support code at all, you can use the standard device support that comes with asyn. It handles all the complexity of I/O Intr scanning, synchronous (fast) versus asynchronous (slow) device support, etc. You just write a C++ driver that inherits from asynPortDriver.
I have written many drivers that use this approach, including 3 for VME devices. These are all actually Industry Pack devices, but they use memory-mapped I/O in the VME address space.
- Systran DAC-128V D/A converter. This is a very simple driver, only 164 lines of code.
https://github.com/epics-modules/dac128v
- IP-Unidig digital I/O module. 745 lines of code, has interrupt support.
https://github.com/epics-modules/ipunidig
- Ip-330 ADC. 1270 lines of code. This uses the standard asyn C interface, rather than the C++ asynPortDriver base class. If I were to write it again I would use asynPortDriver, and it would be fewer lines of code.
https://github.com/epics-modules/ip330
This page has links to training lectures and slide presentations on asyn and asynPortDriver:
http://www.aps.anl.gov/epics/docs/APS2015.php
Mark
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Andrew Johnson
Sent: Friday, August 12, 2016 10:24 AM
To: [email protected]
Subject: Re: wait/dealy inside a record
Hi Stefen,
On 08/12/2016 02:48 AM, Stefen Paul wrote:
> I'm using a waveform record (with custom device support) for writing &
> reading a hardware.
>
> I need following sequence:
>
> - write to a register
> - wait for 20 microseconds
> - again write to the same register
> - again wait for 20 microseconds
> - read an array of other registers
>
> Any tips on how can I generate a delay/wait of ~20 microsec inside the
> device support routine or otherwise in EPICS ?
40 microseconds is probably a bit too long for your device routine to
block record processing, so Michael's suggestion that you use an
asynchronous completion callback is sensible. That requires you to
implement the write/delay/write/delay/read sequence yourself though,
probably in another thread, and to communicate between threads.
An alternative approach that I recommend looking at is to use
asynDriver's Port Driver C++ class, which can simplify the device
support code quite a bit and allows you to write the above sequence as
what looks like single-threaded code. Your 20µs delays could then become
calls to the OS' nanosleep() routine or an equivalent. The asynDriver
infrastructure will run this code in a separate thread at the
appropriate time and handle the communication with the record for you.
http://www.aps.anl.gov/epics/modules/soft/asyn/R4-29/asynPortDriver.html
http://www.aps.anl.gov/epics/modules/soft/asyn/R4-29/asynDriver.html
HTH,
- Andrew
--
Arguing for surveillance because you have nothing to hide is no
different than making the claim, "I don't care about freedom of
speech because I have nothing to say." -- Edward Snowdon
- References:
- wait/dealy inside a record Stefen Paul
- Re: wait/dealy inside a record Andrew Johnson
- Navigate by Date:
- Prev:
Re: NDArrayPool::alloc failing Phil Atkin
- Next:
RE: NDArrayPool::alloc failing Mark Rivers
- 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:
Re: wait/dealy inside a record Andrew Johnson
- Next:
Question about pv value and the label display in CSS boy opi lzf neu
- 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
|