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: [email protected]
To: "Dirk Zimoch" <[email protected]>
Cc: [email protected], EPICS <[email protected]>
Date: Thu, 30 Apr 2015 13:41:53 -0500
Dirk,

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.

Thanks again,
Doug Lormand


> I see "C:", so you work on Windows it seems. There are additional issues
> with windows and dll linkage. I guess pdbbase or any other global
> pointer has the wrong linkage. But I am not very familiar with Windows
> (and hate it). Use Linux and I bet it will work ;-)
>
> Dirk
>
> On 30.04.2015 02:27, [email protected] wrote:
>> Hello again all,
>>
>> 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 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.
>>
>> So does anyone know how to access the runtime database that is loaded at
>> IOC initialization using the command DbLoadRecords? If so how can I do
>> this?
>>
>> I'm really hoping this is some easy pointer issue I'm missing due to
>> inexperience.
>>
>> Thank you,
>> Doug Lormand
>>
>>> Hello Doug,
>>> Access violation reading location 0x00000031.
>>> This looks like a NULL pointer problem. Check pdbbase and pdbentry.
>>> Dirk
>>> On 14.04.2015 01:15, [email protected] wrote:
>>>> Hello,
>>>> I am trying to use the dbDumpRecords example given in section 14.16.2
>> to
>>>> display a list of records and their fields at IOC initialization. I
>> included the example code as a function in the main.c code. Actually,
>> the
>>>> main.c has also been modified and is now called iocMain.cpp. I am
>>>> calling
>>>> the dbDumpRecords function using *iocshPpdbbase.
>>>> The example code I'm using,
>>>> ****************************************************
>>>> void dbDumpRecords(DBBASE *pdbbase)
>>>> {
>>>>       DBENTRY  *pdbentry;
>>>>       long  status;
>>>>       pdbentry = dbAllocEntry(pdbbase);
>>>>       status = dbFirstRecordType(pdbentry);
>>>>       if(status) {printf("No record descriptions\n");return;}
>>>>       while(!status) {
>>>>           printf("record type: %s",dbGetRecordTypeName(pdbentry));
>> status = dbFirstRecord(pdbentry);
>>>>           if(status) printf("  No Records\n");
>>>>           while(!status) {
>>>>               if (dbIsAlias(pdbentry)
>>>>                   printf("\n  Alias:%s\n",dbGetRecordName(pdbentry));
>>>>               else {
>>>>                   printf("\n  Record:%s\n",dbGetRecordName(pdbentry));
>> status = dbFirstField(pdbentry,TRUE);
>>>>                       if(status) printf("    No Fields\n");
>>>>                   while(!status) {
>>>>                       printf("    %s: %s",dbGetFieldName(pdbentry),
>>>>                           dbGetString(pdbentry));
>>>>                       status=dbNextField(pdbentry,TRUE);
>>>>                   }
>>>>               }
>>>>               status = dbNextRecord(pdbentry);
>>>>           }
>>>>           status = dbNextRecordType(pdbentry);
>>>>       }
>>>>       printf("End of all Records\n");
>>>>       dbFreeEntry(pdbentry);
>>>> }
>>>> **************************************************
>>>> This modification is running on a 32 bit Windows 7 machine using EPICS
>> base 3.14.12.3. The compiler is MS Visual Studio 11.
>>>> 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.
>>>> I have also tried several of the other static database functions,
>> dbDumpRecord, dbDumpRecordType, dbDumpMenu, and I have discovered the
>> following.
>>>> I can use the static database functions to display the record type
>>>> names,
>>>> the record names, and the record fields. But if I try to access the
>>>> record
>>>> fields the IOC will crash. If I use the dbVerify function to test the
>> record field values I get a bunch of null and not valid output, for
>> example,
>>>> Record type: ai
>>>>      Record: test1
>>>>       DESC:  (null)
>>>>       ASG:  (null)
>>>>       SCAN:  Not a valid menu choice
>>>>       PINI:  Not a valid menu choice
>>>>       PHAS:  not an integer number
>>>> etc.
>>>> Also, the
>>>> void dbDumpRecord(DBBASE *pdbbase,char *precordTypeName,int level);
>> function fails with the same type of access violation when I have tried
>> using it. All functions that try to read the record fields fail.
>> However,
>>>> if I comment out the offending function calls and start the IOC shell,
>> I
>>>> can use dbDumpRecord(pdbbase) at the prompt and it succeeds.
>>>> I am a newbie at modifying IOCs so I'm not sure what could be going
>>>> wrong
>>>> when trying to access the records fields. Any help is greatly
>>>> appreciated.
>>>> If I can post any follow up info please let me know.
>>>> Thank you in advance,
>>>> Doug Lormand
>>
>>
>>
>>
>
>



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

Navigate by Date:
Prev: RE: Problem building seq-2-2-1 on Windows Mark Rivers
Next: RE: Base R3.15.2-rc1 release Mark Rivers
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 Dirk Zimoch
Next: RE: Problems using static database routines to modify IOCs Mooney, Tim M.
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 ·