当前位置: 首页>>代码示例>>C++>>正文


C++ setStopBits函数代码示例

本文整理汇总了C++中setStopBits函数的典型用法代码示例。如果您正苦于以下问题:C++ setStopBits函数的具体用法?C++ setStopBits怎么用?C++ setStopBits使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了setStopBits函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: LOCK_MUTEX

/*!
\fn bool Posix_QextSerialPort::open(int=0)
Opens a serial port.  Note that this function does not specify which device to open.  If you need
to open a device by name, see Posix_QextSerialPort::open(const char*).  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(int) {
    LOCK_MUTEX();
    if (!portOpen) {

        /*open the port*/
        Posix_File->setName(portName);
        if (Posix_File->open(IO_Async|IO_Raw|IO_ReadWrite)) {
            portOpen=true;
        }

        /*configure port settings*/
        tcgetattr(Posix_File->handle(), &Posix_CommConfig);

        /*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|IXANY));
        Posix_CommConfig.c_oflag&=(~OPOST);
        Posix_CommConfig.c_cc[VMIN]=0;
        Posix_CommConfig.c_cc[VINTR] = _POSIX_VDISABLE; 
        Posix_CommConfig.c_cc[VQUIT] = _POSIX_VDISABLE; 
        Posix_CommConfig.c_cc[VSTART] = _POSIX_VDISABLE; 
        Posix_CommConfig.c_cc[VSTOP] = _POSIX_VDISABLE; 
        Posix_CommConfig.c_cc[VSUSP] = _POSIX_VDISABLE; 
        setBaudRate(Settings.BaudRate);
        setDataBits(Settings.DataBits);
        setStopBits(Settings.StopBits);
        setParity(Settings.Parity);
        setFlowControl(Settings.FlowControl);
        setTimeout(Posix_Copy_Timeout.tv_sec, Posix_Copy_Timeout.tv_usec);
        tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
    }
    UNLOCK_MUTEX();
    return portOpen;
}
开发者ID:BackupTheBerlios,项目名称:poa,代码行数:42,代码来源:posix_qextserialport.cpp

示例2: tcgetattr

bool QSerialPort::open(int block)
{
	if( block== 1) portDesc = ::open(portName.toAscii(),O_RDWR);
	else portDesc = ::open(portName.toAscii(),O_RDWR | O_NONBLOCK );
	if(portDesc == -1)
	{
		return false;
	}
	portOpen = true;

	tcgetattr(portDesc, &portConfig);
	
	portConfig.c_cflag|=(CLOCAL | CREAD);
	portConfig.c_lflag&=(~(ICANON|ECHO|ECHOE|ECHOK|ECHONL|ISIG));
	portConfig.c_iflag&=(~(IGNBRK|BRKINT|PARMRK|ISTRIP |INLCR| IGNCR|ICRNL|IXON)); //  (~(INPCK|IGNPAR|PARMRK|ISTRIP|IXANY));
	portConfig.c_iflag&=~(ICRNL);

	portConfig.c_oflag&=(~OPOST);
	
	tcsetattr(portDesc, TCSANOW, &portConfig);

	setBaudRate(settings.baudRate);
	setDataBits(settings.dataBits);
	setFlowControl(settings.flowControl);
	setParity(settings.parity);
	setStopBits(settings.stopBits);
	setDtr();
	setRts();

	connect(&portFile, SIGNAL(readyRead()), this, SLOT(slotNotifierActivated()));

	return true;
}
开发者ID:AeroCano,项目名称:JdeRobot,代码行数:33,代码来源:q4serialport.cpp

示例3: openTouchDev

static int openTouchDev( char const *devName ){
   int fd = -1 ;
   if( !isSerial(devName) ){
      fd = open(devName, O_RDONLY);
   }
   else {
      printf( "Serial touch screen\n" );
      char const *end = strchr( devName, ',' );
      if( 0 == end )
         end = devName + strlen(devName);
      unsigned nameLen = end-devName ;
      printf( "nameLen: %u, end %p\n", nameLen, end );
      char deviceName[512];
      if( nameLen < sizeof(deviceName) ){
         memcpy( deviceName, devName, nameLen );
         deviceName[nameLen] = '\0' ;
         unsigned baud = 9600 ;
         unsigned databits = 8 ;
         char parity = 'N' ;
         unsigned stop = 1 ;
         if( '\0' != *end ){
            end++ ;
            baud = 0 ; 
            while( isdigit(*end) ){
               baud *= 10 ;
               baud += ( *end-'0' );
               end++ ;
            }

            if( ',' == *end ){
               end++ ;
               databits = *end-'0' ;
               end++ ;
               if( ',' == *end ){
                  end++ ;
                  parity = *end++ ;
                  if( ',' == *end ){
                     stop = end[1] - '0';
                  }
               }
            }
         }
         fd = open( deviceName, O_RDWR );
         if( 0 < fd ){
            printf( "settings: %s,%u,%u,%c,%u\n", deviceName, baud, databits, parity, stop );
            setBaud( fd, baud );
            setRaw( fd );
            setDataBits( fd, databits );
            setStopBits( fd, stop );
            setParity( fd, parity );
         }
         else
            perror( deviceName );
      }
      else
         fprintf( stderr, "Invalid touch device name\n" );
   }

   return fd ;
}
开发者ID:boundarydevices,项目名称:bdScript,代码行数:60,代码来源:touchPoll.cpp

示例4: setBaud

void
SerialPort::setSerial(int baud, int dataBits, int parity, int stopBits)
{
    setBaud(baud);
    setDataBits(dataBits);
    setParity(parity);
    setStopBits(stopBits);
}
开发者ID:cwarden,项目名称:quasar,代码行数:8,代码来源:serial_port_unix.cpp

示例5: sizeof

/*!
\fn bool Win_QextSerialPort::open(OpenMode mode)
Opens a serial port.  Note that this function does not specify which device to open.  If you need
to open a device by name, see Win_QextSerialPort::open(const char*).  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 Win_QextSerialPort::open(OpenMode mode) {
	unsigned long confSize = sizeof(COMMCONFIG);
	Win_CommConfig.dwSize = confSize;
	DWORD dwFlagsAndAttributes = 0;
	if (queryMode() == QextSerialBase::EventDriven)
		dwFlagsAndAttributes += FILE_FLAG_OVERLAPPED;

    LOCK_MUTEX();
    if (mode == QIODevice::NotOpen)
        return isOpen();
    if (!isOpen()) {
        /*open the port*/
        Win_Handle=CreateFileA(port.toLatin1(), GENERIC_READ|GENERIC_WRITE,
                              FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, dwFlagsAndAttributes, NULL);
        if (Win_Handle!=INVALID_HANDLE_VALUE)
        {
            /*configure port settings*/
            GetCommConfig(Win_Handle, &Win_CommConfig, &confSize);
            GetCommState(Win_Handle, &(Win_CommConfig.dcb));

            /*set up parameters*/
            Win_CommConfig.dcb.fBinary=TRUE;
            Win_CommConfig.dcb.fInX=FALSE;
            Win_CommConfig.dcb.fOutX=FALSE;
            Win_CommConfig.dcb.fAbortOnError=FALSE;
            Win_CommConfig.dcb.fNull=FALSE;
            setBaudRate(Settings.BaudRate);
            setDataBits(Settings.DataBits);
            setStopBits(Settings.StopBits);
            setParity(Settings.Parity);
            setFlowControl(Settings.FlowControl);
            setTimeout(Settings.Timeout_Millisec);
            SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));

            //init event driven approach
			if (queryMode() == QextSerialBase::EventDriven) {
		        Win_CommTimeouts.ReadIntervalTimeout = MAXDWORD;
		        Win_CommTimeouts.ReadTotalTimeoutMultiplier = 0;
		        Win_CommTimeouts.ReadTotalTimeoutConstant = 0;
				Win_CommTimeouts.WriteTotalTimeoutMultiplier = 0;
				Win_CommTimeouts.WriteTotalTimeoutConstant = 0;
				SetCommTimeouts(Win_Handle, &Win_CommTimeouts);
            	if (!SetCommMask( Win_Handle, EV_TXEMPTY | EV_RXCHAR | EV_DSR)) {
            		qWarning("Failed to set Comm Mask. Error code: %ld", GetLastError());
					UNLOCK_MUTEX();
            		return false;
            	}
            	overlapThread->start();
            }
			QIODevice::open(mode);
        }
    } else {
		UNLOCK_MUTEX();
    	return false;
    }
    UNLOCK_MUTEX();
    return isOpen();
}
开发者ID:Magic3DPrinter,项目名称:Bservers,代码行数:65,代码来源:win_qextserialport.cpp

示例6: setBaudRate

/*! \brief SerialDevice::stopDevice Is the serial interface's implementation of setDefaults.
 * Sets the serial devices to the default values. (Rate=9600, Parity=None, Flow=None, Data=8, Stop=1)
 */
void SerialDevice::setDefaults()
{
    statusReady = false;
    setBaudRate(9600);
    setParity(0);
    setFlowControl(0);
    setDataBits(8);
    setStopBits(1);
}
开发者ID:FIGS-FESS,项目名称:FESSGUI,代码行数:12,代码来源:serialdevice.cpp

示例7: disable

void Serial::config(uint32_t speed, Serial::Parity parity, Serial::WordLength dataBits, Serial::StopBits stopBits, HardwareFlowControl hardwareFlow)
{
    disable(Device::Part::All);
    setSpeed(speed);
    setParity(parity);
    setWordLength(dataBits);
    setStopBits(stopBits);
    setHardwareFlowControl(hardwareFlow);
}
开发者ID:thomaswihl,项目名称:wos,代码行数:9,代码来源:Serial.cpp

示例8: setBaudRate

/*!
		\fn Win_QextSerialPort::Win_QextSerialPort(const PortSettings& settings)
			Constructs a port with default name and specified settings.
*/
Win_QextSerialPort::Win_QextSerialPort(const PortSettings& settings) {
	Win_Handle=INVALID_HANDLE_VALUE;
	setBaudRate(settings.BaudRate);
	setDataBits(settings.DataBits);
	setStopBits(settings.StopBits);
	setParity(settings.Parity);
	setFlowControl(settings.FlowControl);
	setTimeout(settings.Timeout_Sec, settings.Timeout_Millisec);
}
开发者ID:fcrohas,项目名称:QIcomPCR,代码行数:13,代码来源:win_qextserialport.cpp

示例9: setBaudRate

/*!
Sets the port settigns.
*/
void QextSerialPort::setPortSetting(const PortSettings& settings)
{
    setBaudRate(settings.BaudRate);
    setDataBits(settings.DataBits);
    setParity(settings.Parity);
    setStopBits(settings.StopBits);
    setFlowControl(settings.FlowControl);
    setTimeout(settings.Timeout_Millisec);
}
开发者ID:Jacob1988,项目名称:lxyppc-serial,代码行数:12,代码来源:qextserialport.cpp

示例10: lock

/*!
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 QextSerialPort::open(OpenMode mode)
{
    QMutexLocker lock(mutex);
    if (mode == QIODevice::NotOpen)
        return isOpen();
    if (!isOpen()) {
        qDebug() << "trying to open file" << port.toAscii();
        //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


            /* the equivelent of cfmakeraw() to enable raw access */
#ifdef HAVE_CFMAKERAW
            cfmakeraw(&Posix_CommConfig);   // Enable raw access
#else
            Posix_CommConfig.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP
                                    | INLCR | IGNCR | ICRNL | IXON);
            Posix_CommConfig.c_oflag &= ~OPOST;
            Posix_CommConfig.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
            Posix_CommConfig.c_cflag &= ~(CSIZE | PARENB);
            Posix_CommConfig.c_cflag |= CS8;
#endif

            /*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);

            if (queryMode() == QextSerialPort::EventDriven) {
                readNotifier = new QSocketNotifier(fd, QSocketNotifier::Read, this);
                connect(readNotifier, SIGNAL(activated(int)), this, SIGNAL(readyRead()));
            }
开发者ID:MChemodanov,项目名称:marble,代码行数:61,代码来源:posix_qextserialport.cpp

示例11: sizeof

/*!
Opens a serial port.  Note that this function does not specify which device to open.  If you need
to open a device by name, see QextSerialPort::open(const char*).  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 QextSerialPort::open(OpenMode mode) {
    unsigned long confSize = sizeof(COMMCONFIG);
    Win_CommConfig.dwSize = confSize;
    DWORD dwFlagsAndAttributes = 0;
    if (queryMode() == QextSerialPort::EventDriven)
        dwFlagsAndAttributes += FILE_FLAG_OVERLAPPED;

    QMutexLocker lock(mutex);
    if (mode == QIODevice::NotOpen)
        return isOpen();
    if (!isOpen()) {
        /*open the port*/
        Win_Handle=CreateFileA(port.toAscii(), GENERIC_READ|GENERIC_WRITE,
                              0, NULL, OPEN_EXISTING, dwFlagsAndAttributes, NULL);
        if (Win_Handle!=INVALID_HANDLE_VALUE) {
            QIODevice::open(mode);
            /*configure port settings*/
            GetCommConfig(Win_Handle, &Win_CommConfig, &confSize);
            GetCommState(Win_Handle, &(Win_CommConfig.dcb));

            /*set up parameters*/
            Win_CommConfig.dcb.fBinary=TRUE;
            Win_CommConfig.dcb.fInX=FALSE;
            Win_CommConfig.dcb.fOutX=FALSE;
            Win_CommConfig.dcb.fAbortOnError=FALSE;
            Win_CommConfig.dcb.fNull=FALSE;
            setBaudRate(Settings.BaudRate);
            setDataBits(Settings.DataBits);
            setStopBits(Settings.StopBits);
            setParity(Settings.Parity);
            setFlowControl(Settings.FlowControl);
            setTimeout(Settings.Timeout_Millisec);
            SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));

            //init event driven approach
            if (queryMode() == QextSerialPort::EventDriven) {
                Win_CommTimeouts.ReadIntervalTimeout = MAXDWORD;
                Win_CommTimeouts.ReadTotalTimeoutMultiplier = 0;
                Win_CommTimeouts.ReadTotalTimeoutConstant = 0;
                Win_CommTimeouts.WriteTotalTimeoutMultiplier = 0;
                Win_CommTimeouts.WriteTotalTimeoutConstant = 0;
                SetCommTimeouts(Win_Handle, &Win_CommTimeouts);
                if (!SetCommMask( Win_Handle, EV_TXEMPTY | EV_RXCHAR | EV_DSR)) {
                    qWarning() << "failed to set Comm Mask. Error code:", GetLastError();
                    return false;
                }
                winEventNotifier = new QWinEventNotifier(overlap.hEvent, this);
                connect(winEventNotifier, SIGNAL(activated(HANDLE)), this, SLOT(onWinEvent(HANDLE)));
                WaitCommEvent(Win_Handle, &eventMask, &overlap);
            }
        }
    } else {
        return false;
    }
    return isOpen();
}
开发者ID:M-Elfeki,项目名称:Auto_Pilot,代码行数:62,代码来源:win_qextserialport.cpp

示例12: construct

/*!
\fn Posix_QextSerialPort::Posix_QextSerialPort(const char* name, const PortSettings& settings)
Constructs a port with specified name and settings.
*/
Posix_QextSerialPort::Posix_QextSerialPort(const char* name, const PortSettings& settings)
                     :QextSerialBase(name) {
    construct();
    setBaudRate(settings.BaudRate);
    setDataBits(settings.DataBits);
    setStopBits(settings.StopBits);
    setParity(settings.Parity);
    setFlowControl(settings.FlowControl);
    setTimeout(settings.Timeout_Sec, settings.Timeout_Millisec);
}
开发者ID:BackupTheBerlios,项目名称:poa,代码行数:14,代码来源:posix_qextserialport.cpp

示例13: LOCK_MUTEX

/*!
\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)
    {
        UNLOCK_MUTEX();
        return isOpen();
    }

    if (!isOpen())
    {
        /*open the port*/
        Posix_File->setFileName(port);
        QueueReceiveSignals = 10;
        if (Posix_File->open(QIODevice::ReadWrite | QIODevice::Unbuffered))
        {
            /*set open mode*/
            QIODevice::open(mode);

            /*configure port settings*/
            tcgetattr(Posix_File->handle(), &Posix_CommConfig);

            /*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|IGNBRK|PARMRK|ISTRIP|ICRNL|IXANY));
            Posix_CommConfig.c_oflag&=(~OPOST);
            Posix_CommConfig.c_cc[VMIN]=0;
            Posix_CommConfig.c_cc[VINTR] = _POSIX_VDISABLE;
            Posix_CommConfig.c_cc[VQUIT] = _POSIX_VDISABLE;
            Posix_CommConfig.c_cc[VSTART] = _POSIX_VDISABLE;
            Posix_CommConfig.c_cc[VSTOP] = _POSIX_VDISABLE;
            Posix_CommConfig.c_cc[VSUSP] = _POSIX_VDISABLE;
            setBaudRate(Settings.BaudRate);
            setDataBits(Settings.DataBits);
            setParity(Settings.Parity);
            setStopBits(Settings.StopBits);
            setFlowControl(Settings.FlowControl);
            //setTimeout(Settings.Timeout_Sec, Settings.Timeout_Millisec);
            setTimeout(Settings.Timeout_Millisec);
            tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);

            handle = Posix_File->handle();
            readerThread->handle = handle;
            readerThread->shutdown = false;
            readerThread->start();
        }
        else
        {
            qDebug("Could not open File! Error code : %d", Posix_File->error());
        }
    }
    UNLOCK_MUTEX();
    return isOpen();
}
开发者ID:bcabebe,项目名称:Serial-Bootloader-AN1310-v1.05,代码行数:61,代码来源:posix_qextserialport.cpp

示例14: setPortName

/*!
 * \brief SerialDev::configPort - Parametri per configurare la porta seriale
 * \return true se riesce a configurare correttamente la porta seriale
 */
bool SerialDev::configPort (const QString &name)
{
    bool debugVal = m_debug;
    m_debug = true;
    setPortName(name);

    if (!open(QIODevice::ReadWrite)) {
        QString testo = QString("Can't open %1, error code %2")
                    .arg(portName()).arg(error());
        debug(testo);
        return false;
    }

    if (!setBaudRate(QSerialPort::Baud115200)) {
        QString testo = QString("Can't set rate 115200 baud to port %1, error code %2")
                     .arg(portName()).arg(error());
        debug(testo);
        return false;
    }

    if (!setDataBits(QSerialPort::Data8)) {
        QString testo = QString("Can't set 8 data bits to port %1, error code %2")
                     .arg(portName()).arg(error());
        debug(testo);
        return false;
    }

    if (!setParity(QSerialPort::NoParity)) {
        QString testo = QString("Can't set no patity to port %1, error code %2")
                     .arg(portName()).arg(error());
        debug(testo);
        return false;
    }

    if (!setStopBits(QSerialPort::OneStop)) {
        QString testo = QString("Can't set 1 stop bit to port %1, error code %2")
                     .arg(portName()).arg(error());
        debug(testo);
        return false;
    }

    if (!setFlowControl(QSerialPort::NoFlowControl)) {
        QString testo = QString("Can't set no flow control to port %1, error code %2")
                     .arg(portName()).arg(error());
        debug(testo);
        return false;
    }

    connect(this, SIGNAL(error(QSerialPort::SerialPortError)),
            this, SLOT(errorSlot(QSerialPort::SerialPortError)));
    connect(this, SIGNAL(readyRead()), this, SLOT(fromDeviceSlot()));

    m_debug = debugVal;
   return true;
}
开发者ID:specialk74,项目名称:Lexus,代码行数:59,代码来源:serialdev.cpp

示例15: setBaudRate

/*!
\fn Win_QextSerialPort::Win_QextSerialPort(const PortSettings& settings)
Constructs a port with default name and specified settings.
*/
Win_QextSerialPort::Win_QextSerialPort(const PortSettings& settings, QextSerialBase::QueryMode mode) {
    Win_Handle=INVALID_HANDLE_VALUE;
    setBaudRate(settings.BaudRate);
    setDataBits(settings.DataBits);
    setStopBits(settings.StopBits);
    setParity(settings.Parity);
    setFlowControl(settings.FlowControl);
    setTimeout(settings.Timeout_Millisec);
    setQueryMode(mode);
    init();
}
开发者ID:Anne081031,项目名称:ParkCode,代码行数:15,代码来源:win_qextserialport.cpp


注:本文中的setStopBits函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。