Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble Reading and Writing using an NI USB-8473

Hi,

 

I am trying to write some C++ to send and receive CAN data.  I have been using the "Transmit and receive same Port.c" example code as my basis.  The example code works fine, but my code doesn't.  The only difference that I can see is the that in the example code, they are using ncWrite and in mine, I am using ncWriteMult.  The code to set up the CAN network interface object is the same.  I am using a baud rate of 500k.  The code transmits the two test messages okay, I just don't ever receive anything.  I have a neo-VI on the other end that receives the messages from the NI USB device and it also sends a message of its own every second.  I am attaching my code, if that helps, but it is messy right now.  Originally, I had send and receive set up in two different functions, then I merged send and receive into one function.  I have two threads running in the program that calls the functions in this code, the transmit thread executes every second and the receive thread executes every 1/4 second.

 

If anyone has any thoughts, I would be very grateful..

 

Shawn

 

0 Kudos
Message 1 of 2
(6,154 Views)

Hi Shawn,

 

I don't have the means to debug your application at the moment, but do you get any errors from the ncWriteMult or ncReadMutl functions? The function returns error code that will be useful to see if there is an issue. Use the ncStatusToString function to interpret the error code.

When you use the example program are you get CAN Frames transmitted without error? That is, are you able to read the frames with your neo-VI? If not this could be an issue with terminations. Does your code even make it to the if (actualDataSize >= 1) statement to start parsing the data?
Joshua B.
National Instruments
0 Kudos
Message 2 of 2
(6,141 Views)