01-10-2019 11:37 AM
I am using NI CAN controller PCI-8513 with XNET database. Database setup can be seen in the picture below
I am able to read CAN session name by using the following code in LabWindows CVI.
When returned, PropList = "PID_Write_ECU1". Now I want to get the arbitration ID (0x712). How can it be done? Help please
uint32_t propertySize;
uint8_t PropList[100];
uint8_t DatabaseName[100];
nxDatabaseRef_t DatabaseRef;
uint32_t ArbID;
nxStatus_t nx_status;
char CAN_DB_FilePath[100] = "C:\\temp\\XNET_Database.xml";
nx_status = nxCreateSession (CAN_DB_FilePath, "CANA", "PID_Write_ECU1","CAN1", nxMode_FrameOutSinglePoint, &PID_Write_ECU1); // 0x712
nxGetPropertySize (PID_Write_ECU1, nxPropSession_List, &propertySize);
nxGetProperty(PID_Write_ECU1, nxPropSession_List, propertySize, PropList);
nx_status = nxClear (PID_Write_ECU1);
01-11-2019 02:31 AM - edited 01-11-2019 02:31 AM
After looking at the documentation it seems to me that that value cannot be retrieved from the session but it must be read from the database you are using instead, by means of the function
nxdbGetProperty (DbObjectRef, nxPropFrm_ID, 0, &PropertyValue);
Look at these help pages: nxdbGetProperty and nxPropFrm_ID
01-15-2019 08:47 AM - edited 01-15-2019 08:48 AM
I've tried the function of nxdbGetProperty before, but failed.
nxdbOpenDatabase (CAN_DB_FilePath, &DatabaseRef);
nxdbGetProperty(DatabaseRef, nxPropFrm_ID, 4, &ArbID);
01-16-2019 08:28 AM
Hi Charlie,
Since you are using the nxdbOpenDatabase function to immediately store the database reference in DatabaseRef, I have to assume one of the other references in nxdbGetProperty are causing this error to be thrown. Are you sure nxPropFrm_ID is a valid u32? I would just double check all the parameters you're passing to it with this help document on the function: http://zone.ni.com/reference/en-XX/help/372841T-01/nixnet/nxdbgetproperty/
01-16-2019 09:38 AM - edited 01-16-2019 09:39 AM
Disclaimer: I never tried to get this property so I may be wrong
In my opinion the idea to focus on is to use the correct object reference: since you are looking for a frame attribute, you should pass a frame object reference, which I suppose you can obtain by calling
nxdbFindObject (ParentObjectRef, nxClass_Frame, "", &DbObjectRef);
with the appropriate parameters (e.g. the frame name). As far as I can understand, the parent object reference should be the database reference you have already gotten.