Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I configure CAN objects (extended arbitration ID) to read and read trame ?

I follow the instruction in the manual
but my network analyser display "Error Frame" when I write any frame !!!

this is a basic question but i need help !! thank you
0 Kudos
Message 1 of 5
(4,210 Views)
It helps to have the EXACT error code, because your description seems vaugue. Here are some general things to try.
1. Make sure you have at least 2 devices on the bus. The CAN standard requires any recievers of a message to send an acknoledgement that the message arrived. So if you CAN transmitter is the only one on the bus, it will keep sending the message over and over, and eventually report an error.
If you have a 2 channel CAN interface, loop the 2 channels together, then use the NI Bus Monitor Tool to recieve with the other.

2. Double check the arbitration ID is correct, extended ID's require an extra bit set when you transmit. So even though you want to send 0x1CFFFFFF on the bus, you need to pass 0x3CFFFFFF.

3. Check your baud rate. The CAN standar
d itself doesn't define a specific baud rate, check your Higher Layer Protocol (DeviceNet, CANopen, J1939, K-Line)for the rate you need.

4. If all else fails, check the wiring.
0 Kudos
Message 2 of 5
(4,210 Views)
I am sorry for the vaugue description.
I am beginner with NI-CAN !!

here is the test code (without extended arbitration ID) with Visual C++ and NI-CAN 2.0:

NCTYPE_CAN_FRAME Transmit;
NCTYPE_STATUS Status;
NCTYPE_ATTRID AttrIdList[8];
NCTYPE_UINT32 AttrValueList[8];
char ObjName[] = "CAN0";

AttrIdList[0] = NC_ATTR_BAUD_RATE;
AttrValueList[0] = NC_BAUD_125K;
AttrIdList[1] = NC_ATTR_START_ON_OPEN;
AttrValueList[1] = NC_TRUE;
AttrIdList[2] = NC_ATTR_READ_Q_LEN;
AttrValueList[2] = 10;
AttrIdList[3] = NC_ATTR_WRITE_Q_LEN;
AttrValueList[3] = 10;
AttrIdList[4] = NC_ATTR_CAN_
COMP_STD;
AttrValueList[4] = 0;
AttrIdList[5] = NC_ATTR_CAN_MASK_STD;
AttrValueList[5] = NC_CAN_MASK_STD_DONTCARE;
AttrIdList[6] = NC_ATTR_CAN_COMP_XTD;
AttrValueList[6] = 0;
AttrIdList[7] = NC_ATTR_CAN_MASK_XTD;
AttrValueList[7] = NC_CAN_MASK_XTD_DONTCARE;

Status = ncReset("CAN0",0);

Status=ncConfig (ObjName,8,AttrIdList,AttrValueList);


Status = ncOpenObject(ObjName, &NetIntfObjh);


Transmit.ArbitrationId = 0x05;
Transmit.IsRemote=NC_FALSE;
Transmit.DataLength=8;
Transmit.Data[0] = 0x00;
Transmit.Data[1] = 0x01;
Transmit.Data[2] = 0x02;
Transmit.Data[3] = 0x03;
Transmit.Data[4] = 0x04;
Transmit.Data[5] = 0x05;
Transmit.Data[6] = 0x06;
Transmit.Data[7] = 0x07;

Status= ncWrite(NetIntfObjh, sizeof(Transmit), &Transmit);

Status = ncCloseObject(NetIntfObjh);


thank you for your help
0 Kudos
Message 3 of 5
(4,210 Views)
ARE THERE ANY ERROR CODES FROM THE NI-CAN CARD? Just seeing the code is OK, but it helps if you have any error codes (they are returned in the Return Status of each function). If you checked the 4 items above, and your code still will not execute, contact NI for help.
0 Kudos
Message 4 of 5
(4,210 Views)
The problem is the reset after the port configuration.
If an NI-CAN application is terminated prior to closing all handles, the CanErrNotStopped or CanErrAlreadyOpen error might occur when the application is restarted. By making this the first NI-CAN function called in your application (preceding all ncConfig), you can avoid problems related to improper termination.
0 Kudos
Message 5 of 5
(4,210 Views)