--- cutecom-0.22.0/cutecom.desktop +++ cutecom-0.22.0/cutecom.desktop @@ -1,13 +1,9 @@ [Desktop Entry] -Encoding=UTF-8 -BinaryPattern= Name=CuteCom -MimeType= GenericName=Serial Terminal Exec=cutecom -Icon=openterm -TerminalOptions= -Path= +Icon=emblem-mounted Type=Application -Terminal=0 -X-KDE-StartupNotify=false +Terminal=false +Categories=System;TerminalEmulator; +StartupNotify=true --- cutecom-0.22.0/cutecommdlg.ui +++ cutecom-0.22.0/cutecommdlg.ui @@ -1,7 +1,8 @@ - + + CuteCommDlg - - + + 0 0 @@ -9,203 +10,218 @@ 648 - + CuteCom - + + + 0 + + + 0 + - - - - + + + QLayout::SetDefaultConstraint + + + 0 + + + + Stop bits: - + false - + m_stopCb - - - + + + &Quit - + Alt+Q - - - + + + Data bits: - + false - + m_dataBitsCb - - - + + + &About - + Alt+A - - - + + + 3 - + 5 - + 6 - + 7 - + 8 - - - + + + Device: - + false - + m_deviceCb - - - + + + - + &Open device - + Alt+O - - - + + + Cl&ose device - + Alt+O - - + + - + 1 - + 2 - - - + + + Baud rate: - + false - + m_baudCb - - - + + + true - - - - 7 + + + + -1 - - + + + + 0 + - + - - + + Parity: - + false - + m_parityCb - + - + None - + Odd - + Even - + Mark - + Space @@ -214,63 +230,63 @@ - - - - + + + + Enable Hardware Handshake - + Hardware - - - + + + Enable Software Handshake (XON/XOFF) - + Software - - - + + + Usually you want to use read and write - + Writing - - - + + + Usually you want to use read and write - + Reading - - - + + + Open for: - + false - - - + + + Handshake: - + false @@ -278,8 +294,8 @@ - - + + Apply settings when opening @@ -289,113 +305,131 @@ - - + + Qt::Vertical - - - + + 5 + + + + 0 2 - + QFrame::NoFrame - + QFrame::Plain - + + + 0 + + + 0 + + + 0 + - - + + - Courier + Monospace + + QFrame::StyledPanel + + + QFrame::Sunken + - + - - + + Clear the output window - + &Clear - + Alt+C - - - + + + 1 0 - + Show the output in hexadecimal format - + &Hex output - + Alt+H - - - Enable logging the data to a file. Chose "Append to" to append instead overwrite to an existing file. + + + Enable logging the data to a file. Chose "Append to" to append instead overwrite to an existing file. - + - - - Enable logging the data to a file. Chose "Append to" to append instead overwrite to an existing file. + + + Enable logging the data to a file. Chose "Append to" to append instead overwrite to an existing file. - + Log to: - + Append to: - - - + + + 2 0 - + The logfile - - + + Open file dialog - + ... @@ -404,41 +438,60 @@ - - - + + + 0 1 - + QFrame::NoFrame - + QFrame::Plain - + + + 0 + + + 0 + + + 0 + - + + + QFrame::StyledPanel + + + QFrame::Sunken + + + 1 + + - + - - + + &Input: - + false - + m_cmdLe - - + + Enter commands here, Ctrl+C, Ctrl+S, Ctrl+Q also work @@ -446,66 +499,76 @@ - + + + -1 + - - + + Select a file to be sent using the specified protocol - + Send file... - + false - - + + Select the transfer protocol - + Plain - + XModem - + ZModem - + YModem - + 1kXModem - + Script + + + Set BREAK + + + + - + Qt::Horizontal - + QSizePolicy::Expanding - + 40 20 @@ -514,59 +577,59 @@ - - + + Select the line end termination - + LF line end - + CR line end - + CR,LF line end - + No line end - + Hex input - - + + Char delay: - + false - - + + Delay between single characters - + ms - + 250 - + 1 @@ -579,7 +642,7 @@ - + qPixmapFromMimeSource m_connectPb --- cutecom-0.22.0/qcppdialogimpl.cpp +++ cutecom-0.22.0/qcppdialogimpl.cpp @@ -18,6 +18,7 @@ #include "qcppdialogimpl.h" +#include #include #include #include @@ -99,6 +100,7 @@ connect(m_cmdLe, SIGNAL(returnPressed()), this, SLOT(execCmd())); connect(m_sendPb, SIGNAL(clicked()), this, SLOT(sendFile())); + connect(m_sendBreakPb, SIGNAL(clicked()), this, SLOT(sendBreak())); connect(m_aboutPb, SIGNAL(clicked()), this, SLOT(showAboutMsg())); connect(m_quitPb, SIGNAL(clicked()), this, SLOT(close())); @@ -121,7 +123,7 @@ connect(m_applyCb, SIGNAL(clicked()), this, SLOT(saveSettings())); connect(m_hexOutputCb, SIGNAL(clicked()), this, SLOT(saveSettings())); connect(m_inputModeCb, SIGNAL(activated(int)), this, SLOT(saveSettings())); - connect(m_charDelaySb, SIGNAL(valueChanged(int)), this, SLOT(saveSettings())); + connect(m_charDelaySb, SIGNAL(editingFinished(int)), this, SLOT(saveSettings())); connect(m_logAppendCb, SIGNAL(activated(int)), this, SLOT(saveSettings())); connect(m_applyCb, SIGNAL(toggled(bool)), this, SLOT(enableSettingWidgets(bool))); @@ -134,7 +136,7 @@ // connect(m_enableLoggingCb, SIGNAL(toggled(bool)), this, SLOT(enableLogging(bool))); m_outputView->setWordWrapMode(QTextOption::WrapAnywhere); - m_outputView->document()->setMaximumBlockCount(500); + m_outputView->document()->setMaximumBlockCount(10500); // TODO ? m_outputView->setWordWrap(Q3TextEdit::WidgetWidth); /* QAccel* accel=new QAccel(this); @@ -277,24 +279,6 @@ QString currentDevice=m_deviceCb->currentText(); settings.setValue("/cutecom/CurrentDevice", currentDevice); - bool currentDeviceIsInList=false; - QStringList devices; - for (int i=0; icount(); i++) - { - QString s=m_deviceCb->itemText(i); - devices<count(); if (historyCount>50) @@ -346,13 +330,41 @@ { resize(x,y); } + /* scan for modem devices */ + + int n; + + QDir dir("/dev"); + + QStringList filters; + + /* + * Device filters for: + * + * FreeBSD: cuaU0, cuad0 [0..99] + * Linux: ttyS0 [0..99] + * Apple: cu.* + */ + + filters + << "ttyS[0123456789]" + << "ttyUSB[0123456789]"; + + dir.setFilter(QDir::Files | QDir::System); + dir.setNameFilters(filters); + dir.setSorting(QDir::Name); + + QFileInfoList list = dir.entryInfoList(); + QStringList devices; bool entryFound = settings.contains("/cutecom/AllDevices"); - QStringList devices=settings.value("/cutecom/AllDevices").toStringList(); - if (!entryFound) - { - devices<<"/dev/ttyS0"<<"/dev/ttyS1"<<"/dev/ttyS2"<<"/dev/ttyS3"; + devices=settings.value("/cutecom/AllDevices").toStringList(); + for (n = 0; n != list.size(); n++) { + QFileInfo fileInfo = list.at(n); + devices << (QString("/dev/") + fileInfo.fileName()); } + devices.removeDuplicates(); + devices.sort(); m_deviceCb->insertItems(0, devices); @@ -381,6 +393,13 @@ void QCPPDialogImpl::sendFile() { + unsigned int charDelay = 0; + + if (m_sendFileActive != 0) + return; + + m_sendFileActive++; + if (m_fileDlg==0) { m_fileDlg=new QFileDialog(); @@ -401,17 +420,17 @@ } else { - return; + goto done; } - unsigned int charDelay=m_charDelaySb->value(); + charDelay=m_charDelaySb->value(); if (m_protoPb->currentText()=="Script") { QFile file(filename); if (!file.open(QIODevice::ReadOnly)) { QMessageBox::information(this, tr("Opening file failed"), tr("Could not open file %1").arg(filename)); - return; + goto done; } QTextStream stream(&file); @@ -427,7 +446,7 @@ if (!sendString(nextLine)) { QMessageBox::information(this, tr("Comm error"), tr("Sending failed")); - return; + goto done; } millisleep(charDelay*3); } @@ -438,7 +457,7 @@ if (!file.open(QIODevice::ReadOnly)) { QMessageBox::information(this, tr("Opening file failed"), tr("Could not open file %1").arg(filename)); - return; + goto done; } QByteArray data=file.readAll(); delete m_progress; @@ -523,7 +542,7 @@ delete m_sz; m_sz=0; connectTTY(); - return; + goto done; } m_progress=new QProgressDialog(tr("Sending file via xmodem..."), tr("Cancel"), 0, 100, this); connect(m_progress, SIGNAL(cancelled()), this, SLOT(killSz())); @@ -553,6 +572,29 @@ { QMessageBox::information(this, tr("Opening file failed"), tr("Protocol %1 not supported yet").arg(m_protoPb->currentText())); } + done: + m_sendFileActive--; +} + +void QCPPDialogImpl::sendBreak() +{ + if (m_break == 0) { + if (m_fd < 0) + return; + + ioctl(m_fd, TIOCSBRK, 0); + + m_sendBreakPb->setText(QString("Clr BREAK")); + + m_break = 1; + } else { + if (m_fd > -1) + ioctl(m_fd, TIOCCBRK, 0); + + m_sendBreakPb->setText(QString("Set BREAK")); + + m_break = 0; + } } void QCPPDialogImpl::killSz() @@ -965,6 +1007,7 @@ m_sendPb->setEnabled(true); m_protoPb->setEnabled(true); m_closePb->setEnabled(true); + m_sendBreakPb->setEnabled(true); m_cmdLe->setFocus(); @@ -1019,12 +1062,15 @@ m_sendPb->setEnabled(false); m_protoPb->setEnabled(false); m_closePb->setEnabled(false); + m_sendBreakPb->setEnabled(false); m_connectPb->setFocus(); m_isConnected=false; delete m_notifier; m_notifier=0; + if (m_break != 0) + sendBreak(); } @@ -1250,6 +1296,9 @@ if (bytesRead<0) { + // check for device gone, for example USB + if (errno != EINTR && errno != EWOULDBLOCK) + disconnectTTY(); std::cerr<<"read result: "<append(m_outputBuffer); - m_outputBuffer.clear(); + if (m_outputBuffer.isEmpty()) + return; + + vScrollBar = m_outputView->verticalScrollBar(); + scrollWithText = (vScrollBar->value() == vScrollBar->maximum()); + + QTextCursor cursor(m_outputView->document()); + cursor.movePosition(QTextCursor::End); + cursor.insertText(m_outputBuffer); + + if ((scrollWithText)) + vScrollBar->setValue(vScrollBar->maximum()); + + m_outputBuffer.clear(); } void QCPPDialogImpl::hexOutputClicked(bool /* on */) --- cutecom-0.22.0/qcppdialogimpl.h +++ cutecom-0.22.0/qcppdialogimpl.h @@ -50,6 +50,7 @@ void execCmd(); void readData(int fd); void sendFile(); + void sendBreak(); void showAboutMsg(); void oldCmdClicked(QListWidgetItem* item); @@ -81,6 +82,8 @@ bool m_isConnected; int m_fd; + int m_break; + int m_sendFileActive; struct termios m_oldtio; unsigned int m_cmdBufIndex; QSocketNotifier *m_notifier;