SshConnection::SshConnection(const SshConnectionParameters &serverInfo) : d(new Internal::SshConnectionPrivate(this, serverInfo)) { connect(d, SIGNAL(connected()), this, SIGNAL(connected()), Qt::QueuedConnection); connect(d, SIGNAL(dataAvailable(QString)), this, SIGNAL(dataAvailable(QString)), Qt::QueuedConnection); connect(d, SIGNAL(disconnected()), this, SIGNAL(disconnected()), Qt::QueuedConnection); connect(d, SIGNAL(error(Utils::SshError)), this, SIGNAL(error(Utils::SshError)), Qt::QueuedConnection); }
SshConnection::SshConnection(const SshConnectionParameters &serverInfo, QObject *parent) : QObject(parent) { doStaticInitializationsIfNecessary(); d = new Internal::SshConnectionPrivate(this, serverInfo); connect(d, SIGNAL(connected()), this, SIGNAL(connected()), Qt::QueuedConnection); connect(d, SIGNAL(dataAvailable(QString)), this, SIGNAL(dataAvailable(QString)), Qt::QueuedConnection); connect(d, SIGNAL(disconnected()), this, SIGNAL(disconnected()), Qt::QueuedConnection); connect(d, SIGNAL(error(QSsh::SshError)), this, SIGNAL(error(QSsh::SshError)), Qt::QueuedConnection); }
ConnectionError ConnectionTCPServer::recv( int timeout ) { m_recvMutex.lock(); if( m_cancel || m_socket < 0 || !m_connectionHandler ) { m_recvMutex.unlock(); return ConnNotConnected; } if( !dataAvailable( timeout ) ) { m_recvMutex.unlock(); return ConnNoError; } struct sockaddr_in they; int sin_size = sizeof( struct sockaddr_in ); #ifdef WIN32 int newfd = accept( m_socket, (struct sockaddr*)&they, &sin_size ); #else int newfd = accept( m_socket, (struct sockaddr*)&they, (socklen_t*)&sin_size ); #endif m_recvMutex.unlock(); ConnectionTCPClient* conn = new ConnectionTCPClient( m_logInstance, inet_ntoa( they.sin_addr ), ntohs( they.sin_port ) ); conn->setSocket( newfd ); m_connectionHandler->handleIncomingConnection( conn ); return ConnNoError; }
ctkDICOMHostMainLogic::ctkDICOMHostMainLogic(ctkHostedAppPlaceholderWidget* placeHolder, ctkDICOMAppWidget* dicomAppWidget, QWidget* placeHolderForControls) : QObject(placeHolder), PlaceHolderForHostedApp(placeHolder), DicomAppWidget(dicomAppWidget), PlaceHolderForControls(placeHolderForControls), ValidSelection(false), SendData(false) { this->Host = new ctkExampleDicomHost(PlaceHolderForHostedApp); this->HostControls = new ctkExampleHostControlWidget(Host, PlaceHolderForControls); Data = new ctkDicomAppHosting::AvailableData; disconnect(this->Host,SIGNAL(startProgress()),this->Host,SLOT(onStartProgress())); connect(this->Host,SIGNAL(appReady()),this,SLOT(onAppReady()), Qt::QueuedConnection); connect(this->Host,SIGNAL(startProgress()),this,SLOT(publishSelectedData()), Qt::QueuedConnection); connect(this->PlaceHolderForHostedApp,SIGNAL(resized()),this,SLOT(placeHolderResized())); QTreeView * treeview = dicomAppWidget->findChild<QTreeView*>("TreeView"); QItemSelectionModel* selectionmodel = treeview->selectionModel(); connect(selectionmodel, SIGNAL(selectionChanged ( const QItemSelection &, const QItemSelection & )), this, SLOT(onTreeSelectionChanged(const QItemSelection &, const QItemSelection &))); connect(this->Host, SIGNAL(dataAvailable()), this, SLOT(onDataAvailable())); connect( qApp, SIGNAL(aboutToQuit()), this, SLOT(aboutToQuit()) ); }
bool LH_MonitoringSource_Fraps::doUpdate() { #ifndef Q_OS_WIN return false; #else HMODULE frapsDLL; FRAPS_SHARED_DATA *fsd; #ifdef Q_PROCESSOR_X86_32 frapsDLL = GetModuleHandleA("FRAPS32.DLL"); #else frapsDLL = GetModuleHandleA("FRAPS64.DLL"); #endif bool resultVal = false; setDataAvailable(frapsDLL != NULL); if(!dataAvailable()) // Not running pingFraps(); else { FrapsSharedData = (FRAPS_SHARED_DATA *(WINAPI *)()) GetProcAddress(frapsDLL, "FrapsSharedData"); if (!FrapsSharedData) { qWarning() << "This version of Fraps is incompatible with LCDHost: Fraps 1.9C or later is required!"; } else { fsd = FrapsSharedData(); updateValue("Current FPS","","",(int)fsd->currentFPS, fps_); updateValue("Game Name","","",fsd->gameName); //updateValue("Total Frames","","",(int)fsd->totalFrames); //updateValue("Time of Last Frame","","",(int)fsd->timeOfLastFrame); resultVal = true; } } return resultVal; #endif }
TextTraceHandler::TextTraceHandler(QIODevice *device, QObject *parent) : QObject(parent) { d = new TextTraceHandlerPrivate; d->device = device; connect(device, SIGNAL(readyRead()), this, SLOT(dataAvailable())); }
bool SensorfwRotationSensor::doConnect() { Q_ASSERT(m_sensorInterface); if (m_bufferSize==1) return QObject::connect(m_sensorInterface, SIGNAL(dataAvailable(XYZ)), this, SLOT(slotDataAvailable(XYZ))); return QObject::connect(m_sensorInterface, SIGNAL(frameAvailable(QVector<XYZ>)),this, SLOT(slotFrameAvailable(QVector<XYZ>))); }
void ServerSocket::handleData() { /* qWarning() << "void ServerSocket::handleSocketData()" << m_bufferedData << m_bufferedData.size(); int datasize = m_bufferedData.size(); if((!(datasize % 4)) && datasize < 20) { if(m_bufferedData.contains(Command::playerlist)) { // qWarning() << "Playerlist requested; ID: " << m_id; emit playerlistRequested(m_id); } else if(m_bufferedData.contains(Command::ohsocketIdent)) { // m_ident = true; killSocketTimer(); } else if(m_bufferedData.contains(Command::playerReady)) { emit playerReady(m_id); } else emit dataAvailable(m_id); } else*/ emit dataAvailable(m_id); }
void SmugMug::WebService::_slotHttpRequestFinished (int id, bool error) { qDebug () << "Request Finished: " << id; if (error) { _logHttpError (QString ("Request Finished: %1").arg (id)); } else { emit dataAvailable (_dataIn); bool err = false; QDomDocument doc; if (doc.setContent (_dataIn)) { QDomElement root = doc.documentElement(); if (!_isResponseValid (root)) { err = true; _responseFailed (root); } _handleResponse (id, root, err); } emit actionFinished (); qDebug () << "actionFinished: " << id; } }
bool LabelToolPlugin::visualizeImgCb(label_tool_msgs::ImagesToLabel::Request &req, label_tool_msgs::ImagesToLabel::Response &res) { reset(); // copy data on class structure for(auto &img : req.images) { // convert to opencv mat cv_bridge::CvImagePtr cv_ptr; try { cv_ptr = cv_bridge::toCvCopy(img, img.encoding); } catch (cv_bridge::Exception& e) { ROS_ERROR("cv_bridge exception: %s", e.what()); return false; } std::vector<cv::Point> polygon_edges; ImgWithPolygon img_with_poly_class; img_with_poly_class.img_ = cv_ptr->image; img_with_poly_class.polygon_edges_ = polygon_edges; img_with_polygons_.push_back(img_with_poly_class); } emit dataAvailable(); return true; }
void QmlProfilerModelManager::complete() { switch (state()) { case QmlProfilerDataState::ProcessingData: setState(QmlProfilerDataState::Done); emit dataAvailable(); break; case QmlProfilerDataState::AcquiringData: // If trace end time was not explicitly set, use the last event if (d->traceTime->endTime() == 0) d->traceTime->setEndTime(d->model->lastTimeMark()); setState(QmlProfilerDataState::ProcessingData); d->model->complete(); d->v8Model->complete(); break; case QmlProfilerDataState::Empty: setState(QmlProfilerDataState::Done); break; case QmlProfilerDataState::Done: break; default: emit error(tr("Unexpected complete signal in data model.")); break; } }
int MG2639_Cell::readWaitForResponses(const char * goodRsp, const char * failRsp, unsigned int timeout) { unsigned long timeIn = millis(); // Timestamp coming into function unsigned int received = 0; // received keeps track of number of chars read clearBuffer(); // Clear the class receive buffer (rxBuffer) while (timeIn + timeout > millis()) // While we haven't timed out { if (dataAvailable()) // If data is available on UART RX { // Increment received count & read byte to buffer received += readByteToBuffer(); if (searchBuffer(goodRsp)) return received; // If we've received [goodRsp], return received if (searchBuffer(failRsp)) // If we've received [failRsp] return ERROR_FAIL_RESPONSE; // return FAIL response error code } } if (received > 0) // If we received any characters return ERROR_UNKNOWN_RESPONSE; // Return unkown response error code else // If we haven't received any characters return ERROR_TIMEOUT; // Return the timeout error code }
bool QBluetoothSocketPrivate::setSocketDescriptor(const QAndroidJniObject &socket, QBluetoothServiceInfo::Protocol socketType_, QBluetoothSocket::SocketState socketState, QBluetoothSocket::OpenMode openMode) { Q_Q(QBluetoothSocket); if (q->state() != QBluetoothSocket::UnconnectedState || !socket.isValid()) return false; if (!ensureNativeSocket(socketType_)) return false; socketObject = socket; QAndroidJniEnvironment env; inputStream = socketObject.callObjectMethod("getInputStream", "()Ljava/io/InputStream;"); outputStream = socketObject.callObjectMethod("getOutputStream", "()Ljava/io/OutputStream;"); if (env->ExceptionCheck() || !inputStream.isValid() || !outputStream.isValid()) { env->ExceptionDescribe(); env->ExceptionClear(); //close socket again socketObject.callMethod<void>("close"); if (env->ExceptionCheck()) { env->ExceptionDescribe(); env->ExceptionClear(); } socketObject = inputStream = outputStream = remoteDevice = QAndroidJniObject(); errorString = QBluetoothSocket::tr("Obtaining streams for service failed"); q->setSocketError(QBluetoothSocket::NetworkError); q->setSocketState(QBluetoothSocket::UnconnectedState); return false; } remoteDevice = socketObject.callObjectMethod("getRemoteDevice", "()Landroid/bluetooth/BluetoothDevice;"); if (inputThread) { inputThread->deleteLater(); inputThread = 0; } inputThread = new InputStreamThread(this); QObject::connect(inputThread, SIGNAL(dataAvailable()), q, SIGNAL(readyRead()), Qt::QueuedConnection); QObject::connect(inputThread, SIGNAL(error(int)), this, SLOT(inputThreadError(int)), Qt::QueuedConnection); inputThread->run(); q->setSocketState(socketState); q->setOpenMode(openMode | QIODevice::Unbuffered); if (openMode == QBluetoothSocket::ConnectedState) emit q->connected(); return true; }
bool SensorfwMagnetometer::doConnect() { Q_ASSERT(m_sensorInterface); if (m_bufferSize==1) return QObject::connect(m_sensorInterface, SIGNAL(dataAvailable(MagneticField)), this, SLOT(slotDataAvailable(MagneticField))); return QObject::connect(m_sensorInterface, SIGNAL(frameAvailable(QVector<MagneticField>)), this, SLOT(slotFrameAvailable(QVector<MagneticField>))); }
void UDPServer::handleDataRequest(QString data) { qDebug() << "UDPServer::handleDataRequest called with data:" << data; QString cmd = data.section(';',1,1).toLower(); switch (COMMANDS.indexOf(cmd.section(' ',0,0))) { case 0: // Help command (help) qDebug() << "help command called"; sendHelp(); break; case 1: // List devices command (lsdvs) qDebug() << "List devices command called"; sendDeviceList(); break; case 2: // Select device command (sldvc) qDebug() << "Select device command called"; selectDevice(cmd); break; case 3: // Deselect device command (dsdvc) qDebug() << "Deselect device command called"; deselectDevice(); break; case 4: // List buttons command (lsbts) qDebug() << "List buttons command called"; listButtons(); break; case 5: // Keymap command (kmap) qDebug() << "Keymap command called"; mapKey(cmd); break; case 6: // Undo keymap command (umap) qDebug() << "Undo keymap command called"; unmapKey(cmd); break; case 7: // Supported devices command (supdvs) qDebug() << "Supported devices command called"; supportedDevices(cmd); break; case 8: // Axis Format Map (afmap) qDebug() << "Axis Format Map command called"; axisFormatMap(cmd); break; case 9: // Axis Key Map (akmap) qDebug() << "Axis Key Map command called"; axisKeyMap(cmd); break; default: qDebug() << "Command not recognised"; QString reply = "10;"; reply += "\'" + cmd.section(' ',0,0) + "\'"; reply += " is not recognized as a command, use the \'help\' command for more information"; sendDatagram(reply.toLatin1()); break; } emit dataAvailable(data); }
bool AccelerometerSensorChannelInterface::dataReceivedImpl() { QVector<AccelerationData> values; if(!read<AccelerationData>(values)) return false; if(!frameAvailableConnected || values.size() == 1) { foreach(const AccelerationData& data, values) emit dataAvailable(XYZ(data)); }
void ONBinaryProtocol::Detach(bool keepBuffer) { disconnect(this, SLOT(dataAvailable())); _device = nullptr; if (! keepBuffer) { _buffer.clear(); } }
bool DataLink::foundFrameStart() { //const uint16_t MAX_BYTES_TO_INSPECT = maxFrameSize()*10; bool slipEscape = false; uint16_t inspected = 0; int c = 0; // TODO - Jordan: Break out into separate function? // Look for start character and break out when found while(true) { // Read enough characters for now, go do something else if(inspected >= 100) { return false; } inspected++; if(not dataAvailable()) { //std::cout << "NOTHING AVAILABLE ;(" << std::endl; continue; } c = readByte(); // No characters left to read if(c == -1) { return false; } if((uint8_t)c == SLIP_PACKET_START && not slipEscape) { break; } if((uint8_t)c == SLIP_PACKET_ESCAPE) { slipEscape = true; } else { slipEscape = false; } //std::this_thread::sleep_for(std::chrono::milliseconds(2)); } return true; }
int8_t MG2639_Cell::readBetween(char begin, char end, char * rsp, unsigned int timeout) { unsigned long timeIn = millis(); // timeIn stores timestamp where we enter bool inString = false; // Flag to keep track of whether we've seen [begin] char c = 0; // Char to store currently read character int index = 0; //clearBuffer(); while (timeIn + timeout > millis()) // While we haven't timed out { if (inString == false) // Waiting for beginning character { if (dataAvailable()) // If data is available on UART RX { c = uartRead(); // Read from UART RX if (c == begin) // If c is the [begin] character inString = true; // Set inString to true } } else // in the string { if (dataAvailable()) // If data is available on UART RX { c = uartRead(); // Read data in from UART RX if (c == end) // If c is the [end] char, we're done { rsp[index] = 0; // Terminate the string return 1; // Return success } else { // Else we add to the response string rsp[index++] = c; } } } } // Return fail if we timed out //! TODO: Could be a more verbose response. Did we see [begin]? Timeout? return 0; }
void eHTTPStream::haveData(void *vdata, int len) { __u8 *data=(__u8*)vdata; while (len) { int valid=len; if (!metadataleft) { // not in metadata mode.. process mp3 data (stream to input buffer) // are we just at the beginning of metadata? (pointer) if (metadatainterval && (metadatainterval == bytes)) { // enable metadata mode metadataleft=*data++*16; metadatapointer=0; len--; bytes=0; continue; } else if (metadatainterval && (metadatainterval < bytes)) eFatal("metadatainterval < bytes"); // otherwise there's really data. if (metadatainterval) { // is metadata in our buffer? if ((valid + bytes) > metadatainterval) valid=metadatainterval-bytes; } buffer.write(data, valid); data+=valid; len-=valid; bytes+=valid; } else { // metadata ... process it. int meta=len; if (meta > metadataleft) meta=metadataleft; memcpy(metadata+metadatapointer, data, meta); metadatapointer+=meta; data+=meta; len-=meta; metadataleft-=meta; if (!metadataleft) processMetaData(); } } dataAvailable(); }
void main(void) { /* Configure the oscillator for the device */ ConfigureOscillator(); /* Initialize I/O and Peripherals for application */ InitApp(); W5200_nRESET = 0; __delay_us(5); W5200_nRESET = 1; __delay_ms(50); __delay_ms(50); __delay_ms(50); __delay_ms(50); /* Initialize application settings */ InitSettings(); /* Initialize TCP server */ initServer(&macAddress, &gateway, &netmask); startServer(&localEndpoint); LED = 1; while(1) { if(clientConnected()) { if(dataAvailable()) { uint16_t length = getReceivedLength(); if(length > MAX_BUFFER) { // Limit maximum buffer size to avoid ram saturation due to packet flooding, a normal communication is shorter anyway length = MAX_BUFFER; } uint8_t buffer[MAX_BUFFER]; getReceivedData(buffer, length); parseCommand(buffer[0], buffer, length); stopServer(); startServer(&localEndpoint); } checkClientDisconnection(); } } }
ConnectionError ConnectionTCPClient::recv( int timeout ) { m_recvMutex.lock(); if( m_cancel || m_socket < 0 ) { m_recvMutex.unlock(); return ConnNotConnected; } if( !dataAvailable( timeout ) ) { m_recvMutex.unlock(); return ConnNoError; } int size = static_cast<int>( ::recv( m_socket, m_buf, m_bufsize, 0 ) ); if( size > 0 ) m_totalBytesIn += size; m_recvMutex.unlock(); if( size <= 0 ) { if( size == -1 ) { // recv() failed for an unexpected reason std::string message = "recv() failed. " #if defined( _WIN32 ) && !defined( __SYMBIAN32__ ) "WSAGetLastError: " + util::int2string( ::WSAGetLastError() ); #else "errno: " + util::int2string( errno ) + ": " + strerror( errno ); #endif m_logInstance.err( LogAreaClassConnectionTCPClient, message ); } ConnectionError error = ( size ? ConnIoError : ConnStreamClosed ); if( m_handler ) m_handler->handleDisconnect( this, error ); return error; } m_buf[size] = '\0'; // KEVIN printf("RECV: %d\n", size); if( m_handler ) m_handler->handleReceivedData( this, std::string( m_buf, size ) ); return ConnNoError; }
void AudioSourceOss::read() { struct audio_oss_internal *oss = (struct audio_oss_internal *)internal_data; unsigned char buf[BUF_SIZE]; unsigned char* buffer = buf; int got = 0; while ( got < BUF_SIZE ) { int r = ::read(oss->fd, buffer+got, BUF_SIZE-got); got += r; } emit dataAvailable( (short*)buf, BUF_SIZE/2 ); }
OdroidSmartPowerSource::OdroidSmartPowerSource(QString path) : DataSource("Odroid"), QHIDevice(path), lastCmd(Command::NONE), _interval(1000), _running(false), restarted(false), _path(path) { static_cast<QHIDevice*>(this)->connect(&getDataTmr,&QTimer::timeout,[this] () { sendCommand(Command::REQUEST_DATA); read(64,1000); }); descs.append(new DataDescriptor("U_ext","V",1,DataDescriptor::Type::FLOAT)); descs.append(new DataDescriptor("I_ext","A",1,DataDescriptor::Type::FLOAT)); descs.append(new DataDescriptor("P_ext","W",1,DataDescriptor::Type::FLOAT)); descs.append(new DataDescriptor("E_ext","Wh",1,DataDescriptor::Type::FLOAT)); descs.append(new DataDescriptor("Ext_running","",1,DataDescriptor::Type::CHAR)); QHIDevice::connect(this,&QHIDevice::timeout,this,&DataSource::stop); QHIDevice::connect(this,&QHIDevice::receivedData,[this] (QByteArray data) { assert(data.size() == 64); assert(lastCmd != Command::NONE); double lastTime = QDateTime::currentMSecsSinceEpoch()/1000.0; switch (lastCmd) { case Command::REQUEST_VERSION: sendCommand(Command::REQUEST_STATUS); read(64,1000); break; case Command::REQUEST_DATA: lastTime = getGlobalTime(lastTime); emit dataAvailable(descs.at(0),QString(data.mid(2,5)).toFloat(),lastTime); if (data.at(10) != '-') { emit dataAvailable(descs.at(1),QString(data.mid(10,5)).toFloat(),lastTime); emit dataAvailable(descs.at(2),QString(data.mid(17,6)).toFloat(),lastTime); emit dataAvailable(descs.at(3),QString(data.mid(24,5)).toFloat(),lastTime); } else { emit dataAvailable(descs.at(1),0,lastTime); emit dataAvailable(descs.at(2),0,lastTime); emit dataAvailable(descs.at(3),0,lastTime); } emit dataAvailable(descs.at(4),data.at(9) == '*',lastTime); break; case Command::REQUEST_ONOFF: case Command::REQUEST_STARTSTOP: case Command::REQUEST_STATUS: getDataTmr.start(_interval); break; case Command::NONE: ; //Just to make the compiler happy } emit connected(); }); }
QmlProfilerEventRelativesModelProxy::QmlProfilerEventRelativesModelProxy(QmlProfilerModelManager *modelManager, QmlProfilerEventsModelProxy *eventsModel, QObject *parent) : QObject(parent) { QTC_CHECK(modelManager); m_modelManager = modelManager; QTC_CHECK(eventsModel); m_eventsModel = eventsModel; // Load the child models whenever the parent model is done to get the filtering for JS/QML // right. connect(m_eventsModel, SIGNAL(dataAvailable()), this, SLOT(dataChanged())); }
void terrama2::services::analysis::core::verify::validateAnalysis(DataManagerPtr dataManager, AnalysisPtr analysis, ValidateResult& validateResult) { auto messages = inactiveDataSeries(dataManager, analysis); for(const auto& message : messages) validateResult.messages.insert(validateResult.messages.end(), message); messages = dataAvailable(dataManager, analysis); for(const auto& message : messages) validateResult.messages.insert(validateResult.messages.end(), message); messages = attributeIdentifier(dataManager, analysis); for(const auto& message : messages) validateResult.messages.insert(validateResult.messages.end(), message); }
MyApplication::MyApplication(int &argc, char **argv, int flags) : QApplication(argc, argv, flags) { _one_proc = false; _one_proc_timeout = 2500; _first_proc = true; _shared_memory = new ProcessSharedBuffer(this); _shared_memory->connectToBuffer(QString("%1-%2").arg(QCoreApplication::applicationName(),QDir::homePath())); connect(_shared_memory,SIGNAL(dataAvailable()),this,SLOT(parsingParameters())); _pidstr = QString("PID_%1").arg(QDir::homePath()); _pingstr = QString("LastPing_%1").arg(QDir::homePath()); _argstr = QString("ARG_%1").arg(QDir::homePath()); }
void ONBinaryProtocol::Attach(QIODevice *device) { if (_device != nullptr) { throw Exception("Already attached"); } if (device == nullptr) { throw Exception("Can't attach to a nullptr"); } _device = device; connect(_device, SIGNAL(readyRead()), this, SLOT(dataAvailable())); _buffer.append(_device->readAll()); parseBuffer(); }
void TestProtocol::startReceiving() { // TODO: move this logic to Protocol too? if(! hasState(ADCReady) ) { // TODO: report error: ADC not ready return; } if( hasState(Receiving) ) { // TODO: report warning: already receiving return; } addState(Receiving); connect(dataTimer, &QTimer::timeout, [=]() { TimeStampsVector t = SerialProtocol::generateTimeStamps(1000, dataSize); emit dataAvailable(t, generateRandom(t)); }); dataTimer->start(1000); }
void RemotePluginServer::dispatchProcess(int timeout) { char msg; if (read(m_shmControl->runServerRead, &msg, 1) != 1) { throw RemotePluginClosedException(); } while (dataAvailable(&m_shmControl->ringBuffer)) { dispatchProcessEvents(); } msg = 0; if (write(m_shmControl->runClientWrite, &msg, 1) != 1) { throw RemotePluginClosedException(); } }