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: 

Variable Legnth J1939 Message Handling

Solved!
Go to solution

Does NI-XNET provide a way to handle variable length J1939 messages with Signal Sessions? For instance, if a transmission is asked for a list of all active diagnostic trouble codes, it will send out a single J1939 message that varies in length (depending on how many trouble codes are present). Can a frame be defined in a database such that XNET will correctly parse the frame into corresponding signals, like it does for constant length frames?

0 Kudos
Message 1 of 4
(3,711 Views)

Hi COwen314,

 

It looks like there may be a way to handle variable length frames using our raw frame tools- here's a help page that shows a relevant example using the C API. Look toward the bottom of the page, under "PayloadLength."

 

In terms of working with variable lengths in the Database Manager, because FlexRay also uses variable frame lengths, taking a look at the implementation of the FlexRay examples may give you a good place to start.

Kathryn K.
Technical Support Engineer
National Instruments
http://ni.com/support
0 Kudos
Message 2 of 4
(3,685 Views)
Solution
Accepted by topic author COwen314

In the XNET database we will want to define a frame and provide it with the largest expected payload size. In that frame you can define signals but their bit positions will be static.

 

When XNET write is called on this frame it will send the data that we provide to it. The NIXNET_example database contains a J1939 cluster with a frame called J1939_Transport_P2P. The maximum payload is specified as 16 bytes. If we create a output session and write a 12 byte payload then XNET will only send 12 bytes on the bus.

 

If we define signals in this frame, say three 4 byte signals, they will be updated if their associated data is sent. If we transmit say 8 bytes, the first two signals will update and the third will display the default value. This gets tricky if a signal is partially updated i.e. we send 10 bytes. The first two signals will get the correct data and the third signal will display garbage.

 

Jeff L
National Instruments
Message 3 of 4
(3,678 Views)

Awesome, thanks Jeff.

0 Kudos
Message 4 of 4
(3,596 Views)