LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Creating Multiple CAN Messages With Library Function Node

Solved!
Go to solution

Hello all,

 A short setup: I'm working with J1939 automotive messages. I already have a vi that will create a message (PGN) with a list of channels (SPNs) and initialize the CAN task.
What I would like to do is modify this vi to be able to initialize multiple PGNs and well as SPNs, or multiple combinations of one PGN to one SPN similarly to when you initialize multiple PGN/SPNs with the .ncd file.

The vi feeds all of the input into the nctlvCreateMessage library function seen here:
CreateMessage.PNG
I'll readily admit that the library functions are a little beyond my understanding. That's why I'm here for help....

Does anyone have some background with using these, and know whether it's possible to input multiple PGN/SPN definitions rather than only one?

0 Kudos
Message 1 of 5
(2,596 Views)

Hi Logan84:

 

      A couple of questions:

1) Is this VI based on an example? If so could you point is to the example?

2) Do you have some documentation for the .dll that is being called with the call library node? Like regarding how it works internally 

 

 

0 Kudos
Message 2 of 5
(2,565 Views)

I apologize, I should probably be giving a lot more information, I'm just unsure what I should and shouldn't post.

I did find an example where this can be seen, so I think I'm safe -
National Instruments\LabVIEW 2013\examples\nican\Channel - Advanced 
In the Create Message with Waveform Input.vi it calls CAN Create Message.vi which is what my current vi is calling to configure the message before starting the CAN task.

As far as how it's configured, again, I don't totally understand this function, so bear with me. The function prototype:
int32_t nctlvCreateMessage(void *MessageConfig, uint32_t NumberOfChannels, const void *ChannelConfigList, int32_t Interface, int32_t Mode, double SampleRate, uint32_t *TaskRef);

0 Kudos
Message 3 of 5
(2,558 Views)
Solution
Accepted by topic author Logan84

Your definitely barking up the wrong tree here! As this is a NI library, which wasn't at all clear from your first post, trying to even look at the Call Library Node is almost always the wrong thing to do. There is nothing there that you could change, so move on and concentrate on this from a higher level. There might be a way to do what you want to do by using the VI in a certain way. I can't help with that as I haven't worked with NI-CAN in years.

But if there isn't a way to do what you want to do on the VI level then the attempt to do it by directly changing the way you call the DLL is doomed to fail. These DLL APIs are usually specially created by NI to interface LabVIEW to some of their lower level drivers. The lower level driver is what can be called from C programs, and has a much lower level API that is sometimes inefficient and inelegant to be called from LabVIEW so they create special DLL wrappers in C(++) that translate between the low level API and a more LabVIEW friendly API. You can not change the way these DLLs need to be called and the specialization to support LabVIEW better is in such a way that it only supports that specific configuration as implemented in the VI. So forget about the diagram of this VI.

Try to understand how the data structures in the VI frontpanel relate to the intended message format and if you can create arrays of message records to pass to the VI to make your multiple CAN messages work.

If you can describe your actual intended CAN message layout in more details someone from NI support should be able to tell you if you can use this VI at all to create that.  

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 4 of 5
(2,544 Views)

Thanks for the info Rolf, that makes sense. It's unfortunate for me at the moment, but makes sense.
I guess I'm on to trying to figure out what my best approach is...

0 Kudos
Message 5 of 5
(2,531 Views)