Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamically change CAN message payload length in XNET

It took me a while to figure out that when I send 4 bytes into the nxWriteFrame routine when it's defined as an 8 byte message in the DBC, that the message never makes it onto the bus.  Is there a way to dynamically change the payload length of a CAN message at runtime without stopping and starting the session again?
0 Kudos
Message 1 of 16
(8,862 Views)

Hi KavehV,

 

It is possible to dynamically change the payload lengthduring RunTime but not without starting and stopping the session. In fact, all changes to the payload length, when done dynamically, is done to the copy of the database in memory as opposed to the one on disk, so whenever your application stops running, the changes are discarded. If you need to change the payload length, you would need to essentially do so before you create a session by opening the database, and modifying the copy that's in memory.

Raj
National Instruments
Applications Engineer
0 Kudos
Message 2 of 16
(8,825 Views)
Yeah, I figured this out.  I had to end up using the frame stream output in order to be able to dynamically change the payload length without stopping the session at runtime.  Is there a reason that the other frame APIs don't honor the value you write to them for payload length?  It seems to me like they should.  Perhaps something to incorporate into the next version.
0 Kudos
Message 3 of 16
(8,823 Views)

I also have to change payload length with XNET package. How can I do this? I have tried to change to write Payload length field from Frame Property Node and assign to it the desired length in byte, but this does not  appear to work correctly. Why?

 

regards,

 

Jessica

0 Kudos
Message 4 of 16
(8,303 Views)

Can you explain your use case? The current NI-XNET scheme is attempting to maintain the system described by the database, specifically that a frame matches the configured payload length.

0 Kudos
Message 5 of 16
(8,297 Views)

I have to send to an automotive device three types of CAN message (with three different ayload lengths) by using Frame Output Single-point mode.

Actually I have solved the problem using three different databases, but I believe a better solution exists.

 

Regards,

 

Jessica

0 Kudos
Message 6 of 16
(8,291 Views)

So the device accepts 3 different messages using the same CAN ID and they are of different lengths. I presume the device would look at like the first byte of the payload to determine how to interpret the other bytes or does it just look at the length and based on the length it can determine which of the 3 messages are being sent?

0 Kudos
Message 7 of 16
(8,288 Views)

No, the device is not able to do this.

0 Kudos
Message 8 of 16
(8,285 Views)

So why do you need to send the device the same ID with 3 different payloads?

0 Kudos
Message 9 of 16
(8,283 Views)

This is a particular CAN message that enable diagnostic services on the ECU

0 Kudos
Message 10 of 16
(8,279 Views)