11-09-2022 08:23 AM
Hi,
Is there any CAN-FD example (init, read, write, etc.) using NI-XET C API? I only managed to find regular CAN examples.
BR,
Josip
11-09-2022 08:42 AM
If you are using the signal session, there are no changes as most configurations will be pulled from the database.
If you are using the frame session, you can refer to Using CAN and CAN FD in same NI-XNET Interface.
DISCLAIMER: The attached Code is provided As Is. It has not been tested or validated as a product, for use in a deployed application or system, or for use in hazardous environments. You assume all risks for use of the Code and use of the Code is subject to the Sample Code License Terms which can be found at: http://ni.com/samplecodelicense
11-09-2022 08:43 AM - edited 11-09-2022 08:45 AM
EDIT: Sorry I missed that you were asking for a C example. In that case what I said is still true. You just need to set the FD Baud in the XNet Cluster, and set the CAN IO Mode to CAN FD+BRS, or CAN FD depending on your application.
The examples for one, can be used on the other, with only a few minor changes in some cases.
Lets say you use the CAN Signal Input Single Point.vi example. This has an Init, then Read, then Clear. It references an existing database. So if you open the NI XNet Database Editor (it should be in your start menu), you can import a DBC file. When you import it it will ask for the baud settings, and here you can specify the standard baud rate, and the FD rate. Once you do that go back to the example, select the database and signals from the list and hit run. The example doesn't need to be updated at all, you just need to update the database it uses.
Now if you are doing stuff in memory, then yes you do need to specify that the interface is using FD, and to set the FD rate, as well as the normal rate. But the rest of the example shouldn't need to be changed. Attached is an updated CAN Frame Input Stream.vi which just sets the FD Baud rate, but the rest of the example is unchanged.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord