C++ (Qt) serialPort = new SerialPort(this); connect(serialPort, SIGNAL(readyRead()), this, SLOT(onReadyRead())); serialPort->setPort("/dev/vsps0"); serialPort->setRate(SerialPort::Rate9600, SerialPort::Input); serialPort->setRate(SerialPort::Rate9600, SerialPort::Output); serialPort->setDataBits(SerialPort::Data8); serialPort->setParity(SerialPort::NoParity); serialPort->setFlowControl(SerialPort::NoFlowControl); serialPort->setStopBits(SerialPort::OneStop); serialPort->setReadBufferSize(1024); serialPort->open(SerialPort::ReadWrite);
C++ (Qt) array.append((char)0x00); array.append((char)0x40); array.append((char)0x26); array.append((char)0x31); array.append((char)0x09); array.append((char)0x60); serialPort->write(array);
C++ (Qt)while(!asleep()) sheep++;
C++ (Qt)bool UnixSerialPortEngine::eventFilter(QObject *obj, QEvent *e){ if (e->type() == QEvent::SockAct) { if (obj == m_readNotifier) { m_parent->canReadNotification(); return true; } if (obj == m_writeNotifier) { m_parent->canWriteNotification(); return true; } if (obj == m_exceptionNotifier) { m_parent->canErrorNotification(); return true; } } return QObject::eventFilter(obj, e);}
C++ (Qt) if (obj == m_readNotifier) { m_parent->canReadNotification(); return true; }
C...static unsigned int vsp_poll( struct VSP_ROOT *_root, int _num, poll_table *_pt, struct file *_file) { unsigned int mask = 0; struct VSP_DEV *dev_read, *dev_write; if ( _num >= _root->maxdev) return( -ENODEV); /* if write to file ==> dev = file (F->F) 0->1 */ /* if write to port ==> dev = port (S->S) 1->0 */ dev_read = &( _root->devices_S[ _num]); dev_write = &( _root->devices_D[ _num]); poll_wait( _file, &( dev_read->wqr), _pt); poll_wait( _file, &( dev_write->wqw), _pt); if ( dev_read->buff_len > 0) mask |= POLLIN | POLLRDNORM; /* readable */ if ( dev_write->buff_len < VSP_MAXBUF - 1) mask |= POLLOUT | POLLWRNORM; /* writable */ if ( debug > 2) KLOG( "[%s] poll/select returns %i for R%s W%s to %s(%d)\n", VSP_MOD_NAME, mask, dev_read->name, dev_write->name, VSP_PCOMM, VSP_PID); return( mask); } static unsigned int vspd_poll( struct tty_struct *_tty, struct file *_file, poll_table *_pt) { return( vsp_poll( &rootdev, VSP_MNUMF( _file), _pt, _file)); }static unsigned int vsps_poll( struct tty_struct *_tty, struct file *_file, poll_table *_pt) { return( vsp_poll( &rootdev, VSP_MNUMF( _file), _pt, _file)); } static void vspd_setldisc( struct tty_struct *_tty) { _tty->ldisc.read = vspd_read; _tty->ldisc.write = vspd_l_write; _tty->ldisc.poll = vspd_poll; return; }static void vsps_setldisc( struct tty_struct *_tty) { _tty->ldisc.read = vsps_read; _tty->ldisc.write = vsps_l_write; _tty->ldisc.poll = vsps_poll; return; }...
C++ (Qt)... serialPort->setReadBufferSize(1024);...
C++ (Qt) // If reading from the serial fails after getting a read // notification, close the serial. newBytes = m_readBuffer.size(); if (!readFromPort()) { m_readSerialNotifierCalled = false; return false; }
C++ (Qt) serialPort->setReadBufferSize(1024);
C++ (Qt)qDebug() << "readBuffer" << serialPort->readBufferSize();
C++ (Qt) qint64 bytesToRead = (m_policy == SerialPort::IgnorePolicy) ? bytesAvailable() : 1; if (bytesToRead <= 0) return false;
Cstatic int vsp_ioctl_S( struct VSP_ROOT *_root, int _num, unsigned int _cmd, unsigned long _arg, struct tty_struct *_tty, struct file *_file) {...unsigned short tmp_short = 0;...... case FIONREAD: if ( debug & DEBUG_IOCTL_S) KLOG( "[%s] %s FIONREAD\n", VSP_MOD_NAME, __FUNCTION__); if ( VSP_ACCESS_OK( VERIFY_WRITE, ( void *)_arg, sizeof( unsigned short)) == 0) return( -EFAULT);// FIXME : write buffer space to tmp_short KTU( ( void *)_arg, &tmp_short, sizeof( unsigned short)); break;......}
C++ (Qt) qint64 bytesToRead = (m_policy == SerialPort::IgnorePolicy) ? 256 : 1; if (bytesToRead <= 0) return false;