From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

Extract SPN for a signal from a .dbc using XNET API

This morning I looked at using XNET to load a CAN bus (J1939) .dbc file where I would parse frames, signals, signal SPNs, and misc signal details. I was successful except I just can't figure out how to extract the SPN for a signal. Seems like I am just a few clicks away but I'm having no luck.

 

Any one have an idea how this is done?

 

Thanks,

 

Todd

 

 

Download All
0 Kudos
Message 1 of 5
(3,332 Views)

Hello Labviewman,

 

Please check this thread. 

https://forums.ni.com/t5/LabVIEW/Diagnostic-Messages-J1939/td-p/2157174

 

Diego H

National Instruments

0 Kudos
Message 2 of 5
(3,259 Views)

Thanks, but that doesn't help.

0 Kudos
Message 3 of 5
(3,245 Views)

Unfortunately J1939 with XNET does not currently offer the capability to extract the SPN from the signal information contained in the database.

Jeff L
National Instruments
0 Kudos
Message 4 of 5
(3,236 Views)

Since it doesn't look like this is possible via the XNET API, I figured out the .dbc database structure for the SPNs (signal names). 

 

The line I look for is structured like this:

BA_ "SPN" SIG_ XXXX SPNname SPNNumber;

 

I look for '"SPN" SIG_' and parse the rest (XXXX is a cross reference to the PGN/message name).  If no error, I add the SPNname and SPNNumber to the 'SPN found' arrays.  Then, since I already know the SPNnames for the signals in the database via the XNET Database vis, I search the created array (SPN name found array), take the index to the found name and index the SPNNumber array for the SPN/signal number.

 

The above method found 97% of the SPN numbers for the SPNnames found with the XNET database vis.  I checked about 10 of the 3% that were not found...they didn't have a SPN/signal number, so it seems my method works.

0 Kudos
Message 5 of 5
(3,218 Views)