Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

creating XNET CAN sessions at runtime

I am using LabView RT 2009 and XNET 1.0.0. I see the following methods of receiving CAN messages:

 

- reading ALL messages on the bus (stream)

- reading only specific messages (or signals) defined by a database

 

But what I am trying to do is

 

- reading specific messages, but what frames (IDs) is decided at runtime

 

In order to do this, I am trying to create a new "frame in single-point" session for the needed frames list.

But LabView complains about trying to create a "new session after the interface has been started (code -1074384738). Please create the session before starting." Do I have observe the messages via stream and analyse all message for the specific ones?

 

0 Kudos
Message 1 of 7
(9,375 Views)

To answer your question in a word: yes.  In fact, I am using XNET Read (Frame Raw) after initializing with XNET Create Session.vi (in Frame In Stream mode).  After you begin receiving messages (hint: set number to read to 24 bytes and convert Raw frame into CAN frame) you can look for the ID or other property of your choice.

 

Bill_in_Detroit

GCentral
0 Kudos
Message 2 of 7
(9,374 Views)

Can I change the frames list when the session is runinng? I dont want to stop the session before.

0 Kudos
Message 3 of 7
(8,667 Views)

李雨 -
I am not sure which method you used to construct your code for this, but if you have a loop dedicated to reading frames from the XNET CAN and another writing frames to it (when called upon) you can parse the incoming CAN messages for ARB ID or any other data contained therein and then respond via the write loop with any CAN frame of your choice.  I am not sure whether this can be done with the "Channel" construct that NI has developed but with frames it is easily done.

I have included a code snippet example I wrote a few years ago.  It is for J1939 but CAN is pretty much CAN.  The example it is based on can be found on the NI website at http://zone.ni.com/devzone/cda/epd/p/id/6215. 

 

 

J1939 XNET example code.png

GCentral
0 Kudos
Message 4 of 7
(8,641 Views)

 I use the XNET creat session to configure the I/O names and then select the Frame-Output ,the frame list can be choosed in the database I have set before. I want to change the Frame list when  running the Write session .vi. But it failed.What I use is the session property---interface---outStrmList. it occurs the internal error in the XNET driver.

0 Kudos
Message 5 of 7
(8,629 Views)

Hi 李雨,

 

The Output Stream List property is defined in the help as, "The Output Stream List property provides a list of frames for use with the replay feature." I doublt this ithe property you are wanting.

 

Why are you wanting to change the signal list on the fly, can you not load your whole database? The Frame Input Queued mode will allow you to read a specific frame without having to parse for a specific ID like the Frame Input Stream mode. There are equivilents of this for Singals as well (Queued and Stream modes). See the NI XNET Hardware and Softare Manual Chapter 4, Session section.

 

When using a Queued mode you can create multiple session to read certain frames/signals. If you are really looking for the ability to enable or disable certain session, but keeping the database running then you might be able to use the XNET Stop VI with a scope of session only. This is described in the NI XNET Hardware and Software Manual 4-451 (page 511 of the pdf).

 

I highly recommend upgrading to the latest NI XNET driver, version 1.3.

Joshua B.
National Instruments
0 Kudos
Message 6 of 7
(8,622 Views)

Ah..I just want to immitate the state that if some of the signals are missing ,but others are still running. What will happen the instrument I want to test .The I want to recover the signals that were missing before. But once the session is running ,I can't do anything to change the initial frame list ,if I do not stop the session.

0 Kudos
Message 7 of 7
(8,616 Views)