当前位置:网站首页>BM setup process

BM setup process

2022-06-25 14:51:00 -Ximen blowing snow

The whole idea is ,

  1. Turn on the device first ,devic.getDeviceId() This is the initialized device id

  2. Create cache

  3. start-up bm, The filter is set at the beginning 31RT Address

  4. Start the thread to constantly crawl

  5. Set different filter rules during

  6. Closed post clean cache ,

Here's the initialization bm Of . initialization bm Then a thread is opened BusMonitorDataReadThread, Keep reading data

 //  status = boardCom.bmFilter(devic.getDeviceId(), 1, 0XFFFFFFFF, 0XFFFFFFFF);
   // This is the beginning of setting up a filter 
   status = boardCom.bmFilter(devic.getDeviceId(), 31, 0XFFFFFFFF, 0XFFFFFFFF);
   LogSingleTon::getInstance()->bmMsgLog(" Filter setting parameters " + QString::fromStdString(ADT_L1_Error_to_String(status)));
   if(status == ADT_SUCCESS) {///> Set filter successfully 
     // Set up BM Capture memory ,READ_MSGS_NUM Bus message caching for development 
     status = boardCom.bmBufferSet(devic.getDeviceId(), READ_MSGS_NUM);
     if(status == ADT_SUCCESS) {///> Memory development succeeded 
       // start-up BM function 
       status = boardCom.bmStart(devic.getDeviceId(), true);
       if(status == ADT_SUCCESS) {
         // Create a thread , And start grabbing , This is a direct grab bm  in cdp The thread of ,READ_MSGS_NUM1000 individual 
         BusMonitorDataReadThread *readDataThread = new BusMonitorDataReadThread(devic.getDeviceId(), READ_MSGS_NUM);
         connect(this, SIGNAL(stopReadData()), readDataThread, SLOT(recControlStopSignal()));
         connect(readDataThread, SIGNAL(bmDataReadThreadGenInfor(QString)), this, SLOT(recBmInfor(QString)));
         readDataThread->begin();///> Thread start 
         // Interface enable 
         ui->stopBM->setEnabled(true);
         ui->start->setEnabled(false);
       } else {
         msgs = "BM  Boot failure ";
         msgs += ADT_L1_Error_to_String(status);
         LogSingleTon::getInstance()->errorOutPut(msgs);
       }
     } else {
       msgs = "BM  memory allocation failed ";
       msgs += ADT_L1_Error_to_String(status);
       LogSingleTon::getInstance()->errorOutPut(msgs);
     }
   } else {
     msgs = "BM  Failed to set filter ";
     msgs += ADT_L1_Error_to_String(status);
     LogSingleTon::getInstance()->errorOutPut(msgs);
   }

The thread code is as follows : The main function is to read messages and process them

ADT_L0_UINT32 status;
  ADT_L0_UINT32 numMsgs;///> The actual number of messages read 
  BaordCommon boardCom;
//  ADT_L1_1553_CDP bmMessages[20];
  ADT_L1_1553_CDP bmMessages[1000];
  // Loop data 
  while (!stopped) {
    if(!paused) {///> threading 
      // Read message 
      status = boardCom.bmReadNewMsgs(deviceId, msgNums, &numMsgs, bmMessages);
      if(status == ADT_SUCCESS) {
        QFuture<void>w = QtConcurrent::run([ = ]() {
          QString msgInfo;
          //          qDebug() << "BM data fetch " << numMsgs;
          /* BM The captured data is displayed  */
          for (uint i = 0; i < numMsgs; i++) {
            /*  Show basic messages  */
            if(bmMessages[i].STS1info != 0xffffffff) {
              msgInfo.clear();
              msgInfo += "  Message count :" + convert.intToBigEndianByteArray(QString::number(bmMessages[i].BMCount).toInt()).toHex();
              msgInfo += "  Time high :" + convert.intToBigEndianByteArray(QString::number(bmMessages[i].TimeHigh).toInt()).toHex().toUpper();
              //              msgInfo += "  Time low :" + convert.intToBigEndianByteArray(QString::number(bmMessages[i].TimeLow).toInt()).toHex().toUpper();
              msgInfo += "  Time low :" + QString::number((bmMessages[i].TimeLow * 20) / 1000000);
              msgInfo += "  Message interval :" + QString::number(bmMessages[i].IMGap / 100) + QString("\n"); ///>100ns The interval of 
              msgInfo += " CMD1: "   +  convert.intToBigEndianByteArray(QString::number(bmMessages[i].CMD1info & 0xFFFF).toInt()).toHex().toUpper();
              msgInfo +=  wordPasre.getCommandInfo( bmMessages[i].CMD1info & 0xFFFF);
              msgInfo += " STS1: "   + convert.intToBigEndianTwoBytes(QString::number(bmMessages[i].STS1info & 0xFFFF).toInt()).toHex().toUpper() + QString(" ");
              msgInfo += " CDP Status word : "   + convert.intToBigEndianTwoBytes(QString::number(bmMessages[i].CDPStatusWord & 0xFFFFFFFF).toInt()).toHex().toUpper() + QString("\n");
              for (int j = 0; j < 32; j++) {
                msgInfo += convert.formatDislpay( convert.intToBigEndianTwoBytes(bmMessages[i].DATAinfo[j]));
                if (!((j + 1) % 8)) msgInfo += "\n";
              }
              LogSingleTon::getInstance()->bmMsgLog(msgInfo);
              emit bmDataReadThreadGenInfor(msgInfo);
            }
          }
        } );
        w.waitForFinished();
      } else {
        emit bmDataReadThreadGenInfor(" Message fetching failed ");
      }
      msleep(10);
    } else {///> Thread pause 
      sleep(1);///> Sleep 1 second 
    }
  }

The thread has a function that can receive the set filter information

The code is as follows :

 void BusMonitorDataReadThread::recFilter(ADT_L0_UINT32 rt, ADT_L0_UINT32 rxFilter, ADT_L0_UINT32 txFilter) {
   BaordCommon boardCom;
   filterStatus = boardCom.bmFilter(deviceId, rt, rxFilter, txFilter);
 }
 ​

 

原网站

版权声明
本文为[-Ximen blowing snow]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202200518257883.html