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: 

Reading and Writing to the same Signal

Solved!
Go to solution

I created 2 separate sessions for the same signal, which apparently I cannot do. But I want to read and write to the same signal I assumed I would need to create 1 Output Session and 1 Input session for the same signal? 

 

How can I read and write to the same signal?

0 Kudos
Message 1 of 8
(4,395 Views)

I made this snippet from a slightly modified CAN Frame and Signal Input Same Port shipping example. The shared interface is capable of both sending and receiving the same signals.

 

SharedInterface.png

 

If something similar doesn't work for you, try posting additional details such at the error you are seeing or a picture of the test code you are using.

Jeff L
National Instruments
0 Kudos
Message 2 of 8
(4,379 Views)

I have 2 signal input session and 2 signal output sessions. All coming from the same interface. I have a vi just to create the sessions. The program itself runs just fine without an error but when I embed that vi creating the session into my main program with no changes to the vi controls I get the following error:

 

Error -1074384883 occurred at XNET Create Session (Signal Input Single-point).vi:6590001

 

I don't understand how I don't get this error in my vi creating the session but I get this error in my main vi when I utilize my create session vi.

0 Kudos
Message 3 of 8
(4,376 Views)

Create Session reserves the memory space that it will require and then XNET Start (Session Only) will then fill those objects with the appropriate data based on the database, properties, etc. XNET Start.vi is called implicitly by XNET Read or XNET write if it hasn't already been called explicitly in your code. There are some interesting details on page 5-447 of the manual.

 

A signal can only be in a single input or output session at a time, i.e. the same signal can't be in multiple input sessions. If there are duplicates in your two sessions then the same frame will be opened twice once the session is started as described above. I think that is what we are seeing here. Are your signals exclusively in one input session or one output session?

Jeff L
National Instruments
0 Kudos
Message 4 of 8
(4,373 Views)

Thanks for the heads up on the XNET Start.vi

Yes, my two input signals come from differing messages and my two output signals come from differing messages while my input and outputs mimic each other.

 

 

Jeff, can I use 1 interface to have two input sessions and two output sessions?

0 Kudos
Message 5 of 8
(4,370 Views)

You can have multiple sessions on the same interface. There are caveats though.

Frames are parents of the signal child so the sessions cannot mix and match the parent frames. 

I modified the example above to include a second input session. It works fine when each session uses signals with unique parent frames. However, if I set the signals so that both sessions contain both parent frames then we get the error you are seeing.

SharedFrameParents.PNG

 

CANEventSignal1 and CANEventSignal2 share a parent frame while CANEventSignal3 and CANEventSignal4 share a different parent frame. If we put 1 and 2 in the same session, 3 and 4 in the other session we don't have any problems. 

 

You haven't said what type of sessions you are using or provided many details about your code. The more details you provide the more accurate and useful my suggestions can be. Is there a reason that you need to divide the signals into separate sessions?

 

Jeff L
National Instruments
Message 6 of 8
(4,362 Views)

Hi Jeff, I really appreciate all the feed back....

one of my signals is multiplexed. My session is "ConfigMultiplexor" and the Signal I need "rear". My second session does not contain a multiplexed signal and it is apart of a a different frame. "MCU_request" 

 

Can I have a session with a multiplexed signal by sending the multiplexor and the signal and then another session that just contains one signal?

0 Kudos
Message 7 of 8
(4,360 Views)
Solution
Accepted by topic author danbecerra

Multiplexed signals do complicate things a little but by nature share a common parent frame. Sessions that include a multiplexed signal must include the multiplexer as part of the signal list for the driver to tell which sub-frame to work with. The multiplexer and multiplexed signals (across all sub-frames) will have the same parent frame so they must all be contained in the same session. 

 

You can have other sessions that use other signals so long as the parent frame of said signals isn't used in any other sessions.

Jeff L
National Instruments
0 Kudos
Message 8 of 8
(4,357 Views)