From Friday, January 17th 11 PM CDT (January 18th 5 AM UTC) through Saturday, January 18th 11:30 AM CDT (January 18th 5:30 PM UTC), ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

CAN LabVIEW

Solved!
Go to solution

Hi! All     

     Now I use "CAN" and want to send 8 commands in a program, among which 6 commands have the same frame ID. The following is part of the screenshot of my program. My problem now is that what I read is the result after the execution of the first command, and I want to see the result of the execution of the following commands. If not, do I have to break them down into steps using TestStand?The ID of the third through eighth commands must be 773.My program now has to loop through the first to third commands.Fourth to eighth command, just run it once, so for fourth to eighth command I used a parallel structure.

xiaosanhe1224_0-1678348403169.png

xiaosanhe1224_1-1678348427463.png

 

xiaosanhe1224_2-1678348452540.png

please help me. Thanky you.😭

0 Kudos
Message 1 of 11
(1,596 Views)
Solution
Accepted by topic author xiaosanhe1224

The idea of CAN is actually to use different IDs to be able to distinguish messages. If you send out 5 messages to ID 500 and the counterpart would reply using the same ID or a specific ID that is connected to 500, then the replies would also all have the same ID. You couldn't sort of to which of the 5 sent messages which reply belongs. The code you built is also asynchronous.

 

I would do it differently. The loops are only for sending and receiving, they don't define the ID. The ID and the related payload would be placed in variables outside of these two loops. The outer loop would this way define what to send and when. 

0 Kudos
Message 2 of 11
(1,564 Views)

It sounds like you have some kind of command and response API.  For this you will likely want some of your code to be in series, where you send the command, and then wait for the specific response with some kind of timeout.  Part 6 of my CAN blog goes over the multiple different XNet session types, which can help in waiting for various responses.

0 Kudos
Message 3 of 11
(1,561 Views)
Solution
Accepted by topic author xiaosanhe1224

Hi MaSta,

 


@MaSta wrote:

The idea of CAN is actually to use different IDs to be able to distinguish messages.


CAN allows for "multiplexing" messages. The CAN driver handles such messages by parsing the "multiplexer" value. So one ArbID can be used to transfer a large number of signal values…

 

I had to implement such messages just two weeks ago and now I know the (old) NI-CAN driver handles multiplexed messages off-the-shelf (when the DBC is well-defined)!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 11
(1,556 Views)
Solution
Accepted by topic author xiaosanhe1224

XNet also handles multiplexed signals fairly well.  However I found a few behaviors of it to what I would consider a bug.  When I developed the Frame Signal conversion I changed the behavior of these conversions to be in line with what I thought they should be.

 

But still since OP was talking about seeing a response, I suspect they are doing something else like the ISO15765, UDS, KWP2000, or some other command response scheme.

0 Kudos
Message 5 of 11
(1,553 Views)