NI Linux Real-Time Discussions

キャンセル
次の結果を表示 
次の代わりに検索 
もしかして: 

Reading Total Physical Memory with NI System Configuration API

解決済み
解決策を見る

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.

メッセージ1/7
6,158件の閲覧回数

I want to test your code. Which target are you using and what version of NI System Configuration do you have on your target?

Tim A.
メッセージ2/7
5,126件の閲覧回数

My target is sbRIO-9651, and version of NI System Configuration is 14.5.0.

0 件の賞賛
メッセージ3/7
5,126件の閲覧回数

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?

Tim A.
メッセージ4/7
5,126件の閲覧回数

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.

0 件の賞賛
メッセージ5/7
5,126件の閲覧回数
解決策
トピック作成者rkjulfikerが受理

Found the error, it was in the function list, there was a typo in the function name, so the function could not be found on the runtime. I appreciate the help.

メッセージ6/7
5,126件の閲覧回数

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.

Linux Embedded / Kernel Hacker / BSP / Driver development / Systems engineering
0 件の賞賛
メッセージ7/7
4,187件の閲覧回数