Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Question withdrawn - Passing system function to QProcess - need syntax help

Question withdrawn - Passing system function to QProcess - need syntax help

Scheduled Pinned Locked Moved C / C++ / MFC
c++linuxhelpquestionlearning
3 Posts 2 Posters 6 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    I think I need to withdrew this question. After digesting more QT doc I realized that QProcess is NOT starting a new thread , hence in my case of time consuming "scan" it is just wrong to use it. QT has a "concurrency" "feature" which does start multiple threads... ]

    system("hcitool -i hci0 scan --flush ");

    This "system call " works as expected - it finds nearby Bluetooth devices in allotted time - - up to 15 seconds. I use is instead of many "bluez" library derived function because it works CONSISTENTLY... Because it blocks running thread for up to 15 seconds I like to utilize QT . "QProcess" object. I have it working using convoluted "bash" code

    OProcess.start("/bin/sh", QStringList() << "-c" << "hcitool -i hci0 scan --flush >> /tmp/temp");

    and like to utilize it WITHOUT "bashing". Something like this

    QProcess::execute("system("hcitool -i hci0 scan --flush "));
    

    of course it does not compile, hence I am here posting this. Any "unbashed" suggestions would be appreciated - in C or C++ . PS there are more options to be added to basic "hcitool" command.

    K 1 Reply Last reply
    0
    • L Lost User

      I think I need to withdrew this question. After digesting more QT doc I realized that QProcess is NOT starting a new thread , hence in my case of time consuming "scan" it is just wrong to use it. QT has a "concurrency" "feature" which does start multiple threads... ]

      system("hcitool -i hci0 scan --flush ");

      This "system call " works as expected - it finds nearby Bluetooth devices in allotted time - - up to 15 seconds. I use is instead of many "bluez" library derived function because it works CONSISTENTLY... Because it blocks running thread for up to 15 seconds I like to utilize QT . "QProcess" object. I have it working using convoluted "bash" code

      OProcess.start("/bin/sh", QStringList() << "-c" << "hcitool -i hci0 scan --flush >> /tmp/temp");

      and like to utilize it WITHOUT "bashing". Something like this

      QProcess::execute("system("hcitool -i hci0 scan --flush "));
      

      of course it does not compile, hence I am here posting this. Any "unbashed" suggestions would be appreciated - in C or C++ . PS there are more options to be added to basic "hcitool" command.

      K Offline
      K Offline
      k5054
      wrote on last edited by
      #2

      The docs are pretty clear: [QProcess Class | Qt Core 5.15.8](https://doc.qt.io/qt-5/qprocess.html#:~:text=int QProcess%3A%3Aexecute(const QString %26program%2C const QStringList %26arguments)) Try

      QProcess::execute("hcitool", "-i chio scan --flush");

      since hcitool is part of the bluez package, it almost certainly uses the bluez library to do its work. If you can get hold of the source code, you should be able to look through it and find out why they make it work the way you expect it to.

      Keep Calm and Carry On

      L 1 Reply Last reply
      0
      • K k5054

        The docs are pretty clear: [QProcess Class | Qt Core 5.15.8](https://doc.qt.io/qt-5/qprocess.html#:~:text=int QProcess%3A%3Aexecute(const QString %26program%2C const QStringList %26arguments)) Try

        QProcess::execute("hcitool", "-i chio scan --flush");

        since hcitool is part of the bluez package, it almost certainly uses the bluez library to do its work. If you can get hold of the source code, you should be able to look through it and find out why they make it work the way you expect it to.

        Keep Calm and Carry On

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        I did try "splitting " program and argument - it did not pass compiler. Then I put all as a single parameter and it did not run at all.

        OProcess.start("/bin/sh", QStringList() << "-c" << "hcitool -i hci0 scan --flush | tee >> /tmp/temp"); no tee ourput to console - not that important
        qDebug() << OProcess.state(); returns "process starting" expected
        qDebug() << OProcess.state(); returns "process starting" sort of expected
        OProcess.waitForFinished();
        //OProcess.state();
        qDebug() << OProcess.state(); return process not running expected

        OProcess.execute("hcitool-i hci0 scan --flush >>/tmp/temp");
        qDebug() << OProcess.state(); return process not running not surprised
        OProcess.waitForFinished();
        OProcess.state();
        qDebug() << OProcess.state(); return process not running obvious

        I am under the impression that "hci" was first - then "bluez" - based on "hci" The QT implementation of bluez is missing the "--flush" option in "scan". That keeps QT from actually scanning for devices and that is of no good....

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups