Diffstat (limited to 'noncore/apps/opie-console/io_serial.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-console/io_serial.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/noncore/apps/opie-console/io_serial.cpp b/noncore/apps/opie-console/io_serial.cpp index 77ced85..929aeff 100644 --- a/noncore/apps/opie-console/io_serial.cpp +++ b/noncore/apps/opie-console/io_serial.cpp @@ -35,24 +35,28 @@ void IOSerial::close() { } else { emit error(Refuse, tr("Not connected")); } } bool IOSerial::open() { + qWarning("open"); if (!m_fd) { + qWarning("going to open %s", m_device.latin1()); struct termios tty; m_fd = ::open(m_device, O_RDWR | O_NOCTTY | O_NONBLOCK); if (m_fd < 0) { + qWarning(" fd < 0 "); emit error(CouldNotOpen, strerror(errno)); return FALSE; } tcgetattr(m_fd, &tty); /* Baud rate */ int speed = baud(m_baud); if (speed == -1) { + qWarning("speed -1"); emit error(Refuse, tr("Invalid baud rate")); } cfsetospeed(&tty, speed); cfsetispeed(&tty, speed); /* Take care of Space / Mark parity */ @@ -110,20 +114,23 @@ bool IOSerial::open() { m_read = new QSocketNotifier(m_fd, QSocketNotifier::Read, this); m_error = new QSocketNotifier(m_fd, QSocketNotifier::Exception, this); connect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived())); connect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured())); return TRUE; } else { + qWarning("opened"); emit error(Refuse, tr("Device is already connected")); m_fd = 0; return FALSE; } } void IOSerial::reload(const Profile &config) { m_device = config.readEntry("Device", SERIAL_DEFAULT_DEVICE); + qWarning( "Dev" +m_device ); + qWarning( "Conf:" +config.readEntry("Device") ); m_baud = config.readNumEntry("Baud", SERIAL_DEFAULT_BAUD); m_parity = config.readNumEntry("Parity", SERIAL_DEFAULT_PARITY); m_dbits = config.readNumEntry("DataBits", SERIAL_DEFAULT_DBITS); m_sbits = config.readNumEntry("StopBits", SERIAL_DEFAULT_SBITS); m_flow = config.readNumEntry("Flow", SERIAL_DEFAULT_FLOW); } @@ -147,21 +154,20 @@ int IOSerial::baud(int baud) const { void IOSerial::errorOccured() { emit error(ClosedUnexpected, strerror(errno)); close(); } void IOSerial::dataArrived() { - QByteArray array; - char buf[4096]; + QByteArray array(4096); - int len = read(m_fd, buf, 4096); + int len = read(m_fd, array.data(), 4096); if (len == 0) close(); if (len < 0) return; - array.setRawData(buf, len); + array.resize( len ); emit received(array); } QString IOSerial::identifier() const { return "serial"; } |