Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QtConcurrentRun calls non-qt function
Forum Updated to NodeBB v4.3 + New Features

QtConcurrentRun calls non-qt function

Scheduled Pinned Locked Moved General and Desktop
14 Posts 2 Posters 2.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sharethl
    wrote on last edited by
    #3

    [quote author="SGaist" date="1424711613"]Hi,

    QtConcurrentRun doesn't need your function to be Qt specific. Can you share the code of that function ?[/quote]

    Here is QtConcurrentRun function.
    _brc is an object in non-qt library.
    Usually crash(show disassembler view) after line 5.

    @void Spectrometer::doScanning()
    {
    if(_isFunctional==false) return; // disable operation if not functional

    int result = _brc->startAcquiring();
    
    //emit dataAcquisitionFinished(); // tell manager this data has been acquired.
    
    quint16 dataBuffer[SpectrometerData::PIXEL_NUM];
    if(result == 1){
        result = _brc->getYData(dataBuffer);
    }
    else{
        // TODO:add error message box
        return;
    }
    
    _data_ptr.data()->updateUid(); // make new id to avoid duplication.
    
    //for flipped Spectrometer
    for(int i=0;i<SpectrometerData::PIXEL_NUM;i++){
        auto y = dataBuffer[SpectrometerData::PIXEL_NUM-i-1];
        _data_ptr.data()->updateY(i,y);
    }
    
    _isWorking=false;
    qDebug() << "Scan Finished";
    emit scanFinished();
    

    }@

    @bool BRC::startAcquiring(){
    char cmd[]="E\r\n";
    int cmdLength = strlen(cmd);
    if (write(_fd, cmd, cmdLength) < cmdLength){
    return false;
    }
    return (wait("DR",cmdLength+7, _timeout));
    }@

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #4

      You are trying to write on the same file descriptor from several thread at once ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • S Offline
        S Offline
        sharethl
        wrote on last edited by
        #5

        [quote author="SGaist" date="1424727828"]You are trying to write on the same file descriptor from several thread at once ?[/quote]

        No, BRC is a class, and each BRC object has its own file descriptor.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #6

          Can you also show your call to QtConcurrentRun ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • S Offline
            S Offline
            sharethl
            wrote on last edited by
            #7

            Device manager contains two spectrometers,

            @bool DeviceManager::scan()
            {
            _meter0->scan(); // scan in parallel
            _meter1->scan(); // scan in parallel
            return true;
            }@
            @bool Spectrometer::scan()
            {
            _progress = 0;
            emit reportProgress(_progress);
            // this will run parallel
            QtConcurrent::run(this,&Spectrometer::doScanning);
            _isWorking=true;
            return true;
            }@

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #8

              Then are you sure that _brc is properly allocated ? That both are no trying to access the same resources at the same time ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • S Offline
                S Offline
                sharethl
                wrote on last edited by
                #9

                _brc is a pointer in Spectrometer class.
                and I use new BRC() in Spectrometer's constructor.
                Works most of time.

                and during my app starts up, each _brc did communicate with their corresponding hardware successfully.

                Is it possible to allocate differently with same code but different runs?

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #10

                  What does the backtrace of a crash tell you ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    sharethl
                    wrote on last edited by
                    #11

                    you mean stack trace?

                    two lines of ??

                    [quote author="SGaist" date="1424896978"]What does the backtrace of a crash tell you ?[/quote]

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #12

                      Are you running a debug build ?

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0
                      • S Offline
                        S Offline
                        sharethl
                        wrote on last edited by
                        #13

                        [quote author="SGaist" date="1424993803"]Are you running a debug build ?
                        [/quote]

                        Yes

                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #14

                          Ok, then what does the debugger tell you ?

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          1 Reply Last reply
                          0

                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved