Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Resetting CAN bus without knowing task reference

Solved!
Go to solution

Good morning everyone,

 

I am using the CAN Channel API to read data coming in from a CAN bus while simultaneously taking measurements using other DAQ hardware. When my VI throws an error after the CAN bus has been initialized and started, attempting to run my VI again will cause the CAN init-start VI to throw an error because the channel was never cleared.

 

Is there a way to clear a CAN channel without having a task reference to wire? How else could I solve this issue?

 

Thanks!

Erik

0 Kudos
Message 1 of 6
(4,397 Views)

Hi Erik,

 

From what I'm understanding, you're using the NI-CAN API and driver, not the NI-XNET, correct?  I'm also understanding that the error is occurring unrelated to the CAN data?  How are you handling shutting down the VI when the error occurs?  We should be able to include the CAN clear.vi at the end of the code so that, even in an error fault, the code still clears the CAN task.

 

I'm also wanting to verify whether this is operating in the development environment or a deployed executable.

 

Regards,

 

-Dave C

Applications Engineer
National Instruments
0 Kudos
Message 2 of 6
(4,376 Views)

Good morning,

 

Yes, that is correct, I'm using the NI-CAN API instead of XNET. This is operating in the development environment, not as a deployed executable.

 

I'm not currently doing much error handling; there's a lot going on in this VI, and we haven't matured it to do error handling yet. Is there another solution?

 

Thanks!

Erik

0 Kudos
Message 3 of 6
(4,371 Views)
Solution
Accepted by topic author ekabo

Hi Erik,

 

Is the error that you're experiencing coming from the same function on a regular basis?  If so, what can be done prior to adding error handling to the entire application, you can add a case structure, use the error cluster from that function to act as the selector for the case structure, and add a Clear Channel command to the true case of the structure followed by an error handler.  

 

Now, that said, I still recommend employing error handling throughout the application, especially if this will be distributed as an executable.  But for development purposes, that may be the quickest way to implement a Clear function on failure in the VI so that it will restart correctly on the next iteration.

 

Regards,

 

-Dave C

Applications Engineer
National Instruments
0 Kudos
Message 4 of 6
(4,364 Views)

I have the same problem, yet I can't find CAN Clear VI any where in my development system.  What is the path please?

0 Kudos
Message 5 of 6
(4,131 Views)

Hi,

 

You will find the CAN clear VI in the next path: Measurement I/O >> CAN >> Channel API >> CAN Clear VI. If you want to know how this VI looks like, take a look to the link below (topic #9). http://www.ni.com/white-paper/4294/en#toc9

 

If you are still not able to find the VI please check if you have installed in your computer the NI-CAN driver (you can check if this driver is listed on MAX under Software). If not, you can download it from the next link.

 

http://joule.ni.com/nidu/cds/view/p/id/3152/lang/en

 

Regards,

 

MCOTO

0 Kudos
Message 6 of 6
(4,116 Views)