Menu

GetChannelBlocks() TimeChannel Issue

Help
CodeRunner
2014-02-20
2014-02-21
  • CodeRunner

    CodeRunner - 2014-02-20

    Hello,

    I was trying out the MDFLib and was having an issue with MDF files exported from a Kvaser CAN Logger (MDF 3.2). I tracked the problem down to the GetChannelBlocks() code. The code assumed that the first channel in a group was the time channel but my MDF files have the last channel of the group as the time channel. I made the following change to the code so that the time channel is located and placed as TimeChannel for all the channels in a group.

    int MDFlib::MDFChannelGroup::GetChannelBlocks()
    {
        long ptrNextChannel = m_pChannel;
        m_mdfChan = gcnew List< MDFChannel^ >;
        MDFChannel^ time = nullptr;
        int i=0;
    
        while(ptrNextChannel != 0)
        {
            MDFChannel^ newMDFChannel = gcnew MDFChannel(myFile,
                                                         ptrNextChannel,
                                                         m_theData, 
                                                         m_pData, 
                                                         m_NumOfRecs, 
                                                         m_DataRecSize, 
                                                         m_getData);
            newMDFChannel->NumPoints = m_NumOfRecs;
    //if(i == 0) 
    //{
    //    time = newMDFChannel;
    //}
    
            if (newMDFChannel->ChannelType == 1)
            {
                time = newMDFChannel;
            }
    
    //newMDFChannel->TimeChannel = time;
            m_mdfChan->Add(newMDFChannel);
            ptrNextChannel = newMDFChannel->NextChannelPTR;
            i++;
        }
    
        //Set TimeChannel for all of the channels
        for each(MDFChannel^ tempMDFChan in m_mdfChan)
        {
                tempMDFChan->TimeChannel = time;
        }
    
        return 0;
    }
    
     

    Last edit: CodeRunner 2014-02-20
  • Tony Fountaine

    Tony Fountaine - 2014-02-20

    CodeRunner, thanks for the catch. I found that issue as well recently but haven't updated the library on sourceforge yet. I've been making a few changes. Did the library work with the Kvaser files after the modification? I will add that to the list of supported applications if it works. I've been working on adding support for unsorted MDF files that are exported from CANalyzer.

    If you are interested in an early beta of a new viewer send me an email and I will pass it along to you.

     
    • CodeRunner

      CodeRunner - 2014-02-20

      The only other issue that I had with the Kvaser 3.2 MDF files was that the channel datatype was set to 14 (little endian signed integer). Since your code already handled the 1 datatype (default byte order signed datatype) and the default order of the Kvaser MDF is little endian I just inserted "case 14:" into the MDFChannel code and that is working:

          case 1:
          case 14:
                  if(m_numOfBits <= 8)
                      {
                      if(bitsRequired <= 8)
                      {
                          m_Data = gcnew CData<char>;
                      }
                      else
                      {
                          //Data overlaps byte boundary
                          m_Data = gcnew CData<short>;
                      }
      
       
  • Tony Fountaine

    Tony Fountaine - 2014-02-21

    CodeRunner,

    Thanks for the updates! I was mistaken and didn't have your original change in the library. I've added both changes to my copy now.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.