Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading the mode channel start and no. of bits using the CAN channel API

Currently I am using the CAN channel API to get information from a CANdb file.  I'm using it to get max, min, scaling information, etc.  However, I can not use it to get the start bit and the number of bits in the channel mode when using mode-dependant channels.  Is there an easier method to retrieve this information using one of the CAN API's instead of manually parsing the file myself for the information?
0 Kudos
Message 1 of 7
(6,213 Views)

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

Message 2 of 7
(6,205 Views)
Thats just about what I am currently doing.  Using CAN Get Names and CAN Get Property to access a Vector CANdb file.  The problem is that while CAN Get Property will retrieve the mode value for that channel, it can not retrieve the mode start bit or the mode number of bits for the message its part of.  I'm still thinking that I'm going to have to manually parse the file after looking over the problem again today.
0 Kudos
Message 3 of 7
(6,193 Views)
Hi,
 
In order to get the mode channel "number of bits "information you have to use the point notation to specify the mode channel. See the attached example. The channel string is  "test.MUX3.1.Test1" for the channel Test1 in mode 1 for Multiplexer MUX3 in message test.
 
DirkW
0 Kudos
Message 4 of 7
(6,182 Views)

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.

 

Message Edited by William Griffin on 01-06-2009 04:58 PM
William Griffin
NI Certified LabVIEW Architect
NI Certified Professional Instructor
Spark Embedded
https://sparkembedded.com/
0 Kudos
Message 5 of 7
(5,697 Views)

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.

O. Proulx
National Instruments
www.ni.com/support
0 Kudos
Message 6 of 7
(5,677 Views)
Thank you for the advice and the link. I am aware of this possibility, but I thought I would first see if there is a LabVIEW CAN function to access the data. It seems to me as though this would be a necessary piece of information when reading CAN files, so I am surprised that I cannot find a function within the NI CAN VIs to handle this. As far as I can tell, this is the only relevant information in the CAN database that I cannot access using the NI CAN VIs. If this does not exist then I will look into directly reading the XML file.
William Griffin
NI Certified LabVIEW Architect
NI Certified Professional Instructor
Spark Embedded
https://sparkembedded.com/
0 Kudos
Message 7 of 7
(5,671 Views)