Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

Can I write different length frames to the same CAN object?

We are using a PCI-CAN/2 card and the DDK. Operating system is VenturCom RTX on Windows 2000.

In simulating a servo to an avionics system, we need to transmit frames of two different lengths on the same bus and arbitration ID. For example, the avionics system expects a three-byte response to an initialization command, but an eight-byte response to a position command, and for whatever reason both of these responses must be with the same arbitration ID. ncWrite seems to ignore the data length parameter and instead the length specified in the ncConfig call is always used. Is there a way to get the same CAN object to send different length frames?
0 Kudos
Message 1 of 5
(4,415 Views)
Hi,

You probably used a CAN object (ncWriteObj.vi) in stead of a CAN network object (ncWriteNet.vi). If you use ncWriteNet.vi twice, you can use one for 3 bytes and one for 8 bytes data length. This would probably solve your problem.

Pascal
0 Kudos
Message 2 of 5
(4,415 Views)
I'm not sure what Pascal means. We are using the API in a C program. I'm not familiar with vi files.
0 Kudos
Message 3 of 5
(4,415 Views)
look in the NI-CAN programmer spec. (it came with the NI-CAN libraries/ DLLs). It says:

NCTYPE_STATUS ncWrite(NCTYPE_OBJH ObjHandle,
NCTYPE_UINT32 DataSize,
NCTYPE_ANY_P DataPtr)

Definitions

ObjHandle= Object handle.

DataSize= Size of the data in bytes.

DataPtr= Data written to the object. For C, you provide the data using the pointer DataPtr. For LabVIEW, you provide the data using object-specific input terminals.


so you set your DataSize equal to # of data bytes
0 Kudos
Message 4 of 5
(4,415 Views)
That parameter has no effect. From the bus monitor I can see that the messages are still the size that I specified for attribute NC_ATTR_BKD_WRITE_SIZE in the call to ncConfig for the CAN object, regardless of the value I pass to ncWrite.

I was able to get the desired effect (different length packets on the same arbitration ID) by calling ncWrite on the network interface object, where I specify arbitration ID and size each time, rather than calling ncWrite on a specific CAN object as I had been doing.
0 Kudos
Message 5 of 5
(4,415 Views)