LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

CANFD communication with vxlapi

Solved!
Go to solution

Dear Mr. TroyK 

 

I have used your Labview wrapper in CAN communication so far.

Thank you very much for your great job. It has helped me a lot for long time.

 

Now, I'm trying to make CANFD communication with vxlapi (it's XL-Driver-Library_V11.0.14 released by Vector in March 2019).

But I couldn't succeed to make CANFD communication with "Vector VN1610" hardware and the above version xl-Driver-library.

(I configured VIs with watching the "XL_Driver_Library_Manual_EN.pdf" to trace the specification)

 

Please see the attached "CANFD.zip" if you have time.. The file is my try.

If possible, would you please point out the bad points?

 

Best regards,

K.Amano

0 Kudos
Message 1 of 21
(9,297 Views)

Your XLcanFdConf struct doesn't look quite right.  It is missing the 'options' item.

I'm pretty sure xlCanReceive can only get 1 event at a time, not an array.

Troy - CLD "If a hammer is the only tool you have, everything starts to look like a nail." ~ Maslow/Kaplan - Law of the instrument
Message 2 of 21
(9,236 Views)

Hello Super man Troy

 

Thanks to your advice, my VIs works better!

Thank you very much!

 

By the way, in the "xl Can Receive.vi", struct/cluster is messed..

Is the struct appropriate?

It doesn't look smart..

 

Best regards

Amano

 

 

0 Kudos
Message 3 of 21
(9,233 Views)
Solution
Accepted by topic author kojiamano

@kojiamano wrote: By the way, in the "xl Can Receive.vi", struct/cluster is messed..

Yes you're right, it looks messed.

I think you have misunderstood how a UNION type works.

Each event received is 128 bytes.  You can just allocate a 128 byte array to get the event then extract the data from that.

Don't forget that the receive level returned by the v4 interface is a byte count, not an event count.

Troy - CLD "If a hammer is the only tool you have, everything starts to look like a nail." ~ Maslow/Kaplan - Law of the instrument
Message 4 of 21
(9,220 Views)

Hello TroyK

 

>Each event received is 128 bytes.  You can just allocate a 128 byte array to get the event then extract the data from that.

>Don't forget that the receive level returned by the v4 interface is a byte count, not an event count.

 

>I'm pretty sure xlCanReceive can only get 1 event at a time, not an array.

 

Thanks to your advice,  I succeeded to make CANFD communication normaly!

 

I quit to connect array as input/output.

Instead, I connected the cluster which contained over 128bytes size.(The cluster doesn't contain any array) Then I succeeded.

Thank you very much!

 

*But when the cluster contains the array, labview crashes every time I run the VI.

 Do you know why?

 

 

0 Kudos
Message 5 of 21
(9,206 Views)

@kojiamano wrote: ...when the cluster contains the array, labview crashes every time I run the VI.  Do you know why?

If the size of the array in the cluster isn't exactly what the function needs to be allocated then memory corruption or access violation will occur.  LabVIEW will crash.  I'm not sure, but it may also have something to do with the way LabVIEW allocates memory in complex clusters that contain arrays.  They don't get passed as function parameters to a CLFN very well.

Troy - CLD "If a hammer is the only tool you have, everything starts to look like a nail." ~ Maslow/Kaplan - Law of the instrument
0 Kudos
Message 6 of 21
(9,203 Views)

Hello TroyK

 

I tried to send a message in CANFD communication while receiving CANFD data from my DUT.

 

I had no problem in receiving, but I failed to send message in CANFD. (it's not DUT problem because the Canalyzer could send the same message)

 

I tried to make the "xlCanTransmitEx" function with viewing the specification "XL_Driver_Library_Manual_EN.pdf" I also attached.

But  the "xlCanTransmitEx" function returned error "vector xl driver error 132 XL_ERR_INVALID_TAG"..

 

Could you figure out the bad point in my VIs attached?

(Sorry for taking your time again..)

 

Best regards

K.Amano

 

 

Download All
0 Kudos
Message 7 of 21
(9,186 Views)
Solution
Accepted by topic author kojiamano

See XL Driver Library document section 5.5.1 XLcanTxEvent.
For a CAN-FD transmit (using xlCanTransmitEx) the tag parameter needs to be set to XL_CAN_EV_TAG_TX_MSG (0x440).

 


You will also need to make sure the msgFlags parameter is set correctly:
5.5.2 XL_CAN_TX_MSG
msgFlags
Set to 0 to transmit a CAN 2.0 frame.
XL_CAN_TXMSG_FLAG_BRS - Baudrate switch.
XL_CAN_TXMSG_FLAG_HIGHPRIO - High priority message. Clears all send buffers then transmits.
XL_CAN_TXMSG_FLAG_WAKEUP - Generates a wake up message.
XL_CAN_TXMSG_FLAG_EDL - This flag is used to indicate an extended CAN FD data length according to the table below.
XL_CAN_TXMSG_FLAG_RTR - This flag is used for Remote-Transmission-Request. (Only useable for Standard CAN messages.)

Troy - CLD "If a hammer is the only tool you have, everything starts to look like a nail." ~ Maslow/Kaplan - Law of the instrument
Message 8 of 21
(9,128 Views)

Hello Troy

 

>For a CAN-FD transmit (using xlCanTransmitEx) the tag parameter needs to be set to XL_CAN_EV_TAG_TX_MSG (0x440).

 

Thanks to your advice, I could also send the can message in canfd communication normaly!

 

By the way, where does the value "XL_CAN_EV_TAG_TX_MSG (0x440)" come from?

I retrieved in the specification with the word "XL_CAN_EV_TAG_TX_MSG" or "440" , but they are not found..

 

Are they in another Vector's document?

 

K.Amano

0 Kudos
Message 9 of 21
(9,107 Views)

The Vector XL Driver Library installs with examples.  In the bin folder there is vxlapi.h

[C:\Users\Public\Documents\Vector XL Driver Library\bin]

In this .h file you will find all the #defines for constants with their values.

 

If I search the XL Driver Library document for XL_CAN_EV_TAG_TX_MSG it takes me straight to section 5.5.1.

But the actual value for that constant is in the header file.

Troy - CLD "If a hammer is the only tool you have, everything starts to look like a nail." ~ Maslow/Kaplan - Law of the instrument
0 Kudos
Message 10 of 21
(9,102 Views)