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  2015  2016  2017  <20182019  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  <20182019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: dbReadDatabase in base-7.0
From: Andrew Johnson <[email protected]>
To: Benjamin Franksen <[email protected]>
Cc: [email protected]
Date: Tue, 24 Apr 2018 10:57:15 -0500
Hi Ben,

On 04/24/2018 05:52 AM, Benjamin Franksen wrote:
> I am trying to get some of our applications to build against base-7.0
> (we have only used 3.14 until now). So far most of the changes I needed
> to make were pretty straight forward, but I have now hit a road block.
> 
> It seems that DB_OPT is no longer supported. We are using DB_OPT in some
> of our Makefiles for three reasons: (1) to keep down the size of
> generated db files, (2) to make them more readable, and (3) to compare
> them more easily. Re-adding DB_OPT support to the build system wasn't
> very hard, and this question is /not/ about the build system.
> 
> We have long since replaced dbst with a much simpler tool, which
> basically just calls dbReadDatabase twice (once for the dbd file and
> once for the input db file) and then calls dbWriteRecord.
> 
> This tool no longer works with base-7.0. It complains
> 
>         *** Did you run x_RegisterRecordDeviceDriver(pdbbase) yet? ***
> dbReadDatabase error; file name=../O.Common/OpticRamp.SIOC2CP.db.raw,
> return code=-1, errno=0
> dbAllocRecord(ORMPCGP:setOpt) with ao rec_size = 0
> Can't create record "ORMPCGP:setOpt" of type "ao"
> Error at or before ")" in file "../O.Common/OpticRamp.SIOC2CP.db.raw" line 1
> Error: syntax error
> 
> I do not understand this error message. Is dbReadDatabase no longer the
> right function to call?

tl;dr: Unfortunately your tool relies on code that was ripped out of
dbStaticLib and can't be added back. However there is a Perl script
included in EPICS 7 that may already do what you need, see the last
paragraph below.


The back-story:

If you look in the base-3.14/src/dbStatic directory you'll see two files
called dbStaticRun.c and dbStaticNoRun.c. These implement two different
ways to store a database in memory, by providing two different versions
of the same sets of routines. The first one is (still) used in the IOC
database (although parts of it have been reorganized, rewritten and/or
moved into other source files) and implements the record structure that
as device and record support developers we all know about.

The second file implemented a way to store a record as an array of
pointers to strings containing the value of every record field in
record-type order. This layout was used by any tool that linked against
the dbStaticHost library, so this is the code your tool would have used,
and is no longer available since other parts of dbStaticLib now only
support the IOC-format record layout.

Code using dbStaticRun.c must have also been linked against all the
record.o files and have access to the RSET for the record type, since
that provides it with metadata about the record size and the size and
offset of every field in the record type. The error message you're
seeing is the result of a check we make in case you try to load a record
instance into the IOC without the necessary metadata being available.

Only a C compiler can calculate all the metadata since it varies with
CPU and ABI (alignment rules etc.); the routines *RecordSizeOffset()
which are emitted at the end of the *Record.h files calculate that
metadata for the IOC, and you won't be able to use these for your tool
since you would also have to link against all the record.o files for the
record types you wanted to support.


The solution:

EPICS 7 comes with a set of Perl modules for reading and writing DBD and
DB files, and a script dbExpand.pl that may already do what you need. It
reads a DBD and any number of DB files and outputs the DB information
again with comments stripped, and IIRC only prints non-default field
values; it will also expand include statements and $(macros) whose
values are provided on the command line, and eventually should expand
hierarchical templates as well (that work is on a development branch of
mine if you're interested).

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:
dbReadDatabase in base-7.0 Benjamin Franksen

Navigate by Date:
Prev: Re: Security Hardening for EPICS/RTEMS Gedare Bloom
Next: Walking Piezo Drivers/ Controllers Survey Wallace, Alex
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  <20182019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: dbReadDatabase in base-7.0 Benjamin Franksen
Next: OPC UA Device Support - Requirements Doc Ralph Lange
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  <20182019  2020  2021  2022  2023  2024 
ANJ, 24 Apr 2018 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·