コード例 #1
1
ファイル: win_qextserialport.cpp プロジェクト: dulton/53_hero
/*!
\fn Win_QextSerialPort::Win_QextSerialPort(const QString & name, const PortSettings& settings)
Constructs a port with specified name and settings.
*/
Win_QextSerialPort::Win_QextSerialPort(const QString & name, const PortSettings& settings, QextSerialBase::QueryMode mode) 
{
    m_WinHandle=INVALID_HANDLE_VALUE;
    setPortName(name);
    setBaudRate(settings.BaudRate);
    setDataBits(settings.DataBits);
    setStopBits(settings.StopBits);
    setParity(settings.Parity);
    setFlowControl(settings.FlowControl);
    setTimeout(settings.Timeout_Millisec);
    setQueryMode(mode);
    init();
}
コード例 #2
0
ファイル: connectionBase.hpp プロジェクト: Wolframe/Wolframe
	/// Handle completion of a read operation.
	void handleRead( const boost::system::error_code& e, std::size_t bytesTransferred )
	{
		setTimeout( 0 );
		if ( !e )	{
			LOG_TRACE << "Read " << bytesTransferred << " bytes from " << identifier();
			m_connHandler->networkInput( m_readBuffer, bytesTransferred );
		}
		else	{
			LOG_TRACE << "Read error: " << e.message();
			signalError( e );
		}
		nextOperation();
	}
コード例 #3
0
ファイル: connectionBase.hpp プロジェクト: Wolframe/Wolframe
	/// Handle connection shutdown
	void handleShutdown()
	{
		setTimeout( 0 );
		if ( socket().lowest_layer().is_open() )	{
			boost::system::error_code ignored_ec;
			socket().lowest_layer().shutdown( boost::asio::ip::tcp::socket::shutdown_both, ignored_ec );
			socket().lowest_layer().close();
			LOG_DEBUG << "Connection to " << identifier() << " closed";
		}
		else	{
			LOG_DEBUG << "Connection to " << identifier() << " already closed";
		}
	}
コード例 #4
0
/*!
\fn Posix_QextSerialPort::Posix_QextSerialPort(const PortSettings& settings)
Constructs a port with default name and specified settings.
*/
Posix_QextSerialPort::Posix_QextSerialPort(const PortSettings& settings, QextSerialBase::QueryMode mode)
    : QextSerialBase()
{
    setBaudRate(settings.BaudRate);
    setDataBits(settings.DataBits);
    setParity(settings.Parity);
    setStopBits(settings.StopBits);
    setFlowControl(settings.FlowControl);

    setTimeout(settings.Timeout_Millisec);
    setQueryMode(mode);
    init();
}
コード例 #5
0
/*!
\fn Posix_QextSerialPort::Posix_QextSerialPort(const PortSettings& settings)
Constructs a port with default name and specified settings.
*/
Posix_QextSerialPort::Posix_QextSerialPort(const PortSettings& settings)
 : QextSerialBase()
{
    setBaudRate(settings.BaudRate);
    setDataBits(settings.DataBits);
    setParity(settings.Parity);
    setStopBits(settings.StopBits);
    setFlowControl(settings.FlowControl);

    Posix_File=new QFile();
    setTimeout(settings.Timeout_Millisec);
    init();
}
コード例 #6
0
ファイル: qextserialport.cpp プロジェクト: MorS25/OpenPilot
/*!
   Constructs a port with default name and specified settings.
 */
QextSerialPort::QextSerialPort(const PortSettings & settings, QextSerialPort::QueryMode mode)
    : QIODevice()
{
    construct();
    setBaudRate(settings.BaudRate);
    setDataBits(settings.DataBits);
    setParity(settings.Parity);
    setStopBits(settings.StopBits);
    setFlowControl(settings.FlowControl);
    setTimeout(settings.Timeout_Millisec);
    setQueryMode(mode);
    platformSpecificInit();
}
コード例 #7
0
    void ActionInstance::copyActionDataFrom(const ActionInstance &other)
    {
        setComment(other.comment());
        setLabel(other.label());
        setParametersData(other.parametersData());
		setColor(other.color());
		setEnabled(other.isEnabled());
		setSelected(other.isSelected());
		setExceptionActionInstances(other.exceptionActionInstances());
		setPauseBefore(other.pauseBefore());
		setPauseAfter(other.pauseAfter());
        setTimeout(other.timeout());
    }
コード例 #8
0
ファイル: epson.cpp プロジェクト: app/tradeequip-drv
/*!
 * initPort() - initialization of com port.
 */
void TEDisplayEpson::initPort()
{
    TSerialPort *p = port();
	if ( !p ) return;
	if (!isOpen())
		open();
	p->setFlowControl(FLOW_OFF);
	setPortBaudRate(m_baudRate);
	p->setDataBits(DATA_8);
	p->setParity(PAR_NONE);
	p->setStopBits(STOP_1);
	setTimeout(100);
};
コード例 #9
0
ファイル: mod_rfid.c プロジェクト: timmyhadwen/ESP8266
void ICACHE_FLASH_ATTR rfid_set(uint8 freq, uint8 led) {
	char command[10];
	
	if (freq < 10) {
		os_sprintf(command, "mc%d0\r", freq);
		uart_write_str(command);
#if RFID_DEBUG
		debug("RFID: %s\n", command);
#endif
	}
	
	setTimeout(rfid_set_led, led, 10);
}
コード例 #10
0
ファイル: user_mod_finger.c プロジェクト: habashynn/ESP8266
LOCAL void ICACHE_FLASH_ATTR finger_start_read() {
LOCAL uint32 finger_read_timer = 0;
	if (device_get_uart() != UART_FINGER) {
#if FINGER_DEBUG
		debug("FINGER: %s\n", DEVICE_NOT_FOUND);
#endif
		return;
	}

	finger_current_buff = 0;
	clearTimeout(finger_read_timer);
	finger_read_timer = setTimeout(finger_gen_img, finger_read, FINGER_TIMEOUT);
}
コード例 #11
0
    inline PPositionOurGoalKick(const BeliefState& state) 
      : Play(state)
    {
      name = "PositionOurGoalKick";

      assert(HomeTeam::SIZE == 5);
      setTimeout(100, 1);
      PositionPlay = PLAYTYPE_YES;
      AttackPlay   = PLAYTYPE_NO;
      
      Tactic::Param param;
      
	  Vector2D<int> finalPoint ;
	  /* for goalie */
	  roleList[0].push_back(std::make_pair(Tactic::GoalieOur, param));
      /*Vector2D<int> dpointg(ForwardX(-HALF_FIELD_MAXX + GOAL_DEPTH + BOT_RADIUS*1.2),state.ballPos.y);
	  param.PositionP.x  = ForwardX(-HALF_FIELD_MAXX + GOAL_DEPTH + BOT_RADIUS*1.2) ;
	  param.PositionP.y  = state.ballPos.y;
	  param.PositionP.finalSlope = 0;
	  param.PositionP.align = false ;
	  roleList[0].push_back(std::make_pair(Tactic::Position,param));
      *//* Role 1 - Defender 1*/
	  Vector2D<int> dpoint0(ForwardX(-HALF_FIELD_MAXX + GOAL_DEPTH + BOT_RADIUS*9),-1*(OUR_GOAL_MAXY + 2*BOT_RADIUS));
	  finalPoint = position_our_bot(&state,dpoint0,0);
	  param.PositionP.x = finalPoint.x ; param.PositionP.y = finalPoint.y ;
	  param.PositionP.finalSlope = 0 ;
	  roleList[1].push_back(std::make_pair(Tactic::Position,param));
      
	  // Role 2
	  Vector2D<int> dpoint(ForwardX(-HALF_FIELD_MAXX/2),HALF_FIELD_MAXY/2);
	  finalPoint = position_our_bot(&state,dpoint,0);
	  param.PositionP.x = finalPoint.x ; param.PositionP.y = finalPoint.y ;
      param.PositionP.finalSlope  = 0;
      roleList[2].push_back(std::make_pair(Tactic::Position, param));
      
	  //Role 3
	  Vector2D<int> dpoint1(ForwardX(-CENTER_CIRCLE_DIAMETER/2),HALF_FIELD_MAXY/4);
	  finalPoint = position_our_bot(&state,dpoint1,0);
	  param.PositionP.x = finalPoint.x ; param.PositionP.y = finalPoint.y ;
      param.PositionP.finalSlope  = 0;
      roleList[3].push_back(std::make_pair(Tactic::Position, param));
      
	  //Role 4
	  Vector2D<int> dpoint2(ForwardX(HALF_FIELD_MAXX/6),-HALF_FIELD_MAXY/2);
	  finalPoint = position_our_bot(&state,dpoint2,0);
	  param.PositionP.x = finalPoint.x ; param.PositionP.y = finalPoint.y ;
      param.PositionP.finalSlope  = 0;
      roleList[4].push_back(std::make_pair(Tactic::Position, param));
      
      computeMaxTacticTransits();
    }
コード例 #12
0
VotePacket::VotePacket( uint32 ip, uint16 port, int32 rank,
                        bool direct)
   : Packet(  MAX_VOTE_LENGTH,
              VOTE_PRIO,
              PACKETTYPE_VOTE,
              ip, port, 0, 0)
{   
   int packetPosition = HEADER_SIZE;
   incWriteLong( packetPosition, rank );
   incWriteLong( packetPosition, direct );
   // 5 seconds timeout.
   setTimeout( 5 );
   setLength(packetPosition);
}
コード例 #13
0
ファイル: socket.cpp プロジェクト: edv4rd0/hiphop-php
Socket::Socket(int sockfd, int type, const char *address /* = NULL */,
               int port /* = 0 */)
  : File(true), m_port(port), m_type(type), m_error(0), m_eof(false),
    m_timeout(0), m_timedOut(false), m_bytesSent(0) {
  if (address) m_address = address;
  m_fd = sockfd;

  struct timeval tv;
  tv.tv_sec = RuntimeOption::SocketDefaultTimeout;
  tv.tv_usec = 0;
  setsockopt(m_fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
  setsockopt(m_fd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv));
  setTimeout(tv);
}
コード例 #14
0
ファイル: timer.cpp プロジェクト: absalan/tdesktop
void Timer::start(TimeMs timeout, Qt::TimerType type, Repeat repeat) {
	cancel();

	_type = type;
	setRepeat(repeat);
	_adjusted = false;
	setTimeout(timeout);
	_timerId = startTimer(_timeout, _type);
	if (_timerId) {
		_next = getms(true) + _timeout;
	} else {
		_next = 0;
	}
}
コード例 #15
0
            void
            StopAndWaitRC::doWakeup(Port<Data>)
            {
                if (sendNowData &&
                    getPortConnector< Port<Data> >()->hasAcceptor(activeCompound))
                {
                    setTimeout(resendTimeout);
                    getPortConnector< Port<Data> >()->getAcceptor(activeCompound)->sendData(activeCompound->copy());

                    sendNowData = false;
                }

                getReceptor()->wakeup();
            }
コード例 #16
0
/*!
\fn Posix_QextSerialPort::construct(void)
Common constructor function, called by all versions of 
Posix_QextSerialPort::Posix_QextSerialPort().  Sets up default port settings (115200 8N1 
Hardware flow control where supported, otherwise no flow control, and 500 ms timeout).
*/
void Posix_QextSerialPort::construct(void) {
    QextSerialBase::construct();
#ifdef NOQFILE
    m_fdFile=-1;
#else
    Posix_File=new QFile();
#endif
    setBaudRate(BAUD115200);
    setDataBits(DATA_8);
    setStopBits(STOP_1);
    setParity(PAR_NONE);
    setFlowControl(FLOW_HARDWARE);
    setTimeout(0, 500);
}
コード例 #17
0
ファイル: extworkerconfig.cpp プロジェクト: 52M/openlitespeed
void ExtWorkerConfig::config(const XmlNode *pNode)
{
    const char *pValue;
    int iMaxConns = ConfigCtx::getCurConfigCtx()->getLongValue(pNode,
                    "maxConns", 1, 2000, 1);
    int iRetryTimeout = ConfigCtx::getCurConfigCtx()->getLongValue(pNode,
                        "retryTimeout", 0, LONG_MAX, 10);
    int iInitTimeout = ConfigCtx::getCurConfigCtx()->getLongValue(pNode,
                       "initTimeout", 1, LONG_MAX, 3);
    int iBuffer = ConfigCtx::getCurConfigCtx()->getLongValue(pNode,
                  "respBuffer", 0, 2, 1);
    int iKeepAlive = ConfigCtx::getCurConfigCtx()->getLongValue(pNode,
                     "persistConn", 0, 1, 1);
    int iKeepAliveTimeout = ConfigCtx::getCurConfigCtx()->getLongValue(pNode,
                            "pcKeepAliveTimeout", -1, INT_MAX, INT_MAX);

    if (iKeepAliveTimeout == -1)
        iKeepAliveTimeout = INT_MAX;

    if (iBuffer == 1)
        iBuffer = 0;
    else if (iBuffer == 0)
        iBuffer = HEC_RESP_NOBUFFER;
    else if (iBuffer == 2)
        iBuffer = HEC_RESP_NPH;

    setPersistConn(iKeepAlive);
    setKeepAliveTimeout(iKeepAliveTimeout);
    setMaxConns(iMaxConns);
    setTimeout(iInitTimeout);
    setRetryTimeout(iRetryTimeout);
    setBuffering(iBuffer);
    clearEnv();
    const XmlNodeList *pList = pNode->getChildren("env");

    if (pList)
    {
        XmlNodeList::const_iterator iter;

        for (iter = pList->begin(); iter != pList->end(); ++iter)
        {
            pValue = (*iter)->getValue();

            if (pValue)
                addEnv((*iter)->getValue());
        }
    }

}
コード例 #18
0
ファイル: sock.cpp プロジェクト: judahschvimer/mongo
bool Socket::connect(SockAddr& remote) {
    _remote = remote;

    _fd = socket(remote.getType(), SOCK_STREAM, 0);
    if (_fd == INVALID_SOCKET) {
        LOG(_logLevel) << "ERROR: connect invalid socket " << errnoWithDescription();
        return false;
    }

    if (_timeout > 0) {
        setTimeout(_timeout);
    }

    static const unsigned int connectTimeoutMillis = 5000;
    ConnectBG bg(_fd, remote);
    bg.go();
    if (bg.wait(connectTimeoutMillis)) {
        if (bg.inError()) {
            warning() << "Failed to connect to " << _remote.getAddr() << ":" << _remote.getPort()
                      << ", reason: " << bg.getErrnoWithDescription();
            close();
            return false;
        }
    } else {
        // time out the connect
        close();
        bg.wait();  // so bg stays in scope until bg thread terminates
        warning() << "Failed to connect to " << _remote.getAddr() << ":" << _remote.getPort()
                  << " after " << connectTimeoutMillis << " milliseconds, giving up.";
        return false;
    }

    if (remote.getType() != AF_UNIX)
        disableNagle(_fd);

#ifdef SO_NOSIGPIPE
    // ignore SIGPIPE signals on osx, to avoid process exit
    const int one = 1;
    setsockopt(_fd, SOL_SOCKET, SO_NOSIGPIPE, &one, sizeof(int));
#endif

    _local = getLocalAddrForBoundSocketFd(_fd);

    _fdCreationMicroSec = curTimeMicros64();

    _awaitingHandshake = false;

    return true;
}
コード例 #19
0
void ASIOConnection::refresh(Milliseconds timeout, RefreshCallback cb) {
    _impl->strand().dispatch([this, timeout, cb] {
        auto op = _impl.get();

        // We clear state transitions because we're re-running a portion of the asio state machine
        // without entering in startCommand (which would call this for us).
        op->clearStateTransitions();

        _refreshCallback = std::move(cb);

        // Actually timeout refreshes
        setTimeout(timeout, [this] { _impl->connection().stream().cancel(); });

        // Our pings are isMaster's
        auto beginStatus = op->beginCommand(makeIsMasterRequest(this),
                                            NetworkInterfaceASIO::AsyncCommand::CommandType::kRPC,
                                            _hostAndPort);
        if (!beginStatus.isOK()) {
            auto cb = std::move(_refreshCallback);
            cb(this, beginStatus);
            return;
        }

        // If we fail during refresh, the _onFinish function of the AsyncOp will get called. As such
        // we
        // need to intercept those calls so we can capture them. This will get cleared out when we
        // fill
        // in the real onFinish in startCommand.
        op->setOnFinish([this](StatusWith<RemoteCommandResponse> failedResponse) {
            invariant(!failedResponse.isOK());
            auto cb = std::move(_refreshCallback);
            cb(this, failedResponse.getStatus());
        });

        op->_inRefresh = true;

        _global->_impl->_asyncRunCommand(op, [this, op](std::error_code ec, size_t bytes) {
            cancelTimeout();

            auto cb = std::move(_refreshCallback);

            if (ec)
                return cb(this, Status(ErrorCodes::HostUnreachable, ec.message()));

            op->_inRefresh = false;
            cb(this, Status::OK());
        });
    });
}
コード例 #20
0
ファイル: file_db.cpp プロジェクト: 0u812/emscripten
int main() {
#if FIRST
  FILE *f = fopen("waka.txt", "w");
  fputc('a', f);
  fputc('z', f);
  fclose(f);

  EM_ASM(
    FS.saveFilesToDB(['waka.txt', 'moar.txt'], function() {
      Module.print('save ok');
      var xhr = new XMLHttpRequest();
      xhr.open('GET', 'http://localhost:8888/report_result?1');
      xhr.send();
      setTimeout(function() { window.close() }, 1000);
    }, function(e) {
コード例 #21
0
void HttpService::get(
    const std::string& uri,
    std::function<void(bool, const std::vector<std::uint8_t>&)> callback)
{
    auto request = std::make_unique<HttpRequest>(uri, callback);
    if (timeout > decltype(timeout)::zero()) {
        request->setTimeout(timeout);
    }

    auto result = curl_multi_add_handle(multiHandle, request->getCurl());
    if (result != CURLE_OK) {
        throw std::runtime_error("curl_multi_add_handle() failed");
    }
    sessions.emplace(request->getCurl(), std::move(request));
}
コード例 #22
0
ファイル: serial_ctrl.c プロジェクト: agarmo/MasterThesis
static int internal_receive(char data[], int data_size_max,
                            serial_t* serial, int timeout)
{
  int filled = 0;
  DWORD n;

  if (timeout != serial->current_timeout_) {
    setTimeout(serial, timeout);
    serial->current_timeout_ = timeout;
  }

  ReadFile(serial->hCom_, &data[filled],
           (DWORD)data_size_max - filled, &n, NULL);

  return filled + n;
}
コード例 #23
0
ファイル: user_plug.c プロジェクト: toome123/ESP8266
LOCAL void plug_wifi_blink_cycle() {
	LOCAL bool state = false;
	LOCAL uint32 timer = 0;
	
	if (!plug_wifi_blink) {
		state = false;
		return;
	}
	
	state = !state;
	plug_led(PLUG_LED1, state);
	plug_led(PLUG_LED2, !state && user_relay_get());
	
	clearTimeout(timer);
	timer = setTimeout(plug_wifi_blink_cycle, NULL, 500);
}
コード例 #24
0
    ErrorCode CHttpPostRequest::requestURL(const char* url, UInt32 timeoutSec)
    {
        X_ASSERT(url && *url);

        ErrorCode ret = EC_OK;
        {
            setURL(url);
            setTimeout(timeoutSec * 1000);

            ret = perform();
            ERROR_CHECK_BOOL(EC_OK == ret);
        }

Exit0:
        return ret;
    }
コード例 #25
0
// Recieve data from the base station.
uint8_t EndDevice::requestWait() {
	DEBUG_MSG("[REQUEST WAIT]");
	if (hasTimedOut()) {
		// Timed out waiting for more data
		disableTimeout();

		// Discard the partially received data
		dataEnd = data;

		// Retry the update 4 times.
		timesTimeout++;
		if (timesTimeout > 3) {
			State = EndDeviceError;
			timesTimeout = 0;
			return TICK_UPDATE_TIMEOUT;
		} else {
			State = EndDeviceRequestSend;
		}
	} else if (xbee.getResponse().isAvailable()) {
		if (xbee.getResponse().getApiId() == ZB_RX_RESPONSE) {
			DEBUG_MSG("  GOT PACKET");
			// Has a data packet
			disableTimeout();
			ZBRxResponse zbrr;
			xbee.getResponse().getZBRxResponse(zbrr);

			// Copy the data into the buffer
			memcpy(dataEnd, zbrr.getData(), zbrr.getDataLength());
			dataEnd += zbrr.getDataLength();

			// Test if this was the final data packet for this message
			if (zbrr.getData()[zbrr.getDataLength()-1] == 0) {
				timesTimeout = 0; // Reset timeout counter as we got a complete message
				DEBUG_MSG("  GOT MSG");
				DEBUG_MSG((char *) data);
				State = EndDeviceIdle;
				dataEnd = data;
				return TICK_NEW_MSG;
			} else {
				setTimeout(5000);
			}
		} else {
			// TODO: Other type of message
		}
	}
	return TICK_OK;
}
コード例 #26
0
/*!
\fn bool Posix_QextSerialPort::open(OpenMode mode)
Opens the serial port associated to this class.
This function has no effect if the port associated with the class is already open.
The port is also configured to the current settings, as stored in the Settings structure.
*/
bool Posix_QextSerialPort::open(OpenMode mode)
{
    LOCK_MUTEX();
    if (mode == QIODevice::NotOpen)
        return isOpen();
    if (!isOpen()) {
        /*open the port*/
        qDebug("trying to open file");
        //note: linux 2.6.21 seems to ignore O_NDELAY flag
        if ((fd = ::open(port.toAscii() ,O_RDWR | O_NOCTTY | O_NDELAY)) != -1) {
            qDebug("file opened succesfully");

            setOpenMode(mode);			// Flag the port as opened
            tcgetattr(fd, &old_termios);	// Save the old termios
            Posix_CommConfig = old_termios;	// Make a working copy
            cfmakeraw(&Posix_CommConfig);	// Enable raw access

            /*set up other port settings*/
            Posix_CommConfig.c_cflag|=CREAD|CLOCAL;
            Posix_CommConfig.c_lflag&=(~(ICANON|ECHO|ECHOE|ECHOK|ECHONL|ISIG));
            Posix_CommConfig.c_iflag&=(~(INPCK|IGNPAR|PARMRK|ISTRIP|ICRNL|IXANY));
            Posix_CommConfig.c_oflag&=(~OPOST);
            Posix_CommConfig.c_cc[VMIN]= 0;
#ifdef _POSIX_VDISABLE	// Is a disable character available on this system?
            // Some systems allow for per-device disable-characters, so get the
            //  proper value for the configured device
            const long vdisable = fpathconf(fd, _PC_VDISABLE);
            Posix_CommConfig.c_cc[VINTR] = vdisable;
            Posix_CommConfig.c_cc[VQUIT] = vdisable;
            Posix_CommConfig.c_cc[VSTART] = vdisable;
            Posix_CommConfig.c_cc[VSTOP] = vdisable;
            Posix_CommConfig.c_cc[VSUSP] = vdisable;
#endif //_POSIX_VDISABLE
            setBaudRate(Settings.BaudRate);
            setDataBits(Settings.DataBits);
            setParity(Settings.Parity);
            setStopBits(Settings.StopBits);
            setFlowControl(Settings.FlowControl);
            setTimeout(Settings.Timeout_Millisec);
            tcsetattr(fd, TCSAFLUSH, &Posix_CommConfig);
        } else {
            qDebug("could not open file: %s", strerror(errno));
        }
    }
    UNLOCK_MUTEX();
    return isOpen();
}
コード例 #27
0
bool SerialPort::initPort(const uchar initialBaudrate,
                                  const ulong timeout)
{
    uchar baudrate = initialBaudrate % 7;
    if (baudrate == 0)                // Adapt baud
    {
      setBaudRate(BAUD2400);
      qDebug() << "Baudrate" << "2.4k";
    }
    else if (baudrate == 1)
    {
      setBaudRate(BAUD4800);
      qDebug() << "Baudrate" << "4.8k";
    }
    else if (baudrate == 2)
    {
      setBaudRate(BAUD9600);
      qDebug() << "Baudrate" << "9.6k";
    }
    else if (baudrate == 3)
    {
      setBaudRate(BAUD19200);
      qDebug() << "Baudrate" << "19.2k";
    }
    else if (baudrate == 4)
    {
      setBaudRate(BAUD38400);
      qDebug() << "Baudrate" << "38.4k";
    }
    else if (baudrate == 5)
    {
      setBaudRate(BAUD57600);
      qDebug() << "Baudrate" << "57.6k";
    }
    else if (baudrate == 6)
    {
      setBaudRate(BAUD115200);
      qDebug() << "Baudrate" << "115.2k";
    }
    setFlowControl(FLOW_OFF);
    setParity(PAR_NONE);
    setDataBits(DATA_8);
    setStopBits(STOP_1);
    setTimeout(timeout);
    return open(QIODevice::ReadWrite);
}
コード例 #28
0
ファイル: xmlrpcserver.cpp プロジェクト: yohe/qtxmlrpc-fork
Protocol::Protocol( QAbstractSocket * parent, const int _timeout )
            : QObject( parent ), timeout( 0 ), timeoutTimerId( 0 ), socket( parent )
{
#ifdef DEBUG_PROTOCOL
      qDebug() << this << "Protocol(): child of" << socket;
#endif
      // check we are only one protocol, working with this socket, at this time
      foreach( QObject * o, parent->children() )
            if( o != this && qobject_cast<Protocol*>(o) ) {
            qCritical() << this << "Protocol(): socket" << parent
                        << "already have another protocol" << o;
            qFatal( "programming error" );
      }

      if( _timeout > 0 )
            setTimeout( _timeout );
}
コード例 #29
0
ファイル: adb_codec.cpp プロジェクト: charliebruce/waxbee
	/**
	 public entry point to initiate an ADB transaction on the bus
	*/
	void initiateAdbTransfer(AdbPacket* adbPacket, void (*done_callback)(uint8_t errorCode))
	{
		// reset
		resetDecoder();

		// keep reference to the packet
		itsAdbPacket = adbPacket;

		itsDoneCallback = done_callback;

		// keep the line idle for at least IDLE_TIME_US
		// TODO: remember how much time left since last packet
		// and adjust setTimeout accordingly
		state = idle;
		adb_highimpedance();
		setTimeout(IDLE_TIME_US);
	}
コード例 #30
0
ファイル: statetimer.c プロジェクト: DeeaRe/statecharts
/**
 * Queue a timer event
 *
 * \param handle	Statemachine handle for the callback
 * \param evid 		Event-ID for the timer
 * \param time_ms 	timout time for the timer
 * \param periodic	true if the timer should be repeated
 * \param callback	Pointer to a callback functions with is called after each timeout
 *
 */
void setTimer(void* handle, const sc_eventid evid, const sc_integer time_ms,
		const sc_boolean periodic, raiseEventCallback_t callback) {
	uint8_t i;
	for (i = 0; i < NUM_MAX_TIMERS; ++i) {
		if (timers[i].in_use)
			continue;

		timers[i].statemachineHandle = handle;
		timers[i].evid = evid;
		timers[i].time_ms = time_ms;
		timers[i].periodic = periodic;
		timers[i].callback_fun = callback;
		setTimeout(&timers[i]);
		return;
	}
	//error: no free timer
}