01-03-2007 12:11 AM
01-03-2007 02:18 PM - edited 01-03-2007 02:18 PM
Hi Dillon, you can use the CAN channel API VIs. Check out the CAN Get Property.VI. That'll give you most properties related to the channel. Are you trying to read directly from a Vector CANdb file? Because either you can import that in manually using MAX, or you can do that programmatically using CAN Get Names.VI. I hope that's what you're looking for or at least gives you some ideas.
Message Edited by Sima on 01-03-2007 02:18 PM
01-03-2007 04:06 PM
01-04-2007 09:41 AM
01-06-2009 04:57 PM - edited 01-06-2009 04:58 PM
I think that there has been some misunderstanding with regard to the original question. I believe Dillon is trying to find the start bit and number of bits in the multiplexer. The terminology of multiplexer and mode gets a little confusing. For clarification, my understanding is that a mode is a specific value of a multiplexer. In the case of Dirk's example code, he was able to retrieve the number of bits of the CHANNEL, but not the number of bits of the MULTIPLEXER.
I believe that I have run into a similar problem to Dillon's. I want to read a NI CAN Database (*.ncd) or a Vector CAN Database (*.dbc) programmitically. I have attached a zip containing a VI and some *.ncd file to allow others to see my progress thus far. This is a heavily modified version of Dirk's previously posted program. As you can see, it is easy to get a list of messages using the "CAN Get Names" VI. Using that list of messages, it is also easy to get a list of channels by reusing the "CAN Get Names" VI. The list of channels does not include any information as to whether or not they belong to a multiplexer, but fortunately we can use the "CAN Get Property" VI to find out which channels are mode dependent and the value of the mode that the channel corresponds to (if it is mode dependent). Unfortunately, this does not give us any information as to the location or length of the multiplexer which contains the mode. Thus, I know whether I should be looking for a multiplexer and I know what value to watch for in the multiplexer, but I have no idea where or how to look for that value in the CAN message.
Interestingly, by playing around with Dirk's database that he had attached, I was able to determine that the list of channels does not always give out the same information. Typically, you will simply receive an 1D array strings containing only the channel names, but the output is different in the event that you have a database that meets the following criteria:
1. Two channels (in different modes) have the same name
2. The database contains at least two multiplexers
In this case the output will be a 1D array of strings in which the repeated channels (regardless of whether they are in the same multiplexer) will be output in the format "<message name>.<multiplexer NAME>.<mode value>.<channel name>". The channels that have unique names are simply output as the channel name. Now this is helpful in that by default the multiplexer name contains the start bit of the multiplexer, but this cannot be relied upon. The creator of the database could easily change the name of the multiplexer and the format is only adhered to when the previously mentioned criteria are met. Also it still does not tell us anything about the number of bits expected in the multiplexer (remember Dirk had found the number of bits expected for the CHANNEL).
I have found another alternative output format when the following criteria are met:
1. Two channels (in different modes) have the same name
2. Only one multiplexer is contained within the file
In this case the output will be a 1D array of strings in which the repeated channels will be output in the format "<message name>.<mode value>.<channel name>". Again, this special format is only used for the repeated channels. Uniquely named channels are simply output as channel names. While this is not particularly useful, but I thought I should mention it.
It is also probably worth noting that I found the previously mentioned alternative formats by directly reading reading a *.ncd file. It appears that by reading the channels directly from MAX we get at least one additional format (<message name.channel name> ). Considering that this is actually even less information and since my application specifically requires that I directly read a CAN database without the assistance of MAX, I have not significantly explored this avenue.
Let
me finish by reiterating the question that I am asking: How do you
programmitically determine the start bit and number of bits of the
multiplexers in a CAN database (*.ncd or *.dbc). I have attached a zip
file containg my current "testing" VI and some databases to illustrate
the results that I have described above.
01-07-2009 11:21 AM
Hello All,
You could read the .NCD file using the File IO VIs in LabVIEW. Since the .ncd file is an xml file, you can decode the information you want from it. You can look at this KB to see an example of creating an NCD in LabVIEW. This could get you started on decoding it.
Let me know if that helps at all. Have a great day.
01-07-2009 12:25 PM