Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

dual card, two independent networks?

Hello,

I like to use a pci-can/2 card as adapter for two independent CANetworks, but this works not as I would expect.
I have to use the Frame-API, because I coded more or less an analyzer application. During initialization of the application, the both CAN Network Objects "CAN0" and "CAN1" are opened with the same attributes. What happens is that I get back the same handle for those, in my opinion different and independent, devices. The transmission of Frames seems to work correctly, but the received frames are stored in the same input queue so that I can not find out wich frame was received on which network.
What I would expect is, that the driver maintains indepent queues for both Objects ("CAN0" and "CAN1"). Is'nt that right?

The system is a Windows XP Sp2 Box with the ni driver version 2.4. Currently there is one pci-can/2 board installed. The programming language is C, using Visual Studio 6. The application is compiled as a multithreaded application in oder to run one thread for each CANetwork.

I hope someone can help me,
best regards,

mp.
0 Kudos
Message 1 of 4
(4,786 Views)

Hi,

You can configure both ports using the same attributes, but if you open the handles, they have to be different, in order to work. The driver takes care of that.

The memory should be different for both Network Interface Objects. Thus you should not see any frame from port 1 within the queue of Port 0.

You should use the NI Spy to log your API calls to see more details. The Spy comes with the driver and you can start it from START>> Programs>>National Instruments.

Attached you can find an example.

0 Kudos
Message 2 of 4
(4,780 Views)
Hi,

thank you for your help. NI Spy showed me the same as the debugger: The same handle was returned for the two calls of ncOpenObject(). Now I changed my code and it works.

NI Spy show me that the process and thread ID might be used by the driver. Previously I tried to open both ports within the main thread. Now I changed the code that way, that each port is opened by the thread that polls it. And now it works!

Best regards,
mp.

P.S.: I don't know if it is a feature or a bug. If it is a feature it should be documented somewhere...


0 Kudos
Message 3 of 4
(4,775 Views)
Should different object handles be returned when opening them on the same thread?  Is mp2's problem an expected behavior?
0 Kudos
Message 4 of 4
(4,506 Views)