Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

Polled NI-USB-8473 seems to occasionally return uninitalized data array.

I'm polling an NI-USB-8473 every 1 millisecond using the following software (vb.net):

 

status = ncWaitForState(_ObjectHandle, NC_STATE_ENUM.NC_ST_READ_AVAIL, 100, CurrentState)                   

If ((status = NC_SUCCESS) AndAlso _

    ((CurrentState And NC_STATE_ENUM.NC_ST_READ_AVAIL) > 0)) Then

 

    status = ncRead(_ObjectHandle, Marshal.SizeOf(can_struct), can_struct)

    If (status = NC_SUCCESS) Then

        ' Queue received message for processing.

    End If

End If

It seems that occasionally a CAN message struct is returned with an uninitialized/unassigned Data array, which results in an exception when the array is accessed.

I can easily check for this condition, but I assume that a frame is being lost every time this happens.

This happens during a software download operation that doesn't tolerate lost frames.

I'm hoping that someone can point me to a solution.

Thanks for taking the time to read this.

0 Kudos
Message 1 of 4
(6,453 Views)

How are you distinguishing between different types of frames (remote, data, ack, etc)? My first thought is that the frames you're receiving with the uninitialized data frames are remote frames which have no data field. Are you filtering out all the non-data frames before you try and process the data?

 

Regards,

Ryan K.
Product Manager, ATCA and BEEcube
National Instruments
0 Kudos
Message 2 of 4
(6,432 Views)

Thanks for your reply.

I'm not currently filtering non-data frames.

I'm not expecting any non-data frames from the engine actuator that I'm connected to.

I can certainly check the frame types though to see what turns up.

0 Kudos
Message 3 of 4
(6,428 Views)

Yes, I'd recommend at least implementing the filtering to see if that makes a difference. I'd also be interested to see if you see similar behavior running one of the text-based examples that ships with the NI-CAN driver. I've linked a document below that outlines where those examples are installed on your machine.

 

Where Can I Find NI-CAN Text Based Examples?
http://digital.ni.com/public.nsf/allkb/C5BA0C0A7D37019F8625758D005192F9

 

Try running one of the CAN receive examples and see what results you get.

 

Regards,

Ryan K.
Product Manager, ATCA and BEEcube
National Instruments
0 Kudos
Message 4 of 4
(6,416 Views)