Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

use both CAN APIs

Solved!
Go to solution

Hi,

 

I am developing an application that talks to a microcontroller.  I would like to use the Frame API for setup where I can send commands and get responses, and would like to use the Channel API for a mode where I am simply monitoring messages that I receive from the micro.

 

I have a state machine where I begin by opening the Frame API, have some different states that i go into which utilize the query/response aspect of the frame API and then a state which closes the Frame API and opens the Channel API.  The problem that I am having occurs when I have already closed the Frame API and started a read task with the channel API.  When I click the stop monitoring button, I exit the While loop which was reading a message defined in the Can DB (havn't actually had it read data yet) and execute the Channel APIs CAN Clear.VI i get the following error.

 

Error - 1074388720 occured at CAN Initialize.vi

 

Possible reasons:

 

NI-CAN (Hex 0xBFF62110) You cannot use the Frame API and Channel API simultaneously on the same interface (such as CAN0).   tools in MAX use the Channel API.  Soultuon: Use a different interface with each API.

 

 

I need a way to work around this and am not sure why the Frame API isn't seeming to be closed, especially since I have a state in my state machine to close the Frame API before I begin using the Channel API.

 

If anyone has any suggestions please let me know.

 

Thanks,

Gary

0 Kudos
Message 1 of 12
(9,242 Views)

Hey glstill,

 

What CAN device do you have?

 

Thank you,

Ryan

National Instruments
Applications Engineer
0 Kudos
Message 2 of 12
(9,227 Views)

I have a couple different devices.  I have a pcmcia card 2 port hi speed series 2 and i also have a pc card 2 port hi speed.  I am using NI can 2.6.

 


The transceiver on the micro is also a Phillips TJ104x.  I am going to attach a small test application where you can easily see what is going on. 

There is a state machine that goes back and forth between the two APIs and you click the top stop button to go into the channel API and when you click the bottom stop button the error occurs.

0 Kudos
Message 3 of 12
(9,224 Views)
you need this control to run it.
0 Kudos
Message 4 of 12
(9,223 Views)

sorry i will attach it all again so it can be run.  Use this VI.  it has a tab control.  when the program starts, the frame api is running and then you click stop and switch the tab to see the channel api running.  when you click the stop button on the channel api you should see the error.

 

the error has been occurring every time, but when i just ran it, it didnt give that error.  I still think the problem exists and I see the problem in my real app that basically does the same thing.

0 Kudos
Message 5 of 12
(9,222 Views)

The problem is that you probably left a handle open when switched to the channel api part. That alleays happens if you stop a VI with the red LabVIEW Stop button from the menu.

Since your program went back to the frame api and din't have a way to stop it you probably used that LabVIEW stop. That breaks the execution and doesn't call the close function. Thus a handle is still open and the channel api cannot be used.

See the modified example, that works now.

 

DirkW

Message 6 of 12
(9,211 Views)

Thank you for the response.

 

The problem that I am encountering is that I want to be able to go back and forth between the APIs by switching states.  I know that the stop button isnt wired to stop the for loop, I was just using it to go back and forth between the states.  The fix that you sent me doesn't try to make them go back and forth.  How can I go back and forth on the same port (can0)?

 

 

0 Kudos
Message 7 of 12
(9,207 Views)
Solution
Accepted by topic author glstill

Thats more a LabVIEW question but because its you, here is an example that allows switching back and forth and Exit if you set the exit checkmark.

 

DirkW

0 Kudos
Message 8 of 12
(9,179 Views)
thank you.  Im using 8.2 and i guess it won't let me open it.  is it possible for you to save it in a way where I can open it with 8.2?
0 Kudos
Message 9 of 12
(9,177 Views)

Hey,

 

Here is the VI saved in LabVIEW 8.2.1.

 

Thank you,

Ryan

National Instruments
Applications Engineer
Message 10 of 12
(9,174 Views)