05-27-2014 07:20 AM
Hi,
I'm looking for some tricks in order to extract DBC Information using the NI CAN without a CAN interface...
Basically I have some DBC files and I would to analyze them to get hierarchy Messages and Channels (and their related information, offset, scale, etc.).
http://www.ni.com/white-paper/4294/en/
The function CAN Get Names is usefull and allow me depending on the mode to get a list of the Channels and Messages described in the DBC file. However, I'm encountering one major issue and none of the least, I cannot use the function the CAN Get Property... As it required a connector based on Task that I cannot provide since I dont have any real and physical CAN interface, for now. Therefore I cannot have any information about the channels neither about the messages...
Does anybody can give me a hand to fix that matter?
Solved! Go to Solution.
05-28-2014 03:14 PM
Are you using a Series 2 CAN card? Or are you using an XNET device using the old CAN drivers? If you are using XNET hardware please use the XNET drivers. They are newer and better and do a whole bunch of cool stuff. One sign that you should use the new drivers is the article you linked to is almost 5 years old.
Okay with that out of the way, if you are using a Series 2 CAN card then you can't use XNET and you are moving down the right path. If you don't have the hardware, just use one of the two virtual CAN ports, CAN 256, or 257. The driver routes one to the other so you can write on one, and you should see the same values read back on the other. But for you it doesn't matter because all you are trying to do is read the DBC.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
06-08-2014 05:12 AM - edited 06-08-2014 05:13 AM
It seems that no matter the virtual port I am using, it does not work. Could you have a look at my sample.vi, I know it's poorly wired, especially since I'm more in .NET things than NI from my occupation ^^'. I also provided a dummy DBC file to simulate a very basic input.
And by the way is there any way then to get the Byte Array / Bit Array corresponding to a certain message (and how to set the signal values required to get the message)?
06-09-2014 08:05 AM - edited 06-09-2014 08:05 AM
@Nelval wrote:
It seems that no matter the virtual port I am using, it does not work. Could you have a look at my sample.vi, I know it's poorly wired, especially since I'm more in .NET things than NI from my occupation ^^'. I also provided a dummy DBC file to simulate a very basic input.
And by the way is there any way then to get the Byte Array / Bit Array corresponding to a certain message (and how to set the signal values required to get the message)?
Your code isn't that bad, relativly easy to follow. In any case the problem had nothing to do with the CAN port being used. If you would probe the error wires around you would see that coming out of the CAN Init Start stated that the channel name didn't exist. Looking at how you had it wired you took the messages (or frames) and put them into the channels terminal, when I assume you wanted the channels. Then looking at your tree you were again trying to get the ID of a channel, but giving it the message name. I also added reading the Start Bit, Number of Bits, and Byte Order for all the channels read.
If you were to do this with XNET there would be completelly different functions, but the same operations can be done.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
06-15-2014 09:31 PM
Ah thanks for pointing out the X-NET possiblity.
I gave a try and It seems it does not require any specific Virtual Ports. For now, it seems that it works like a charm!
I still have a question about how to get the bit array / byte array representing the frame / signal (channel).
And how to set the value and have this bit array update accordingly to the user input.
06-15-2014 11:02 PM
06-16-2014 09:09 AM
@srikrishnaNF wrote:
Hi Nelval,
If you try to open any dbc or ncd files,baically they are just xml files which have fields,sections,sub sections and items.You can use xml functions to parse them and extract the data without even using any of the CAN pallette functions.
Yeah you could reinvent the wheel, but these functions already exist for parsing DBC data.
I believe the information I posted answers your question. The Bit start and Bit Length will tell you which bits of a frame make up a signal. This with scaling, and byte order information tells you how to go from frame bits to signals.
But why are you needing to know this information? The purpose of a DBC is to obstract this information so you don't need to worry about it. Just give it a DBC and say write RPM to be 2000 and it handles the frame that needs to go out. You should not be doing this conversion yourself.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
06-18-2014 09:13 PM
Hm first I know the purpose of the DBC files and the abstraction it can provide. second DBC files are defintely not XML files, they have nothing to do with... apart maybe that both of those fileformats are relying on text.
Well I have my own Instrument Driver for a specific CAN Instrument, supporting Standard and ISO protocols, i'm willing to send some data, my Instrument Drivers which works with underlying text messages accept a byte array to send a message. How can I get the byte array related to a CAN Frame.
I tried the following diagram but I got the following error:
"Possible reason(s): NI-XNET: (Hex 0xBFF6308F) The function you called is not defined for the session mode (e.g. you called a frame I/O function on a signal I/O session)."
06-19-2014 08:09 AM
Okay you are close, just know that what you want to do can only be done with XNET not the normal series 2 CAN stuff.
Let me first explain why you got the error. You said give me all the signals within a frame and make a session with it for conversion, then you said read all frames on the CAN bus. You can't use a conversion session to read an interface.
What you want is to replace the XNET Read function with the XNet Convert function under the Advanced palette. It is a polymorphic VI and you will want to change it from Signal to Frame CAN. Then give it an array of doubles, where each value corresponds to each signal you made a session for. So if your particular frame has 3 signals you'll want to provide an array with three values. Then the output of the XNET Convert will be the an array of frames, but in your case it should only have one frame in it, because all signals you are converting are in the same frame. If you are doing crazy looping like this then ensure that you are closing interfaces before opening new ones.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
06-19-2014 09:36 PM - edited 06-19-2014 09:36 PM
Hi there,
Thanks, seems it works now.
Thanks for your support.
Still, I think that's the XNET and CAN libraries are a bit hard to handle, kinda powerful but hard to deal with the first time.