EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  <20152016  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  <20152016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: Problems using static database routines to modify IOCs
From: Andrew Johnson <[email protected]>
To: "[email protected]" <[email protected]>
Cc: EPICS <[email protected]>
Date: Fri, 1 May 2015 10:56:32 -0500
Hi Doug,

> The system is a Windows 7 computer! Unfortunately I need this to work in
> Windows because the software we use the IOC for is only Windows based.
> Thank you for pointing this out since I hadn't considered it could be a
> Windows compatibility issue. The ultimate goal is to use database access
> to compare values at boot up with a set of stored 'good' values. I think
> this will require the runtime database access routines which I've had some
> success with so far. So in the end I'm hoping this might be a non issue.

Doing this on Windows should not be a problem. To clarify, you're
wanting to compare these values *before* the IOC runs iocInit()?

>>> I have been able to get the example code to work within the IOC I'm trying
>>> to modify, but in a round about way. It is some type of pointer problem
>>> but I'm not sure what's wrong.
>>>
>>> So the code works if I add the following,
>>>
>>> void dbDumpRecords(DBBASE *pdbbase)
>>> {
>>>          DBENTRY *pdbentry;
>>>      long status;
>>>
>>>      status =
>>> dbReadDatabase(&pdbbase,"C:\\SlowControls\\EPICS\\Utilities\\Bin\\tCat.dbd",NULL,NULL);
>>>      if(!status) {printf("Database file loaded.\n");}
>>>      else {printf("Database load file failed.\n");}
>>>
>>>      status =
>>> dbReadDatabase(&pdbbase,"C:\\SlowControls\\EPICS\\Utilities\\Bin\\test.db",NULL,NULL);
>>>      if(!status) {printf("Records file loaded.\n\n");}
>>>      else {printf("Records load file failed.\n\n");}
>>>
>>>          pdbentry = dbAllocEntry(pdbbase);
>>> .......rest of dump routine
>>>
>>> So the dump routine runs perfectly if I include dbReadDatabase routines
>>> for both the database.dbd and records.db files.

What that is doing is loading a second instance of the database
definition into memory, which is not what you want to do.

>>> What I don't understand is why I need to Read the databases into the
>>> function separately from the IOCs initialization. I thought I could
>>> access the runtime database in memory through pdbbase.

You should be able to, so the fact that you're having problems tells me
that the pdbbase pointer that your code is using is not the same one
that the IOC is using. The dbStatic library is designed to allow
multiple databases to be loaded into memory at once, but the IOC can
only run one, which is declared in the header dbAccessDefs.h (also
included by dbAccess.h).

>>>>> The code solution compiles without any issues but when I try to run
>>>>> the
>>> IOC it causes the following
>>>>> Unhandled exception at 0x5C6F1C6E (dbStaticHost.dll) in tcIoc.exe:
>>> 0xC0000005: Access violation reading location 0x00000031.

That might have been that you were accessing iocshPpdbbase or pdbbase
before it was initialized. I'd need to see your iocMain.c to be sure,
but in general you should be running this kind of code from the startup
script using a command that your code registers with iocsh, or from an
initHook. That way it can be run at the right time, which would be after
the dbLoadDatabase() and dbLoadRecords() commands but before iocInit()
starts up the database operations.


Lets try starting from the beginning again: You're wanting to "compare
values at boot up with a set of stored 'good' values". As Tim said there
are some fields (mostly array fields) for which you can only do that
from an initHook as part of the IOC startup, but for most fields you can
do it earlier, as long as the database definition and record instances
have been loaded first.

How & when are you running your code?

- Andrew

-- 
Light thinks it travels faster than anything but it is wrong.
No matter how fast light travels, it finds the darkness has
always got there first, and is waiting for it.
    -- Terry Pratchett, Reaper Man

Replies:
Re: Problems using static database routines to modify IOCs marc . lormand
References:
Re: Problems using static database routines to modify IOCs Dirk Zimoch
Re: Problems using static database routines to modify IOCs marc . lormand
RE: Problems using static database routines to modify IOCs Mooney, Tim M.

Navigate by Date:
Prev: RE: Problems using static database routines to modify IOCs Mooney, Tim M.
Next: Re: Problems using static database routines to modify IOCs marc . lormand
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  <20152016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: RE: Problems using static database routines to modify IOCs Mooney, Tim M.
Next: Re: Problems using static database routines to modify IOCs marc . lormand
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  <20152016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 16 Dec 2015 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·