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