Hi All,
I am using NI System Configuration C API to read my RT Target's total physical memory. I did not find any good example for this, after looking at nisyscfg.h, I came up with the following code:
main(){
NISysCfgStatus status;
NISysCfgSessionHandle session;
double total_phys_mem;
//Declaring session
if (NISysCfg_Succeeded(status = NISysCfgInitializeSession("localhost",NULL,NULL,NISysCfgLocaleDefault,NISysCfgBoolTrue,10000,NULL,&session))){
//Reading Total Physical Memory
if (NISyscfg_Succeeded(status = NISysCfgGetSystemProperty(session,NISysCfgSystemPropertyMemoryPhysTotal,&total_phys_mem))){
printf("\nTotal Physical Memory: %f", total_phys_mem);
}
}
}
When I try to run this, I get a "Segmentation fault" error. I have used the same session to create filter, set filter's property, get resourceHandle, read serial number, CPU Load etc. without any problem, but reading total physical memory is becoming difficult. May be this code is wrong, so can anyone please show me the right way to do this with this C API?
Thanks.
Solved! Go to Solution.
I want to test your code. Which target are you using and what version of NI System Configuration do you have on your target?
My target is sbRIO-9651, and version of NI System Configuration is 14.5.0.
Thanks for the info, rkjulfiker.
The only peculiar thing I noticed in your code was a spelling issue. Your second if statement has a "NISyscfg_Succeeded" when I believe it should be "NISysCfg_Succeeded".
After I corrected this I was able to compile (cross compiling from Eclipse CDT) and execute it on my target 9637 with the 15.0 software set. Testing on a different arm target with 14.5 next to make sure that works as well.
Are you compiling on target or from another host machine?
I typed the code here, not copied, I mistyped that "NISyscfg_Succeeded". Sorry if that caused you any trouble. My original code has correct spelling though, and I also used eclipse to compile. It builds successfully, but I still get the same error when try to run it.
I am using NI System Configuration C API to read my RT Target's total physical memory. I did not find any good example for this, after looking at nisyscfg.h, I came up with the following code:
As on any Linux machine, you can read that data from /proc/meminfo.