• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ setParity函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: setBaud

void NetworkManager::SerialSetting::fromMap(const QVariantMap &setting)
{
    if (setting.contains(QLatin1String(NM_SETTING_SERIAL_BAUD))) {
        setBaud(setting.value(QLatin1String(NM_SETTING_SERIAL_BAUD)).toUInt());
    }

    if (setting.contains(QLatin1String(NM_SETTING_SERIAL_BITS))) {
        setBits(setting.value(QLatin1String(NM_SETTING_SERIAL_BITS)).toUInt());
    }

    if (setting.contains(QLatin1String(NM_SETTING_SERIAL_PARITY))) {
        QChar character = setting.value(QLatin1String(NM_SETTING_SERIAL_PARITY)).toChar();

        if (character == 'n') {
            setParity(NoParity);
        } else if (character == 'E') {
            setParity(EvenParity);
        } else if (character == 'o') {
            setParity(OddParity);
        }
    }

    if (setting.contains(QLatin1String(NM_SETTING_SERIAL_STOPBITS))) {
        setStopbits(setting.value(QLatin1String(NM_SETTING_SERIAL_STOPBITS)).toUInt());
    }

    if (setting.contains(QLatin1String(NM_SETTING_SERIAL_SEND_DELAY))) {
        setSendDelay((Setting::SecretFlagType)setting.value(QLatin1String(NM_SETTING_SERIAL_SEND_DELAY)).toULongLong());
    }
}
开发者ID:Bridges,项目名称:libnm-qt5,代码行数:30,代码来源:serialsetting.cpp


示例2: switch

bool serial::setFormat (format_t fmt)
{
	bool r = true;

	switch(fmt) {
	case serial::Format7E1:
		r &= setDatabits(serial::DB7);
		r &= setStopbits(serial::SB1);
		r &= setParity(serial::ParityEven);
		break;
	case serial::Format7O1:
		r &= setDatabits(serial::DB7);
		r &= setStopbits(serial::SB1);
		r &= setParity(serial::ParityOdd);
		break;
	case serial::Format8N1:
	default:
		r &= setDatabits(serial::DB8);
		r &= setStopbits(serial::SB1);
		r &= setParity(serial::ParityNone);
		break;
	}

	return r;
}
开发者ID:semenovf,项目名称:pfs-io-serial,代码行数:25,代码来源:serial.cpp


示例3: m_fd

SerialPort::SerialPort(const string device)
	: m_fd(0), m_baudRate(0), m_wordSize(0), m_asyncTimeout(DEFAULT_ASYNC_TIMEOUT)
{
	if((m_fd = ::open(device.c_str(), O_RDWR | O_NOCTTY)) < 0)
		throw SysException();

	::bzero(&m_term, sizeof(m_term));

	::tcgetattr(m_fd, &m_termOld);

	setBaudRate(DEFAULT_BAUD_RATE);
	setWordSize(DEFAULT_WORD_SIZE);
	setParity(DEFAULT_PARITY);

	m_term.c_cflag |= CLOCAL | CREAD;
	m_term.c_iflag = IGNPAR;
	m_term.c_oflag = OPOST;
	m_term.c_lflag = 0;

	m_term.c_cc[VTIME] = 0;
	m_term.c_cc[VMIN] = 1;

	setAttr();

	if(::fcntl(m_fd, F_SETOWN, getpid()) == -1)
		throw SysException();
}
开发者ID:stuartatpeasy,项目名称:m68k-system,代码行数:27,代码来源:serialport.C


示例4: 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


示例5: 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


示例6: 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


示例7: 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


示例8: 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


示例9: 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


示例10: 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


示例11: 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


示例12: 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


示例13: 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


示例14: 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


示例15: 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


示例16: Setting

NetworkManager::SerialSetting::SerialSetting(const Ptr &other):
    Setting(other),
    d_ptr(new SerialSettingPrivate())
{
    setBaud(other->baud());
    setBits(other->bits());
    setParity(other->parity());
    setStopbits(other->stopbits());
    setSendDelay(other->sendDelay());
}
开发者ID:Bridges,项目名称:libnm-qt5,代码行数:10,代码来源:serialsetting.cpp


示例17: 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


示例18: 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


示例19: initialize

			/*
			 * Initialize Uart HAL Peripheral
			 *
			 * Enables clocks, the UART peripheral (but neither TX nor RX)
			 * Sets baudrate and parity.
			 */
			static void
			initialize(uint32_t baudrate, Parity parity = Parity::Disabled)
			{
				enable();
				// DIRTY HACK: disable and reenable uart to be able to set
				//             baud rate as well as parity
				USART2->CR1 &= ~USART_CR1_UE;	// Uart Disable
				setBaudrate(baudrate);
				setParity(parity);
				USART2->CR1 |=  USART_CR1_UE;	// Uart Reenable
			}
开发者ID:Alex0704t,项目名称:xpcc,代码行数:17,代码来源:usart_hal_2.hpp


示例20: 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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ setPen函数代码示例发布时间:2022-05-30
下一篇:
C++ setParentPresenceVector函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap