Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

XNET Set Signal in Frame

Hey,

 

This is more like a suggestion for functionality. I like the new conversion sessions, but it would be nice if you could take an existing frame with some data already in it and set a given signal value in that frame.

 

I believe if you want to do something like that you need to create your own code to find the bit locations of the signal in the frame data, clear them, and then you could use the convert signal to frame and OR the data you converted to to get the payload you want.

 

Thanks,

Kevin Key

 

 

0 Kudos
Message 1 of 5
(7,188 Views)

Hi Kevin,

 

I believe what you're trying to do is shown in the example "Hardware Input and Output >> CAN >> NI-XNET >> Intro to Sessions >> Signal Sessions >> CAN Signal Input Single Point" from the Example Finder.  You're able to select whichever signal you're interested in and write to it.

 

 

Regards,

Che T.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 5
(7,166 Views)

I realize that this is an ancient thread, but I have the same need as Kevin. Che's response does not address the problem. I have frame data (i.e. a CAN frame cluster) and I would like to use the Convert session to generate not a new frame, but to update one signal value inside of the payload before passing it off to a XNET Frame Write. Is this possible without rolling our own code right now?

0 Kudos
Message 3 of 5
(3,970 Views)

I can only think of ways to do this, that involve writing your own code.  One method might be to perform a conversion library and take the frame and get all the signals out of it.  Then replace the one signal, then do another conversion back into a frame.  This would also involve some database reading to find all signals in a given frame.

 

Another option might be to do the conversion from signal to frame on the one signal you want.  Then perform bit replacement taking the current frame, and replacing the bits with the ones from the new frame that only has the one signal.  Both are a bit of a pain and a better solution in my mind is to design your code so you are dealing with signals, not frames, and then keep the previously written values and replace those with each write.

0 Kudos
Message 4 of 5
(3,961 Views)

Hi Hoovah,

 

I ended up taking your second approach. I create one payload with the signal -> frame conversion that has the signals of interest, and I used the "original" payload. I then perform bit masking on the two payloads and ultimately OR them together. The tricky part turns out to be correctly generating the bitmask for the signal within the payload. Being me, I had to make sure that it worked in both big endian and little endian payloads, and across byte boundaries, and so on. If I can get permission to post the code I will.

 

The biggest frustration in all of this is that one still has to pass in the list of signals, rather than just using the conversion session. The "List of Signals" property of the session reference is not valid for conversion session, and this seems like an oversight on the part of NI.

 

Of course it would be better to stick to all signals or all frames, but sometimes reality (legacy code, customer preferences, weird situations that nobody thought of when designing the way it should work (TM), etc.) intrudes.

 

Best regards,

Jason

0 Kudos
Message 5 of 5
(3,944 Views)