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: 

XNET Signal output erases some signals in a frame: Proper way to use Signal Defaults?

Solved!
Go to solution

Hello,

 

My team is creating an application to adjust the settings of a device in a CAN network. The device communicates its own settings to the CAN network every 250ms. The data comes across as several frames, each frame having several signals.
Example settings framesExample settings frames

Our goal is to show the user the current settings and then let the user write new values. When the device receives these frames from our application it saves the user's settings and starts reporting the new values. 

 

The problem is that when you use "XNET Signal Output" to send a single signal, the rest of the values in the frame are set to default. For example:

  • Device reports settings of frame "Evaporator_Settings_n1" to XNET
    • FanBurstDutyTimS = 10
    • FanBurstPeriodTimS = 20
    • MasterMinTimS = 30
    • ...
  • User sends new setting by only sending one signal "FanBurstDutyTimS"
    • FanBurstDutyTimS = 11
    • XNET fills in the rest of the signals in the frame with default values from the XNET database
  • Device reports the settings it received
    • FanBurstDutyTimS = 11
    • FanBurstPeriodTimS = 0
    • MasterMinTimS = 0
    • ...

Ideally we would like to fix this by setting the defaults in the XNET database to be whatever the device has reported most recently. XNET would save the defaults and send matching values in the frame except the one you want to change. The device writes over some settings with the same number it already had except the one you updated which is a new value.

 

Unfortunately you can't change signal defaults in the database while a session is started. If you try, you get the error:

NI-XNET:  (Hex 0xBFF6314F) Database object is locked because it is used in a session. Solution: Configure the database before using it in a session.

 

You can use XNET Clear to close a session, but this only works to close a Read Session. If I create a Write Session, I get the error. 
======================================================
As I'm writing this I've realized my mistake. The program was creating a session to read and properly closing that one before saving the default. It also created a Write Session if the user clicked "Write" and never closed that.

I'm reminded of another error I saw when developing this. I branched the XNET session in some places and when I tried to save defaults as described above I got:
...Solution: Don't branch a session. or something like that.

 

After making sure the session was not branched anymore, I forgot that I created the second session that was still causing the above error.

I've attached an example of the functioning program that reads the settings, saves them to the database, and properly sends all signals in a frame. This is a bit messy, but uses only the XNET VIs, no subVIs. 

0 Kudos
Message 1 of 2
(2,802 Views)