Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

Sending cycling message over the CAN

Solved!
Go to solution

Hi,

 

I'm trying to find the best approach to send the cyclic message consisted of 8 signals. The message and the signals are defied in the XNET database. What I want to do is:

1. Open the session using message name

2. Write message by passing engineering values (array of DBL) to write function opened on session from point 1.

 

I couldn't find any examples.

 

To visualise my approach so far:

Engineering data to send:

hooo01.PNG

Constructing the array with current time:

hooo02.PNG

Approach to send:

hooo03.PNG

 

Error:

Error -1074384753 occurred at XNET Write (Signal Single-point).vi:3310002

 

NI-XNET:  (Hex 0xBFF6308F) The function you called is not defined for the session mode (e.g. you called a frame I/O function on a signal I/O session).

 

0 Kudos
Message 1 of 19
(6,248 Views)

First next time post VIs, or snippets, not pictures.  You wouldn't post pictures of notepad in a text based language forum.

 

Secondly there are plenty of examples shipped with XNet drivers for how to do this.  Go to Help >> Find Examples and search XNet.

 

Third to make your code work you need to define what signals you are going to be writing to.  In the Create Session you need to provide the array of signals you want to write, and then when you write they need to write an array of the same size.  Attached is an example.

 

In your example you used the Queued mode which isn't the one you want you likely want single point.  In Part 6 of my CAN Blog I go over the advanced XNet modes and describe when you might want each mode.

Message 2 of 19
(6,233 Views)

@Hooovahh wrote:

First next time post VIs, or snippets, not pictures.  You wouldn't post pictures of notepad in a text based language forum.


OK

 


Hooovahh wrote:

Secondly there are plenty of examples shipped with XNet drivers for how to do this.  Go to Help >> Find Examples and search XNet.


Because I couldn't find what I wanted amongst all examples that is why I posted it on the forum.

 


Hooovahh wrote:

Third to make your code work you need to define what signals you are going to be writing to.  In the Create Session you need to provide the array of signals you want to write, and then when you write they need to write an array of the same size.  Attached is an example.


That's the whole point of my query. I was looking for a method of writing/sending the messages as are defined in the database, and not to arrange again their signals into the groups and write them. In my scenario I have nine messages, 1 to 9 signals each, sending cyclically at four different intervals and it would be much convenient for developers to refer the messages rather than their particular signals.

 

So from your post I understand this method of sending/writing is not available. 

0 Kudos
Message 3 of 19
(6,215 Views)

MimiKLM wrote: 

That's the whole point of my query. I was looking for a method of writing/sending the messages as are defined in the database, and not to arrange again their signals into the groups and write them. In my scenario I have nine messages, 1 to 9 signals each, sending cyclically at four different intervals and it would be much convenient for developers to refer the messages rather than their particular signals.

 

So from your post I understand this method of sending/writing is not available. 


It is still not clear what you are trying to do.  You started saying you had 8 signals to write, and they look pretty static since they are just time and date in a specific format.  If this is the case why can't you specify the signal names for each value?  That is why I posted the example I did and said to look into the shipped example on writing signals.

 

Now you are saying there is from 1 to 9 signals to write? and the user needs to have some selection on messages rather than signals?  If you want to get the signals inside a frame this is possible using the XNet database API but I still don't have a clear picture of what you want or how it should work.  I'm pretty sure whatever you want it to do it can do, XNet is extremely flexible.

0 Kudos
Message 4 of 19
(6,208 Views)

Ok,

 

Maybe I used some implicit assumptions, so I explain once again.

 

The question I will be asked is will be: "have you send all messages" not "have you send all signals". I know that at the end of the day they mean the same but it would be much convenient to operate on messages as the objects rather than on the signals.

 

So I think that something like described below should exist:

1. open the session using the message name

2. pass to write vi an array (of size of the size the message array which contains all signals belonged to the message) with the engineering values of the signals.

3. loop number 2

4. close the reference and exit the program

 

Rather than existing

1. open the session based on an array with the signals disassembled from the already defined messages

2. pass to write vi an array consisted with these signals

3. loop number 2

4. close the reference and exit the program

 

PS: I've stated that I have a message (it is called timeDATE_VAR2) consisted of eight signals, just to visualize my situation. If I know how to sent one message (as per message, not per group/array freely chosen signals) then I could send rest of them

0 Kudos
Message 5 of 19
(6,203 Views)
Solution
Accepted by topic author MimiKLM

Okay how about this solution.  I think this demonstrates all the pieces of what you need but maybe isn't in the form you want yet.  You pick the frame which selects all the signals in that frame and sets their default values.  The user can then change the values, and click Start which will set those values, with those signals.  I'm not sure how you would want to visualize multiple frames (tabs? subpanels? a tree control?)  But it could be done.

Message 6 of 19
(6,199 Views)

Dear  

 

0 Kudos
Message 7 of 19
(5,599 Views)

I think the error is pretty clear.  It states that for the session you created, doesn't specify the multiplexer signal and is required since you selected some signals which are multiplexed.  This means you need to add the PS5_Settings_Mux signal to your array of signals to write.  I'm unsure if when you perform the write you now need to write 4 signals, or if the XNet API ignores that since it will be handled by the session.

0 Kudos
Message 8 of 19
(5,590 Views)

pro_screenshot.png
Dear Hooovahh,

 

Thanks for your reply.

According to your indication, I modify the signal lists as the posted figure.

I want to be sure whether the first signal is be sent cyclically with message repetition rate at 500ms?
Your kindly help is important to me to solve the problem I encount.

Thanks again.

 

Best regards,

Kai

0 Kudos
Message 9 of 19
(5,586 Views)

Well then you are going to want to edit that database because I believe that signal is not set to be sent at that rate.  Open the XNet Database Editor and look at change that frames retransmit rate.  This can also be edited programatically with the database editing API.  Examples can be found in Help >> Find Examples on how to do this.

0 Kudos
Message 10 of 19
(5,584 Views)