NI Home > Community > NI Discussion Forums

Automotive and Embedded Networks

Showing results for 
Search instead for 
Do you mean 
Reply
Member
Carbert
Posts: 6
0 Kudos

Get Product Number using NI-XNET

 

I'm trying to get the product number and name of the National
Instruments card installed on my computer. According to the manual when
I get the property for nxPropDev_Name I should get NI PCI-8512 (2 ports)
for an NI PCI-8512 device. Instead I get an empty Cstring. For
nxPropDev_ProductNum I should get 8512 for an NI PCI-8512 device, but
instead I get this number: 3435973836.

Below is a snippet of the code I'm using. Is there something I am doing
incorrectly?

Thanks

int propSize;
int cpropSize;
u32 propName;
CString cpropName;
char *l_pSelectedInterface = "CAN2";
char *l_pFrameArray = NULL;
char *l_pSelectedDatabase = ":memory:";
char *l_pSelectedCluster = "";

g_nxStatus = (*m_pNxCreateSession)(l_pSelectedDatabase,
l_pSelectedCluster,
l_pFrameArray,l_pSelectedInterface,
nxMode_FrameInStream, &SessionRef);

g_nxStatus = (*m_pNxGetPropertySize)(SessionRef, nxPropDev_ProductNum,
(u32)(&propSize));
g_nxStatus = (*m_pNxGetProperty)(SessionRef, nxPropDev_ProductNum,
(u32)(propSize),
&propName);
g_nxStatus = (*m_pNxGetPropertySize)(SessionRef, nxPropDev_Name,
(u32)(&cpropSize));                                                                                                                                                                             g_nxStatus = (*m_pNxGetProperty)(SessionRef, nxPropDev_Name, (u32)(&cpropSize)); 
Active Participant
T-REX$
Posts: 503
0 Kudos

Re: Get Product Number using NI-XNET

Hello Carbert,

 

Everything in your code looks fine to me. What version of the X-NET driver do you have installed? Also, what is the Part Number of your card, so that we can try test the behavior here on our end. I see that you have a Service Request open with us here. Once this issue is resolved, will you post back here with the results for future people that may run into similar issues?

Cheers!

TJ G
Member
Carbert
Posts: 6
0 Kudos

Re: Get Product Number using NI-XNET

I'm using NI-XNET 1.3 and the part number NI PCI-8512 - 780683-01

Active Participant
T-REX$
Posts: 503
0 Kudos

Re: Get Product Number using NI-XNET

Hello Carbert,

 

One more thing, are you using LabWindows/CVI, or just the standard C API with another compiler (gcc maybe) ? Are you working from a specific example that you would like us to start from as well?

 

Cheers!

TJ G
Member
Carbert
Posts: 6
0 Kudos

Re: Get Product Number using NI-XNET

Hi TJ,

 

I'm using the standard C API on Visual Studio 2010. I'm not working off any specific example.

 

Thanks

Active Participant
T-REX$
Posts: 503
0 Kudos

Re: Get Product Number using NI-XNET

Hi Carbert,

 

The applications engineer assigned to your service request and I will see if we can reproduce the behavior that you're seeing as soon as possible. Thanks for all the information.

Cheers!

TJ G
Member
therkkila
Posts: 2
0 Kudos

Re: Get Product Number using NI-XNET

3435973836 -> 0xCCCC CCCC

 

This is common value for uninitialized variable in Visual C++.

 

So in this case function pNxGetProperty fails and since propName is a pointer, it's value stays as it was before function call. So if you initialize propName = 0, it stays 0 becouse of function failure.

 

Calling nxGetProperty gives error.

NI-XNET:  (Hex 0xBFF6308D) The property ID you specified is not valid (or not valid for the current session mode or form factor).

 

And I have tested with property nxPropSession_IntfBaudRate and it works well, so environment should ok.

 

I'm strugling with this same problem. Several other properties are failing too, so are those unimplemented or is there some other reason for this?

 

 

Active Participant
GPIB_Guru
Posts: 552
0 Kudos

Re: Get Product Number using NI-XNET

This is probably making the impossible difficult, but you cannot get from the session back to the device directly. It is actually a separate API (right now - ideally we can improve this to make it easier in the future) called the system API to get system->device->interface type of properties.Using the system API, I am doing the following:

1) Open System

2) Get all interfaces in the system

3) Loop on the interfaces until I find one that has a name that matches the desired one

4) Once I get the interface, I can get the device that the interface is a part of

5) Once I get the device, I can then query the device for the required information (Name, Number)

6) Close System

 

Note: This doesn't do any error checking for simplicity, but it does get the status so you could easily apply error checking to prevent any type of ugly unexpected failures.

 

 

int  l_NumInterfaces;
int  l_PropSize;
u32  l_PropProductNum;
char l_PropProductName[1024];
char l_PropInterfaceName[1024];
nxSessionRef_t l_PropInterfaceRefs[32];
nxSessionRef_t l_SystemRef;
nxSessionRef_t l_SelectedDeviceRef;
char *l_pSelectedInterface = "CAN2";
char *l_pFrameArray = NULL;
char *l_pSelectedDatabase = ":memory:";
char *l_pSelectedCluster = "";
int i;

g_Status = nxSystemOpen(&l_SystemRef);
g_Status = nxGetPropertySize(
	l_SystemRef,
	nxPropSys_IntfRefs,
	&l_PropSize
	);

g_Status = nxGetProperty(
	l_SystemRef, 
	nxPropSys_IntfRefs,
	l_PropSize,
	l_PropInterfaceRefs
	);

l_NumInterfaces = l_PropSize/sizeof(nxSessionRef_t);
for (i = 0; i < l_NumInterfaces; i++)
{
	g_Status = nxGetPropertySize(
		l_PropInterfaceRefs[i],
		nxPropIntf_Name,
		&l_PropSize
		);

	g_Status = nxGetProperty(
		l_PropInterfaceRefs[i], 
		nxPropIntf_Name,
		l_PropSize,
		l_PropInterfaceName
		);

	if (!strcmp(l_PropInterfaceName, l_pSelectedInterface))
	{
		g_Status = nxGetProperty(
			l_PropInterfaceRefs[i], 
			nxPropIntf_DevRef,
			sizeof(nxSessionRef_t),
			&l_SelectedDeviceRef
			);

		g_Status = nxGetProperty(
			l_SelectedDeviceRef, 
			nxPropDev_ProductNum,
			sizeof(u32),
			&l_PropProductNum
			);

		g_Status = nxGetPropertySize(
			l_SelectedDeviceRef, 
			nxPropDev_Name,
			&l_PropSize
			);

		g_Status = nxGetProperty(
			l_SelectedDeviceRef, 
			nxPropDev_Name,
			l_PropSize,
			l_PropProductName
			);
		break;
	}
}

g_Status = nxSystemClose (l_SystemRef);

 

Member
therkkila
Posts: 2
0 Kudos

Re: Get Product Number using NI-XNET

These changes worked well, so from my part this case is solved. Thanks alot.

Active Participant
GPIB_Guru
Posts: 552
0 Kudos

Re: Get Product Number using NI-XNET

Thanks for the update. I am glad that you were able to be successful.