Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

Using ncAction to Start & Stop CAN objects

Hello,
I have to start and stop CAN Objects and I have unexpected results : if I set NC_ATTR_START_ON_OPEN to NC_TRUE in the interface configuration, everything works properly. Then if I set NC_ATTR_START_ON_OPEN to NC_FALSE, ncAction function does not work properly.
I'm using NI-CAN v2.3.

Here is a sample of my code.
 

Any suggestion about that problem ?


0 Kudos
Message 1 of 5
(4,459 Views)

Hi JCX,

I can reproduce your Problem. It seems that there is something wrong with the handles. We work to get it fixed, but it can take a little while.

For the moment the workaround is to start the second Object (ncAction) before you try to Stop it. The new Start will fix  a kind of a handle problem, so you should be able to Stop the Object then.

It should look like this then:

 // Start the network interface and CAN objects
  NiCANErrChkMsgPopup(ncAction (PortHandle, NC_OP_START, 0));  
 
  // Stop the Second Frame
  NiCANErrChkMsgPopup(ncAction (HdleSTD301, NC_OP_STOP, 0)); 
 
// Start the  CAN object
  NiCANErrChkMsgPopup(ncAction (HdleSTD1495, NC_OP_START, 0));  

  // Stop the First Frame
  NiCANErrChkMsgPopup(ncAction (HdleSTD1495, NC_OP_STOP, 0));
 
because the Stop cleanes the message queues, you have to write a new message to the write queue before any restart.
 
hope that helps
 
DirkW
0 Kudos
Message 2 of 5
(4,433 Views)
Thank you for working on it.
0 Kudos
Message 3 of 5
(4,430 Views)

Hi JCX,

We found the problem in the code , but a fix needs a lot of changes to the existing NI CAN/DNet framework.

So we decided to implement this fix with our new 2.4 driver release later this year.

If you feel not comfortable with the workaround and our decision, please contact your local support or sales engineer. He will assist you, to get contact to the CAN PSE for further discussions.

DirkW

 

0 Kudos
Message 4 of 5
(4,356 Views)
Thank you DirkW, we can wait for NI-CAN 2.4 as the function works properly using NC_ATTR_START_ON_OPEN with NC_TRUE. Frames don't start at the same time but it does not seem to be a problem for our application.
0 Kudos
Message 5 of 5
(4,350 Views)