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 | 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 |
<== Date ==> | <== Thread ==> |
---|
Subject: | Re: ASYN port driver for file IO? |
From: | Ralph Lange <[email protected]> |
To: | Torsten Bögershausen <[email protected]>, EPICS Tech-Talk <[email protected]> |
Date: | Wed, 18 Jun 2014 10:12:29 +0200 |
Hi Torsten,
On 18/06/2014 08:43, Torsten Bögershausen wrote: thats sounds too interesting to keep quiet. ;-) What, more specific, do you want to do ? Yes. Why not. Do you need all the lines, or only a specifc one ? Yes. Possibly both. Do you want to read the file multiple times ? Yes. Or maybe not? In this case you could write a little daemon, I could, but I don't want to... Do you want to share more details ? Sure. My specific use case is reading statistics data from a file in the /proc file system, using StreamDevice to pull the numbers out. But, obviously, I want to have something that is more versatile, maybe to an extent that it's worth adding it to the ASYN package. So, I am thinking along the following lines. st.cmd: # drvAsynReadFilePortConfigure port fileName priority Autoconnect noProcessEos drvAsynReadFilePortConfigure("mem","/proc/meminfo",0,1,0) connect/disconnect = open/close statsfile.proto: freshD { out "o\$1"; in "%*s%d" } Control through writing: g = goto line o = reopen and goto line line numbers: 0 = don't move (next line), negative = from the end of the file database: record (longin, "memFree") { field(DTYP, "stream") field(INP, "@statsfile.proto freshD(2) mem") } Other applications could include refreshing the last n lines of some (log) file into a char array, or ...... Windows/Linux line endings would be handled through EOS processing, interpose layers could do interesting things. An similar (slightly simpler) drvAsynWriteFilePort could allow writing to a file (overwriting or appending). File IO is something that is traditionally hard to do on an IOC - this approach might provide an easy way for many use cases. What do you think? ~Ralph |