PrologThread::PrologThread(qintptr socketId, QString prologPath, QObject *parent) :
    QThread(parent), _socketId(socketId), _prologPath(prologPath), _cmdSize(0)
{
    // We initialize client's prolog environemt
    _process = new QProcess;
    QObject::connect(this, SIGNAL(started()), this, SLOT(startProcess()));
    QObject::connect(_process, SIGNAL(readyReadStandardOutput()), this, SLOT(readStdOut()));
    QObject::connect(_process, SIGNAL(readyReadStandardError()), this, SLOT(readErrOut()));
    QObject::connect(_process, SIGNAL(started()), this, SLOT(processStarted()));
    QObject::connect(_process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(processError(QProcess::ProcessError)));
    _process->setProcessChannelMode(QProcess::MergedChannels);
     _process->setProgram(_prologPath);
     _process->setProcessEnvironment(QProcessEnvironment::systemEnvironment());
     _process->setWorkingDirectory(QDir::homePath());
}
Example #2
0
void TarsnapClient::run()
{
    _process = new QProcess();
    _process->setProcessChannelMode(QProcess::MergedChannels);
    _process->setProgram(_command);
    _process->setArguments(_arguments);
    LOG << tr("Executing [%1 %2]").arg(_process->program()).arg(_process->arguments().join(' ')) << DELIMITER;
    _process->start();
    if(_process->waitForStarted(DEFAULT_TIMEOUT_MS))
    {
        emit started(_uuid);
    }
    else
    {
        processError();
        goto cleanup;
    }
    if(_requiresPassword)
    {
        QByteArray password( _password.toUtf8() + "\n" );
        _process->write( password.data(), password.size() );
    }
    if(_process->waitForFinished(-1))
    {
        readProcessOutput();
        processFinished();
    }
    else
    {
        processError();
        goto cleanup;
    }
cleanup:
    delete _process;
    _process = 0;
}
Example #3
0
void EmulApp::startSoundServer()
{
    if (sndThr) delete sndThr, sndThr = 0;
    sndThr = new SndThr(this);
    sndThr->start();

    if (soundServerProc) delete soundServerProc;
    soundServerProc = new QProcess(this);

    soundServerProc->setProcessChannelMode(QProcess::MergedChannels);
    connect(soundServerProc, SIGNAL(readyRead()), this, SLOT(soundServerHasOutput()));
    connect(soundServerProc, SIGNAL(error(QProcess::ProcessError)), this, SLOT(processError(QProcess::ProcessError)));
    connect(soundServerProc, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(processDied()));


    QStringList args;
#ifdef Q_OS_WIN
    soundServerProc->start("SoundServer.exe", args, QIODevice::ReadOnly);
#elif defined(Q_OS_DARWIN)
    if (QFile::exists("FSMEmulator.app/Contents/MacOS/SoundServer"))
        soundServerProc->start("FSMEmulator.app/Contents/MacOS/SoundServer", args, QIODevice::ReadOnly);
    else
        soundServerProc->start("./SoundServer", args, QIODevice::ReadOnly);
#else /* LINUX */
    soundServerProc->start("./SoundServer", args, QIODevice::ReadOnly);
#endif
    Log() << "Starting SoundServer...\n";    
    soundServerProc->waitForStarted(10000);
    if (soundServerProc->state() == QProcess::Running) {
#ifdef Q_OS_WIN
        int pid = soundServerProc->pid()->dwProcessId;
#else
        int pid = soundServerProc->pid();
#endif
        Log() << "Started SoundServer with PID " << pid << "\n";
    } else {
        QString errStr;

        switch (soundServerProc->error()) {
        case QProcess::FailedToStart: errStr = "Process failed to start"; break;
        case QProcess::Crashed: errStr = "Process crashed after starting"; break;
        case QProcess::Timedout: errStr = "Waiting for the process timed out"; break;
        default: errStr = "Unknown error";
        }
        throw Exception("Could not start SoundServer: " + errStr);
    }
    
}
Example #4
0
bool Client::connectToServer(const QString &serverName)
{
  if (!m_jsonRpcClient) {
    m_jsonRpcClient = new JsonRpcClient(this);
    connect(m_jsonRpcClient, SIGNAL(resultReceived(QJsonObject)),
            SLOT(processResult(QJsonObject)));
    connect(m_jsonRpcClient, SIGNAL(notificationReceived(QJsonObject)),
            SLOT(processNotification(QJsonObject)));
    connect(m_jsonRpcClient, SIGNAL(errorReceived(QJsonObject)),
            SLOT(processError(QJsonObject)));
    connect(m_jsonRpcClient, SIGNAL(connectionStateChanged()),
            SIGNAL(connectionStateChanged()));
  }

  return m_jsonRpcClient->connectToServer(serverName);
}
Example #5
0
QQmlDebugProcess::QQmlDebugProcess(const QString &executable, QObject *parent)
    : QObject(parent)
    , m_executable(executable)
    , m_started(false)
    , m_port(0)
    , m_maximumBindErrors(0)
    , m_receivedBindErrors(0)
{
    m_process.setProcessChannelMode(QProcess::MergedChannels);
    m_timer.setSingleShot(true);
    m_timer.setInterval(5000);
    connect(&m_process, SIGNAL(readyReadStandardOutput()), this, SLOT(processAppOutput()));
    connect(&m_process, SIGNAL(error(QProcess::ProcessError)),
            this, SLOT(processError(QProcess::ProcessError)));
    connect(&m_timer, SIGNAL(timeout()), SLOT(timeout()));
}
void Dialog::startSlave()
{
    if (serial.portName() != serialPortComboBox->currentText()) {
        serial.close();
        serial.setPortName(serialPortComboBox->currentText());

        if (!serial.open(QIODevice::ReadWrite)) {
            processError(tr("Can't open %1, error code %2")
                         .arg(serial.portName()).arg(serial.error()));
            return;
        }
    }

    runButton->setEnabled(false);
    statusLabel->setText(tr("Status: Running, connected to port %1.")
                         .arg(serialPortComboBox->currentText()));
}
Example #7
0
bool Process::engineProcessStart(const QString& fullPath, const QString& workingDir, const QStringList& argList)
{
    DEBUG_FUNC_NAME

    connect(process_, SIGNAL(finished(int, QProcess::ExitStatus)),
             this, SLOT(processFinished(int, QProcess::ExitStatus)));
    connect(process_, SIGNAL(error(QProcess::ProcessError)),
             this, SLOT(processError(QProcess::ProcessError)));

    process_->setWorkingDirectory(workingDir);

    // NOTE: start() function without args not parse correctly filepath with spaces, Qt bug?
    process_->start(fullPath, argList, QProcess::Unbuffered | QProcess::ReadOnly);
    processPid_ = process_->processId();

    return true;
}
void HandshakeResponder::responderParseHandshakeFinished(){ //R:3 parse
    m_timeout.stop();
    disconnect(m_socket, &AbstractLink::readyRead, this, 0);
    QByteArray cypherResponse;
    m_socketStream >> cypherResponse;
    if(isError(cypherResponse))return;

    QByteArray clearResponse = gcmDecrypt(cypherResponse);

    if(clearResponse.isEmpty()) return;

    else if(clearResponse.size() == 1 && clearResponse.at(0) == (char)HandshakeFinished){
        emit success();
    }else{
        processError(UndefinedError);
    }
}
void NTStatsServer::processStatsMessage(int nIndex)
{
    // Handle Stats Message here
    StatsServerMessage* msgChannel = fdArray_[nIndex].msgChannel_;
    if (!msgChannel)
        return;
    if (statsMsgHandler_.processStatsMessage(*msgChannel) != PR_TRUE)
    {
        processError(nIndex);
    }
    else
    {
        // Start a new Async Operation now
        startAsyncReadOperation(nIndex);
    }
    return;
}
Example #10
0
int MainWindow::startRun()
{
    ui->lbInfo->setText(gainstart);
    p = new QProcess;
    connect(p, SIGNAL(readyReadStandardOutput()), this, SLOT(redFromStdOut()));
    connect(p, SIGNAL(readyReadStandardError()), this, SLOT(redFromStdErr()));
    connect(p, SIGNAL(error(QProcess::ProcessError)), this, SLOT(processError(QProcess::ProcessError)));
    connect(p, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(processFinished(int,QProcess::ExitStatus)));
    p->start(filename);
    bStart = p->waitForStarted();
    //bFinish = p->waitForFinished(-1);
    if(bStart)
        return 1;
    else
        return -1;
//    return 1;
}
Example #11
0
void CTypeChecker::Visit(const CClassDeclaration *classDeclaration) {
    const CSymbol* classSymbol = classDeclaration->ClassName->Symbol;
    currentClass = *find<CClassInfo,&CClassInfo::Name>(table.Classes, classSymbol);
    if (isCyclicInheritance(classSymbol)) {
        processError("cyclic inheritance for class '" + classSymbol->GetName() + "'", classDeclaration);
    }

    if (classDeclaration->BaseClassName != nullptr) {
        classDeclaration->BaseClassName->Accept(this);
    }
    classDeclaration->ClassName->Accept(this);
    if (classDeclaration->VarDeclarationList != nullptr) {
        classDeclaration->VarDeclarationList->Accept(this);
    }
    if (classDeclaration->MethodDeclarationList != nullptr) {
        classDeclaration->MethodDeclarationList->Accept(this);
    }
}
Example #12
0
void ProcessManager::runProcess(QString path, QString args)
{
    if(process)
    {
        disconnect(process, SIGNAL(started()), this, SLOT(processStarted()));
        disconnect(process, SIGNAL(errorOccurred(QProcess::ProcessError)), this, SLOT(processError(QProcess::ProcessError)));
        disconnect(process, SIGNAL(finished(int)), this, SLOT(processFinished(int)));
        delete process;
    }
    process = new QProcess(this);
    process->setProcessChannelMode(QProcess::MergedChannels);
    connect(process, SIGNAL(started()), this, SLOT(processStarted()));
    connect(process, SIGNAL(errorOccurred(QProcess::ProcessError)), this, SLOT(processError(QProcess::ProcessError)));
    connect(process, SIGNAL(finished(int)), this, SLOT(processFinished(int)));

    QStringList arguments = args.split(" ",QString::SkipEmptyParts);
    process->start(path, arguments);
}
Example #13
0
    unsigned long InetAddress::hostToAddr (const char* hostname) const
    {
        // convert a.b.c.d notation to ip address
        unsigned long ipaddr = inet_addr(hostname);
        if (ipaddr == INADDR_NONE)
        {
            // failed. try convert from hostname to ip address
            hostent* h = gethostbyname(hostname);
            if (!h)
            {
                processError("InetAddress::hostToAddr");
            }

            ipaddr = *((unsigned long*) h->h_addr_list[0]);
        }

        return ipaddr;
    }
void NXClientLib::invokeNXSSH(QString publicKey, QString serverHost, bool encryption, QByteArray key, int port)
{
	QStringList arguments;
	proxyData.server = serverHost;
	
	if (publicKey == "default") {
		usingHardcodedKey = true;
	}

	if (publicKey == "default" || publicKey == "supplied") {
		if (publicKey == "default")
			cerr << tr("WARNING: Using hardcoded NoMachine public key.").toStdString() << endl;
		
		keyFile = new QTemporaryFile;
		keyFile->open();
		
		arguments << "-nx" << "-i" << keyFile->fileName();
		
		if (publicKey == "default")
			keyFile->write(cert);
		else
			keyFile->write(key);
			
		keyFile->close();
	} else {
		arguments << "-i" << publicKey;
	}
	
	if (encryption == true) {
		arguments << "-B";
		session.setEncryption(true);
	} else
		session.setEncryption(false);
	
	connect(&nxsshProcess, SIGNAL(started()), this, SLOT(processStarted()));
	connect(&nxsshProcess, SIGNAL(error(QProcess::ProcessError)), this, SLOT(processError(QProcess::ProcessError)));
	connect(&nxsshProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(processParseStdout()));
	connect(&nxsshProcess, SIGNAL(readyReadStandardError()), this, SLOT(processParseStderr()));

	nxsshProcess.setEnvironment(nxsshProcess.systemEnvironment());

	arguments << QString("-p %1").arg(port) << QString("nx@" + serverHost);
	nxsshProcess.start(NXSSH_BIN, arguments);
}
GnuplotWidget::GnuplotWidget(QWidget *parent, QSqlDatabase *argDatabase, int argObsobjID, QString argTitle) :
    QWidget(parent),
    ui(new Ui::GnuplotWidget)
{
    mDatabase = argDatabase;
    mObsobjID = argObsobjID;

    ui->setupUi(this);

    QString wkString;
    wkString.clear();
    wkString.append(this->getObstblName());
    wkString.append(" - ");
    wkString.append(argTitle);
    this->setWindowTitle((const QString)wkString);

    mProcess = new QProcess(this);
    mPathname.clear();
    mPathname.append("/usr/local/bin/gnuplot");
//    mArgument.clear();
//    mArgument.append("");
    m_running = false;

    connect(mProcess, SIGNAL(readyReadStandardOutput()),
            this, SLOT(refreshWidget()));
    connect(mProcess, SIGNAL(finished(int, QProcess::ExitStatus)),
            this, SLOT(processFinished(int, QProcess::ExitStatus)));
    connect(mProcess, SIGNAL(error(QProcess::ProcessError)),
            this, SLOT(processError(QProcess::ProcessError)));

    if (!m_running)
    {
        m_running = true;
        mProcess->start(mPathname);
    }

//    QByteArray data = mProcess->readAll();
//    QString str;
//    str.clear();
//    str.append(data.data());

    this->called_when_DatabaseUpdated();

}
Example #16
0
void DGLRunAppProject::startDebugging() {
    // randomize connection port
    int port = rand() % (0xffff - 1024) + 1024;

    m_process = new DGLDebugeeQTProcess(port, m_EglMode);

    m_process->setParent(this);

    CONNASSERT(m_process, SIGNAL(processReady()), this,
               SLOT(processReadyHandler()));
    CONNASSERT(m_process, SIGNAL(processError(std::string)), this,
               SLOT(processErrorHandler(std::string)));
    CONNASSERT(m_process, SIGNAL(processFinished(int)), this,
               SLOT(processExitHandler(int)));
    CONNASSERT(m_process, SIGNAL(processCrashed()), this,
               SLOT(processCrashHandler()));

    m_process->run(getExecutable(), getPath(), getCommandLineArgVector(), getSkipProcessesCount());
}
void NTStatsServer::startAsyncReadOperation(int nIndex)
{
    StatsFileDesc* statFileDesc = &fdArray_[nIndex];
    if (statFileDesc->state_ != STAT_HANDLE_WAIT_READING)
        return;
    StatsServerMessage* msgChannel = statFileDesc->msgChannel_;
    PRBool fSuccess = msgChannel->asyncRecvFromServer();
    if (fSuccess == PR_TRUE)
    {
        processStatsMessage(nIndex);
        return;
    }
    if (msgChannel->isPendingRead() == PR_FALSE)
    {
        // Error Happened in IO
        processError(nIndex);
    }
    return;
}
Example #18
0
TermGdbAdapter::TermGdbAdapter(GdbEngine *engine)
    : AbstractGdbAdapter(engine)
{
#ifdef Q_OS_WIN
    // Windows up to xp needs a workaround for attaching to freshly started processes. see proc_stub_win
    if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA) {
        m_stubProc.setMode(Utils::ConsoleProcess::Suspend);
    } else {
        m_stubProc.setMode(Utils::ConsoleProcess::Debug);
    }
#else
    m_stubProc.setMode(Utils::ConsoleProcess::Debug);
    m_stubProc.setSettings(Core::ICore::settings());
#endif

    connect(&m_stubProc, SIGNAL(processError(QString)), SLOT(stubError(QString)));
    connect(&m_stubProc, SIGNAL(processStarted()), SLOT(handleInferiorSetupOk()));
    connect(&m_stubProc, SIGNAL(wrapperStopped()), SLOT(stubExited()));
}
Example #19
0
static void calculateAvgValue(ADC_HandleTypeDef *hadc, uint8_t position) {
	uint64_t values[] = {0, 0, 0};

	before = hadc->DMA_Handle->Instance->NDTR;

	for (int i = position; i < ADC_HALF_BUFFER_SIZE + position; i++) {
		values[i % 3] += adcBuffer[i];
	}

	for (int i = 0; i < 3; i++) {
		adcResults[i] = values[i] * 3 / ADC_HALF_BUFFER_SIZE;
	}

	after = hadc->DMA_Handle->Instance->NDTR;

	if (after > before) {
		processError(2, 500, 500);
	}
}
Example #20
0
void FirewallCodeViewer::showDiff(const QString &sourceFileName, const QString &destinationFileName)
{
    if (st->getDiffPath().isEmpty()) {
        int ret = QMessageBox::warning(this,
                             tr("Could not start diff program"),
                             tr("You have not configured an external diff program yet.\n"
                                "Do you want to do it now?"),
                             QMessageBox::Yes,
                             QMessageBox::No
                             );
        if (ret == QMessageBox::Yes) {
            PrefsDialog pd(this);
            pd.selectTab("Diff");
            pd.exec();
        }
        return;
    }

    if (!QFileInfo(destinationFileName).isFile()) return;

    QStringList args;

    if (!QFileInfo(sourceFileName).isFile()) {
        QString newSourceFileName = QFileDialog::getOpenFileName(
                    this,
                    tr("Select source file for diff..."),
                    st->getOpenFileDir());

        if (!QFileInfo(newSourceFileName).isFile()) return;

        args << newSourceFileName;
    } else {
        args << sourceFileName;
    }

    args << destinationFileName;

    QProcess *process = new QProcess();
    connect(process, SIGNAL(finished(int)), process, SLOT(deleteLater()));
    connect(process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(processError(QProcess::ProcessError)));
    process->start(st->getDiffPath(), args);
}
Example #21
0
QgsRunProcess::QgsRunProcess( const QString& action, bool capture )
    : mProcess( nullptr )
    , mOutput( nullptr )
{
  // Make up a string from the command and arguments that we'll use
  // for display purposes
  QgsDebugMsg( "Running command: " + action );

  mCommand = action;

  mProcess = new QProcess;

  if ( capture )
  {
    connect( mProcess, SIGNAL( error( QProcess::ProcessError ) ), this, SLOT( processError( QProcess::ProcessError ) ) );
    connect( mProcess, SIGNAL( readyReadStandardOutput() ), this, SLOT( stdoutAvailable() ) );
    connect( mProcess, SIGNAL( readyReadStandardError() ), this, SLOT( stderrAvailable() ) );
    // We only care if the process has finished if we are capturing
    // the output from the process, hence this connect() call is
    // inside the capture if() statement.
    connect( mProcess, SIGNAL( finished( int, QProcess::ExitStatus ) ), this, SLOT( processExit( int, QProcess::ExitStatus ) ) );

    // Use QgsMessageOutput for displaying output to user
    // It will delete itself when the dialog box is closed.
    mOutput = QgsMessageOutput::createMessageOutput();
    mOutput->setTitle( action );
    mOutput->setMessage( tr( "<b>Starting %1...</b>" ).arg( action ), QgsMessageOutput::MessageHtml );
    mOutput->showMessage( false ); // non-blocking

    // get notification of delete if it's derived from QObject
    QObject* mOutputObj = dynamic_cast<QObject *>( mOutput );
    if ( mOutputObj )
    {
      connect( mOutputObj, SIGNAL( destroyed() ), this, SLOT( dialogGone() ) );
    }

    // start the process!
    mProcess->start( action );
  }
  else
  {
    if ( ! mProcess->startDetached( action ) ) // let the program run by itself
void TgtProcessIntf::tgtMakeConnection()
{
    std::shared_ptr<const TgtConnectionConfig> connectionConfig = std::dynamic_pointer_cast<const TgtConnectionConfig>(
        _connectionConfig);
    _proc = new QProcess(this);
    connect(_proc, SIGNAL(readyReadStandardOutput()), this, SLOT(readFromStdout()));
    connect(_proc, SIGNAL(readyReadStandardError()), this, SLOT(readFromStderr()));
    connect(_proc, SIGNAL(error(QProcess::ProcessError)), this, SLOT(processError(QProcess::ProcessError)));
    connect(_proc, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(processDone(int,QProcess::ExitStatus)));
    _proc->setWorkingDirectory(connectionConfig->_workingDir.c_str());
    QStringList args(connectionConfig->_args.c_str());

    QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
    env.insert("TERM", "xterm");
    env.insert("COLORTERM", "gnome-terminal");
    _proc->setProcessEnvironment(env);

    _proc->start(connectionConfig->_program.c_str(), args);
    _processWriterThread = TgtThread::create(boost::protect(std::bind(&TgtProcessIntf::writerThread, this)));
}
Example #23
0
ScreenSaver::ScreenSaver(wl_display *display, QObject *parent)
    : QObject(parent)
    , QtWaylandServer::wl_screensaver(display)
    , m_compositor(nullptr)
    , m_enabled(true)
    , m_timeout(5*60*1000)
    , m_timer(new QTimer(this))
    , m_process(new QProcess(this))
{
    m_timer->setInterval(m_timeout);
    connect(m_timer, SIGNAL(timeout()),
            this, SLOT(timeout()));

    connect(m_process, SIGNAL(started()),
            this, SLOT(processStarted()));
    connect(m_process, SIGNAL(finished(int)),
            this, SLOT(processFinished(int)));
    connect(m_process, SIGNAL(error(QProcess::ProcessError)),
            this, SLOT(processError(QProcess::ProcessError)));
}
Example #24
0
void TarsnapClient::processFinished()
{
    QString output(_processOutput);
    switch (_process->exitStatus())
    {
    case QProcess::NormalExit:
        if(!output.isEmpty())
            LOG << tr("[%1 %2] finished with exit code %3 and output:\n%4").arg(_command)
                   .arg(_arguments.join(' ')).arg(_process->exitCode()).arg(output) << DELIMITER;
        else
            LOG << tr("[%1 %2] finished with exit code %3 and no output.").arg(_command)
                   .arg(_arguments.join(' ')).arg(_process->exitCode()) << DELIMITER;
        emit finished(_uuid, _data, _process->exitCode(), output);
        emit terminated(_uuid);
        break;
    case QProcess::CrashExit:
        processError();
        break;
    }
}
void Dialog::sendRequest()
{
    if (serial.portName() != serialPortComboBox->currentText()) {
        serial.close();
        serial.setPortName(serialPortComboBox->currentText());

        if (!serial.open(QIODevice::ReadWrite)) {
            processError(tr("Can't open %1, error code %2")
                         .arg(serial.portName()).arg(serial.error()));
            return;
        }
    }

    setControlsEnabled(false);
    statusLabel->setText(tr("Status: Running, connected to port %1.")
                         .arg(serialPortComboBox->currentText()));

    serial.write(requestLineEdit->text().toLocal8Bit());
    timer.start(waitResponseSpinBox->value());
}
DemoApplication::DemoApplication(QString executableName, QString caption, QString imageName, QStringList args)
{
    imagePath = imageName;
    appCaption = caption;

    if (executableName[0] == QLatin1Char('/'))
        executablePath = executableName;
    else
        executablePath = QDir::cleanPath(QDir::currentPath() + QLatin1Char('/') + executableName);
  
    arguments = args;

    process.setProcessChannelMode(QProcess::ForwardedChannels);

    QObject::connect( &process, SIGNAL(finished(int,QProcess::ExitStatus)), 
                      this, SLOT(processFinished(int,QProcess::ExitStatus)));

    QObject::connect( &process, SIGNAL(error(QProcess::ProcessError)), 
                      this, SLOT(processError(QProcess::ProcessError)));

    QObject::connect( &process, SIGNAL(started()), this, SLOT(processStarted()));
}
Example #27
0
void Device::open_port(){
    if (serial.portName() != "COM3") {
        serial.close();
        serial.setPortName("COM3");
        if(serial.isOpen()){
            //do nothing
        }
        else{
            if (!serial.open(QIODevice::ReadWrite)) {
                processError(QObject::tr("Can't open %1, error code %2")
                             .arg(serial.portName()).arg(serial.error()));
                return;
            }
        }

        if (!serial.setBaudRate(QSerialPort::Baud19200)) {
            processError(QObject::tr("Can't set rate 19200 baud to port %1, error code %2")
                         .arg(serial.portName()).arg(serial.error()));
            return;
        }

        if (!serial.setDataBits(QSerialPort::Data8)) {
            processError(QObject::tr("Can't set 8 data bits to port %1, error code %2")
                         .arg(serial.portName()).arg(serial.error()));
            return;
        }

        if (!serial.setParity(QSerialPort::NoParity)) {
            processError(QObject::tr("Can't set no patity to port %1, error code %2")
                         .arg(serial.portName()).arg(serial.error()));
            return;
        }

        if (!serial.setStopBits(QSerialPort::OneStop)) {
            processError(QObject::tr("Can't set 1 stop bit to port %1, error code %2")
                         .arg(serial.portName()).arg(serial.error()));
            return;
        }

        if (!serial.setFlowControl(QSerialPort::NoFlowControl)) {
            processError(QObject::tr("Can't set no flow control to port %1, error code %2")
                         .arg(serial.portName()).arg(serial.error()));
            return;
        }
    }
}
Example #28
0
void ASIOReadBuffer::asioReadIntoChunk(const ErrorCode&error,std::size_t bytes_read) {
    TCPSSTLOG(this,"rcv",&mNewChunk[mBufferPos],bytes_read,error);
    mBufferPos+=bytes_read;
    std::tr1::shared_ptr<MultiplexedSocket> thus(mParentSocket.lock());

    if (thus) {
        if (error) {
            processError(&*thus,error);
        } else {
            if (mBufferPos>=mNewChunk.size()) {
                assert(mBufferPos==mNewChunk.size());
                processFullChunk(thus,mWhichBuffer,mNewChunkID,mNewChunk);
                mNewChunk.resize(0);
                mBufferPos=0;
                readIntoFixedBuffer(thus);
            } else {
                readIntoChunk(thus);
            }
        }
    } else {
        delete this;
    }
}
Example #29
0
void DGLDebugeeQTProcess::handleProcessFinished(int code,
                                                QProcess::ExitStatus status) {

    m_PollTimer->stop();

    if (status == QProcess::CrashExit) {
        // this is loader process that crashed!
        emit processCrashed();
    } else {
        // check in IPC if loader was successful
        if (m_Loaded || m_SemLoader.try_wait()) {
            IPCMessage* ipcMessage = (IPCMessage*)m_MappedRegion.get_address();

            if (ipcMessage) {
                static_assert(sizeof(char) == sizeof(ipcMessage->m_message[0]),
                              "Wrong IPC message element size");
                if (!ipcMessage->m_ok) {
                    emit processError((char*)ipcMessage->m_message);
                }
            }
        }
        emit processFinished(code);
    }
}
Example #30
0
void MainWindow::solve()
{
    if(_pr)
        delete _pr;

    ui->solve->setEnabled(false);
    ui->markup->clear();
    ui->solutions->clear();

    _pr=new QProcess(this);
    QString cmd = QString("EquationSolverConsole.exe");

    if(!QFile::exists(cmd))
        ui->solutions->append(tr("Enable to run utility: %1").arg(cmd));
    //QString cmd = QString("cmd.exe");
    QStringList args;
    args << ui->equation->text();
    _equation = ui->equation->text();
    connect(_pr, SIGNAL(started()), SLOT(processStarted()));
    connect(_pr, SIGNAL(error(QProcess::ProcessError)), SLOT(processError()));
    connect(_pr, SIGNAL(finished(int)), SLOT(processFinished(int)));
    _pr->setWorkingDirectory(QDir::currentPath());
    _pr->start(cmd,args);
}