cutecom-0.22.0/0000775000175100001440000000000011220755155012110 5ustar alexuserscutecom-0.22.0/CMakeLists.txt0000644000175100001440000000346611220506311014643 0ustar alexuserscmake_minimum_required(VERSION 2.4.3 FATAL_ERROR ) project(CuteCom) set(QT_MIN_VERSION 4.1.0) find_package(Qt4 REQUIRED) include_directories(${QT_INCLUDES} ${CMAKE_BINARY_DIR}) add_definitions(-DQT3_SUPPORT) set(cutecomSrcs main.cpp qcppdialogimpl.cpp) qt4_wrap_cpp(cutecomSrcs qcppdialogimpl.h) qt4_wrap_ui(cutecomSrcs cutecommdlg.ui) set(exeType) set(binInstallDir bin ) if(APPLE) # with cmake < 2.6 install(TARGETS ... BUNDLE DESTINATION ... ) doesn't work: cmake_minimum_required(VERSION 2.6 FATAL_ERROR ) set(exeType MACOSX_BUNDLE) set(binInstallDir /Applications ) # hint to linker for indirect referenced libs inside qt3support set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -dylib_file QtSql.framework/Versions/4/QtSql:/Library/Frameworks/QtSql.framework/Versions/4/QtSql") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -dylib_file QtNetwork.framework/Versions/4/QtNetwork:/Library/Frameworks/QtNetwork.framework/Versions/4/QtNetwork") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -dylib_file QtXml.framework/Versions/4/QtXml:/Library/Frameworks/QtXml.framework/Versions/4/QtXml") endif(APPLE) add_executable(cutecom ${exeType} ${cutecomSrcs} ${uiHeaders}) target_link_libraries(cutecom ${QT_QT3SUPPORT_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY}) if (APPLE) set_target_properties(cutecom PROPERTIES OUTPUT_NAME CuteCom) endif (APPLE) install(TARGETS cutecom DESTINATION ${binInstallDir} ) install(FILES cutecom.1 DESTINATION share/man/man1 ) find_program(KDECONFIG_EXECUTABLE NAMES kde-config ) if (KDECONFIG_EXECUTABLE) # then ask kde-config for the kde data dirs exec_program(${KDECONFIG_EXECUTABLE} ARGS --install apps --expandvars OUTPUT_VARIABLE _apps_DIR ) install(FILES cutecom.desktop DESTINATION ${_apps_DIR}/Utilities) endif (KDECONFIG_EXECUTABLE) cutecom-0.22.0/COPYING0000644000175100001440000004311610073572406013147 0ustar alexusers GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. cutecom-0.22.0/Changelog0000644000175100001440000000675411221407524013727 0ustar alexusers0.22.0, June 27th, 2009 -CuteCom now also works on Mac OS X, patch by Oliver Klauke -support for more baudrates -install man page to /share/man/man1 instead to /man/man1 (seems to be more standard conform) -require Qt >= 4.1.0 (0.21.0 required 4.3) 0.21.0, May 11th, 2009 -disconnect from the device if it disappears, e.g. from USB, patch by Bjoern Spruck -less Qt3Support usage 0.20.0, Mar 12th, 2008 -ported to Qt4, using the patches from Federico Fuga and Michael G. Hansen -same features as 0.14.2 otherwise 0.14.2, Jan 26th, 2007 -support for the 1k xmodem protocl, patch by yoann -a cutecom man page, patch from Roman I Khimov -there is now a cvs repository for CuteCom: http://cutecom.cvs.sourceforge.net/cutecom/cutecom/ 0.14.1, Nov 22nd, 2006 -added patch by Bernhard Schiffner which flushes the device when it's opened -CuteCom can now also be built using CMake (http://www.cmake.org) 0.14.0, Jul 16th, 2006 -added log-to-file feature -save the directory used for sendFile() 0.13.2, Jun 9th, 2005 -by default give the output view more room than the input history -even higher repetition rate for Ctrl-C 0.13.1, Feb 2nd, 2005 -added CR line end -use the character delay also for sending files in "Plain" mode -use a slightly bigger delay after potential line ends when sending files in "Plain" or "Script" mode 0.13.0, Jan 29th, 2005 -different input modes (LF line end, LF-CR line end, no line end, hex input) -hex output -adjustable character delay 0.12.0, Nov 09th, 2004 -major performance improvement of the output view -increased repetition rate for Ctrl-C 0.11.0, Oct 13th, 2004 -NEW FEATURE: receive Ctrl+C, Ctrl+Q and Ctrl+S key presses and send them over the serial line -added shortcut keys to some buttons -increased history from 20 to 50 lines 0.10.2, Oct 10th, 2004 -removed negative logic for "Apply settings" -output view: removed tooltip and now it's always enabled -BUGFIX: use the correct port settings for x/y/z modem transfer -BUGFIX: division by zero crash 0.10.1 -added checkbox "Dont apply settings when opening" - if checked, the selected settings won't be applied to the terminal device, useful e.g. when another program is running and already working with this device (e.g. gdb) -fixed read-only opening of the device file 0.10.0 -first stable release -NEW FEATURE: add checkboxes to select whether to open the device read/write, read-only, write-only (write-only is especially useful when debugging with gdb over a serial line and you need a terminaal to enter commands) 0.0.8 -BUGFIX: make the output view really actually work as expected -make xmodem, ymodem and zmodem transfers actually work -removed the "Exec file" button and added a "Script" protocol to "Send file" -> it will be interpreted line by line, everything after a "#" will be ignored -improved focus and history handling -the file dialog now remembers the dir where it was closed the last time 0.0.7 -BUGFIX: make the output view actually work as expected 0.0.6 -save the last 20 history entries -only add a history entry if it differs from the previous one -maximum line count of the output view is 1000 lines -maximum history line count is 50 -sending of an empty string (\n) when pressing enter 0.0.5 -the device combobox is now editable -added some tooltips 0.0.4 -first published version, state: beta -serial communication works basically -GUI polishing still needed -no translations Alexander Neundorf cutecom-0.22.0/README0000644000175100001440000000310211220754676012771 0ustar alexusersCuteCom 0.22.0, June 27th, 2009 CuteCom is a graphical serial terminal, similar to minicom. It is aimed mainly at hardware developers or other people who need a terminal to talk to their devices. It is free software and distributed under the GNU General Public License Version 2, which can find in the file COPYING. It is written using the Qt library by Trolltech (www.trolltech.com), at least version 4.1.0 is required. CuteCom doesn't use the autotools (autoconf, automake, libtool, etc.) but CMake (http://www.cmake.org), you need at least version 2.4.3. Enter the source directory and run "cmake ." followed by make and make install and you're done. To make sure it can find Qt4, set the PATH so that qmake from Qt4 is in the PATH (and comes before qmake from Qt3 in the PATH), e.g.: export PATH=/opt/qt4/bin:$PATH; cmake . If you are using CMake >= 2.6.0, adjust the CMAKE_PREFIX_PATH environment variable instead of PATH to help CMake finding Qt4, e.g.: export CMAKE_PREFIX_PATH=/opt/qt4; cmake . To uninstall cutecom simply delete the file "cutecom" and the file "cutecom.desktop" amd your done. The config file is ~/.config/CuteCom/CuteCom.conf. Currently it is known to run on Linux, FreeBSD and Mac OS X, and porting to other systems should be easy. Everything platformspecific should be in QCPPDialogImpl::setNewOptions(). Distributions welcome :-) Now that it uses Qt4 it should also be portable to Windows. CuteCom is heavily inspired by Bray++ for Windows (http://bray.velenje.cx/avr/terminal/) Homepage: http://cutecom.sourceforge.net Alexander Neundorf cutecom-0.22.0/TODO0000644000175100001440000000042310765610002012567 0ustar alexusers-get rid of Qt3Support -add function to search for text in the output view (Ctrl+F and RMB menu of the output view) -make font of the output view configurable (RMB menu of the output view) -add something to measure time between outputs Alexander Neundorf cutecom-0.22.0/configure0000755000175100001440000000046710766043114014023 0ustar alexusers#!/bin/sh echo echo "CuteCom uses the CMake build system, at least version 2.4.3 is required." echo "If there is no package for your distribution, you can " echo "get it from http://www.cmake.org/HTML/Download.html" echo echo "So instead of running ./configure, you need to run cmake:" echo "$ cmake ." echo cutecom-0.22.0/cutecom.10000644000175100001440000000307610532110020013612 0ustar alexusers.\" Hey, EMACS: -*- nroff -*- .\" First parameter, NAME, should be all caps .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection .\" other parameters are allowed: see man(7), man(1) .TH CUTECOM 1 "November 24, 2006" .\" Please adjust this date whenever revising the manpage. .\" .\" Some roff macros, for reference: .\" .nh disable hyphenation .\" .hy enable hyphenation .\" .ad l left justify .\" .ad b justify to both left and right margins .\" .nf disable filling .\" .fi enable filling .\" .br insert line break .\" .sp insert n+1 empty lines .\" for manpage-specific macros, see man(7) .SH NAME cutecom \- graphical serial terminal. .SH SYNOPSIS .B cutecom .SH DESCRIPTION .\" TeX users may be more comfortable with the \fB\fP and .\" \fI\fP escape sequences to invode bold face and italics, .\" respectively. \fBCuteCom\fP is a graphical serial terminal, like \fBminicom\fP. It is aimed mainly at hardware developers or other people who need a terminal to talk to their devices. It features a lineoriented interface instead of character-oriented, xmodem, ymodem, zmodem support (requires the lrzsz package) and hexadecimal input and output among other things. .SH OPTIONS \fBCuteCom\fP doesn't really have any command-line options. .SH SEE ALSO .BR minicom (1), .BR sz (1). .SH AUTHOR CuteCom was written by Alexander Neundorf . .PP This manual page was written by Roman I Khimov , for the Debian project (but may be used by others). cutecom-0.22.0/cutecom.desktop0000644000175100001440000000031110073576172015140 0ustar alexusers[Desktop Entry] Encoding=UTF-8 BinaryPattern= Name=CuteCom MimeType= GenericName=Serial Terminal Exec=cutecom Icon=openterm TerminalOptions= Path= Type=Application Terminal=0 X-KDE-StartupNotify=false cutecom-0.22.0/cutecommdlg.ui0000644000175100001440000004326511220235514014752 0ustar alexusers CuteCommDlg 0 0 756 648 CuteCom 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 Parity: false m_parityCb None Odd Even Mark Space 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 Apply settings when opening Qt::Vertical 0 2 QFrame::NoFrame QFrame::Plain Courier 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. Log to: Append to: 2 0 The logfile Open file dialog ... 0 1 QFrame::NoFrame QFrame::Plain &Input: false m_cmdLe Enter commands here, Ctrl+C, Ctrl+S, Ctrl+Q also work Select a file to be sent using the specified protocol Send file... false Select the transfer protocol Plain XModem ZModem YModem 1kXModem Script Qt::Horizontal QSizePolicy::Expanding 40 20 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 qPixmapFromMimeSource m_connectPb m_closePb m_aboutPb m_quitPb m_deviceCb m_baudCb m_dataBitsCb m_stopCb m_parityCb m_softwareCb m_hardwareCb m_readCb m_writeCb m_applyCb m_outputView m_clearOutputPb m_hexOutputCb m_enableLoggingCb m_logAppendCb m_logFileLe m_logFileFileDialog m_cmdLe m_sendPb m_protoPb m_inputModeCb m_charDelaySb m_oldCmdsLb cutecom-0.22.0/main.cpp0000644000175100001440000000210611034210134013517 0ustar alexusers/* Copyright (C) 2004-2005 Alexander Neundorf This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include "qcppdialogimpl.h" //signal handlers should be installed... int main( int argc, char ** argv ) { QApplication a( argc, argv ); QCPPDialogImpl w(0); w.show(); a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) ); return a.exec(); } cutecom-0.22.0/qcppdialogimpl.cpp0000644000175100001440000010745111220754711015624 0ustar alexusers/* Copyright (C) 2004-2009 Alexander Neundorf This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "qcppdialogimpl.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //Added by qt3to4: #include #include #include #include #include #include #include using namespace std; #include #include #include #include #include #include #include #include #include void millisleep(int ms) { if (ms>0) { struct timeval tv; tv.tv_sec=0; tv.tv_usec=ms*1000; select(0, 0, 0, 0, &tv); } } QCPPDialogImpl::QCPPDialogImpl(QWidget* parent) :QWidget(parent) ,m_isConnected(false) ,m_fd(-1) ,m_cmdBufIndex(0) ,m_notifier(0) ,m_sz(0) ,m_progress(0) ,m_progressStepSize(1000) ,m_fileDlg(0) ,m_outputTimer(this) ,m_keyRepeatTimer(this) ,m_keyCode(0) ,m_hexBytes(0) ,m_previousChar('\0') { QCoreApplication::setOrganizationName("CuteCom"); // QCoreApplication::setOrganizationDomain("mysoft.com"); QCoreApplication::setApplicationName("CuteCom"); this->setupUi(this); fillBaudCb(); connect(m_connectPb, SIGNAL(clicked()), this, SLOT(connectTTY())); connect(m_closePb, SIGNAL(clicked()), this, SLOT(disconnectTTY())); connect(m_clearOutputPb, SIGNAL(clicked()), this, SLOT(clearOutput())); // connect(m_clearInputPb, SIGNAL(clicked()), m_oldCmdsLb, SLOT(clear())); connect(m_cmdLe, SIGNAL(returnPressed()), this, SLOT(execCmd())); connect(m_sendPb, SIGNAL(clicked()), this, SLOT(sendFile())); connect(m_aboutPb, SIGNAL(clicked()), this, SLOT(showAboutMsg())); connect(m_quitPb, SIGNAL(clicked()), this, SLOT(close())); connect(m_oldCmdsLb, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(oldCmdClicked(QListWidgetItem*))); connect(m_oldCmdsLb, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(execCmd())); connect(m_hexOutputCb, SIGNAL(toggled(bool)), this, SLOT(hexOutputClicked(bool))); connect(m_connectPb, SIGNAL(clicked()), this, SLOT(saveSettings())); connect(m_deviceCb, SIGNAL(activated(int)), this, SLOT(saveSettings())); connect(m_baudCb, SIGNAL(activated(int)), this, SLOT(saveSettings())); connect(m_dataBitsCb, SIGNAL(activated(int)), this, SLOT(saveSettings())); connect(m_parityCb, SIGNAL(activated(int)), this, SLOT(saveSettings())); connect(m_stopCb, SIGNAL(activated(int)), this, SLOT(saveSettings())); connect(m_protoPb, SIGNAL(activated(int)), this, SLOT(saveSettings())); connect(m_softwareCb, SIGNAL(clicked()), this, SLOT(saveSettings())); connect(m_hardwareCb, SIGNAL(clicked()), this, SLOT(saveSettings())); connect(m_readCb, SIGNAL(clicked()), this, SLOT(saveSettings())); connect(m_writeCb, SIGNAL(clicked()), this, SLOT(saveSettings())); 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_logAppendCb, SIGNAL(activated(int)), this, SLOT(saveSettings())); connect(m_applyCb, SIGNAL(toggled(bool)), this, SLOT(enableSettingWidgets(bool))); connect(m_logFileFileDialog, SIGNAL(clicked()), this, SLOT(chooseLogFile())); connect(&m_outputTimer, SIGNAL(timeout()), this, SLOT(doOutput())); connect(&m_keyRepeatTimer, SIGNAL(timeout()), this, SLOT(sendKey())); connect(m_enableLoggingCb, SIGNAL(toggled(bool)), this, SLOT(enableLogging(bool))); // connect(m_enableLoggingCb, SIGNAL(toggled(bool)), this, SLOT(enableLogging(bool))); m_outputView->setWordWrapMode(QTextOption::WrapAnywhere); m_outputView->document()->setMaximumBlockCount(500); // TODO ? m_outputView->setWordWrap(Q3TextEdit::WidgetWidth); /* QAccel* accel=new QAccel(this); accel->insertItem(CTRL+Key_C, 3); accel->insertItem(CTRL+Key_Q, 17); accel->insertItem(CTRL+Key_S, 19); connect(accel, SIGNAL(activated(int)), this, SLOT(sendByte(int)));*/ m_outputTimerStart.start(); readSettings(); disconnectTTY(); m_cmdLe->installEventFilter(this); } void QCPPDialogImpl::fillBaudCb() { #ifdef B0 m_baudCb->addItem("0"); #endif #ifdef B50 m_baudCb->addItem("50"); #endif #ifdef B75 m_baudCb->addItem("75"); #endif #ifdef B110 m_baudCb->addItem("110"); #endif #ifdef B134 m_baudCb->addItem("134"); #endif #ifdef B150 m_baudCb->addItem("150"); #endif #ifdef B200 m_baudCb->addItem("200"); #endif #ifdef B300 m_baudCb->addItem("300"); #endif #ifdef B600 m_baudCb->addItem("600"); #endif #ifdef B1200 m_baudCb->addItem("1200"); #endif #ifdef B1800 m_baudCb->addItem("1800"); #endif #ifdef B2400 m_baudCb->addItem("2400"); #endif #ifdef B4800 m_baudCb->addItem("4800"); #endif #ifdef B7200 m_baudCb->addItem("7200"); #endif #ifdef B9600 m_baudCb->addItem("9600"); #endif #ifdef B14400 m_baudCb->addItem("14400"); #endif #ifdef B19200 m_baudCb->addItem("19200"); #endif #ifdef B28800 m_baudCb->addItem("28800"); #endif #ifdef B38400 m_baudCb->addItem("38400"); #endif #ifdef B57600 m_baudCb->addItem("57600"); #endif #ifdef B76800 m_baudCb->addItem("76800"); #endif // this one is the default (without special reason) m_baudCb->addItem("115200"); m_baudCb->setCurrentIndex(m_baudCb->count()-1); #ifdef B128000 m_baudCb->addItem("128000"); #endif #ifdef B230400 m_baudCb->addItem("230400"); #endif #ifdef B460800 m_baudCb->addItem("460800"); #endif #ifdef B576000 m_baudCb->addItem("576000"); #endif #ifdef B921600 m_baudCb->addItem("921600"); #endif } void QCPPDialogImpl::resizeEvent(QResizeEvent *e) { QWidget::resizeEvent(e); saveSettings(); } void QCPPDialogImpl::saveSettings() { QSettings settings; settings.setValue("/cutecom/HardwareHandshake", m_hardwareCb->isChecked()); settings.setValue("/cutecom/SoftwareHandshake", m_softwareCb->isChecked()); settings.setValue("/cutecom/OpenForReading", m_readCb->isChecked()); settings.setValue("/cutecom/OpenForWriting", m_writeCb->isChecked()); settings.setValue("/cutecom/DontApplySettings", !m_applyCb->isChecked()); settings.setValue("/cutecom/Device", m_deviceCb->currentText()); settings.setValue("/cutecom/Baud", m_baudCb->currentItem()); settings.setValue("/cutecom/Databits", m_dataBitsCb->currentItem()); settings.setValue("/cutecom/Parity", m_parityCb->currentItem()); settings.setValue("/cutecom/Stopbits", m_stopCb->currentItem()); settings.setValue("/cutecom/Protocol", m_protoPb->currentItem()); settings.setValue("/cutecom/width", width()); settings.setValue("/cutecom/height", height()); settings.setValue("/cutecom/LineMode", m_inputModeCb->currentItem()); settings.setValue("/cutecom/HexOutput", m_hexOutputCb->isChecked()); settings.setValue("/cutecom/CharDelay", m_charDelaySb->value()); settings.setValue("/cutecom/SendFileDialogStartDir", m_sendFileDialogStartDir); settings.setValue("/cutecom/LogFileName", m_logFileLe->text()); settings.setValue("/cutecom/AppendToLogFile", m_logAppendCb->currentItem()); 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) { historyCount=50; } QStringList saveHist; for (unsigned int i=m_oldCmdsLb->count()-historyCount; icount(); i++) { saveHist << m_oldCmdsLb->item(i)->text(); } settings.setValue("/cutecom/History", saveHist); } void QCPPDialogImpl::readSettings() { QSettings settings; m_hardwareCb->setChecked(settings.value("/cutecom/HardwareHandshake", false).toBool()); m_softwareCb->setChecked(settings.value("/cutecom/SoftwareHandshake", false).toBool()); m_readCb->setChecked(settings.value("/cutecom/OpenForReading", true).toBool()); m_writeCb->setChecked(settings.value("/cutecom/OpenForWriting", true).toBool()); m_applyCb->setChecked(!settings.value("/cutecom/DontApplySettings", false).toBool()); enableSettingWidgets(m_applyCb->isChecked()); int defaultBaud = settings.value("/cutecom/Baud", -1).toInt(); if (defaultBaud != -1) { m_baudCb->setCurrentIndex(defaultBaud); } m_dataBitsCb->setCurrentIndex(settings.value("/cutecom/Databits", 3).toInt()); m_parityCb->setCurrentIndex(settings.value("/cutecom/Parity", 0).toInt()); m_stopCb->setCurrentIndex(settings.value("/cutecom/Stopbits", 0).toInt()); m_protoPb->setCurrentIndex(settings.value("/cutecom/Protocol", 0).toInt()); m_inputModeCb->setCurrentIndex(settings.value("/cutecom/LineMode", 0).toInt()); m_hexOutputCb->setChecked(settings.value("/cutecom/HexOutput", false).toBool()); m_charDelaySb->setValue(settings.value("/cutecom/CharDelay", 1).toInt()); m_sendFileDialogStartDir=settings.value("/cutecom/SendFileDialogStartDir", QDir::homePath()).toString(); m_logFileLe->setText(settings.value("/cutecom/LogFileName", QDir::homePath()+"/cutecom.log").toString()); m_logAppendCb->setCurrentIndex(settings.value("/cutecom/AppendToLogFile", 0).toInt()); int x=settings.value("/cutecom/width", -1).toInt(); int y=settings.value("/cutecom/height", -1).toInt(); if ((x>100) && (y>100)) { resize(x,y); } bool entryFound = settings.contains("/cutecom/AllDevices"); QStringList devices=settings.value("/cutecom/AllDevices").toStringList(); if (!entryFound) { devices<<"/dev/ttyS0"<<"/dev/ttyS1"<<"/dev/ttyS2"<<"/dev/ttyS3"; } m_deviceCb->insertItems(0, devices); int indexOfCurrentDevice = devices.indexOf(settings.value("/cutecom/CurrentDevice", "/dev/ttyS0").toString()); // fprintf(stderr, "currentDEev: -%s - index: %d\n", settings.value("/cutecom/CurrentDevice", "/dev/ttyS0").toString().toLatin1().constData(), indexOfCurrentDevice); if (indexOfCurrentDevice!=-1) { m_deviceCb->setCurrentIndex(indexOfCurrentDevice); } QStringList history=settings.value("/cutecom/History").toStringList(); if (!history.empty()) { m_oldCmdsLb->addItems(history); m_oldCmdsLb->setCurrentRow(m_oldCmdsLb->count()-1); m_oldCmdsLb->scrollToItem(m_oldCmdsLb->currentItem()); m_oldCmdsLb->clearSelection(); } } void QCPPDialogImpl::showAboutMsg() { QMessageBox::about(this, tr("About CuteCom"), tr("This is CuteCom 0.22.0
(c)2004-2009 Alexander Neundorf, <neundorf@kde.org>
Licensed under the GNU GPL v2")); } void QCPPDialogImpl::sendFile() { if (m_fileDlg==0) { m_fileDlg=new QFileDialog(); m_fileDlg->setDirectory(m_sendFileDialogStartDir); m_fileDlg->setFileMode(QFileDialog::ExistingFile); } QString filename; if ( m_fileDlg->exec() == QDialog::Accepted ) { QStringList fn = m_fileDlg->selectedFiles(); if(!fn.isEmpty()) { filename = fn[0]; } m_sendFileDialogStartDir=m_fileDlg->directory().absolutePath(); saveSettings(); } else { return; } unsigned int 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; } QTextStream stream(&file); while (!stream.atEnd()) { QString nextLine=stream.readLine(); nextLine=nextLine.left((unsigned int)nextLine.indexOf('#')); if (nextLine.isEmpty()) { continue; } if (!sendString(nextLine)) { QMessageBox::information(this, tr("Comm error"), tr("Sending failed")); return; } millisleep(charDelay*3); } } else if (m_protoPb->currentText()=="Plain") { QFile file(filename); if (!file.open(QIODevice::ReadOnly)) { QMessageBox::information(this, tr("Opening file failed"), tr("Could not open file %1").arg(filename)); return; } QByteArray data=file.readAll(); delete m_progress; m_progress=new QProgressDialog(tr("Sending file..."), tr("Cancel"), 0, 100, this); m_progress->setMinimumDuration(100); unsigned int step=data.size()/100; if (step<1) { step=1; } for (int i=0; isetValue(i/step); qApp->processEvents(); } sendByte(data.data()[i], charDelay); if ((data.data()[i]=='\n') || (data.data()[i]=='\r')) //wait twice as long after bytes which might be line ends (helps some uCs) { millisleep(charDelay); } // if (!sendByte(data.data()[i])) if (0) { QMessageBox::information(this, tr("Comm error"), tr("Sending failed (%1/%2").arg(i).arg(data.count())); break; } if ( m_progress->wasCanceled() ) { break; } } delete m_progress; m_progress=0; } else if ((m_protoPb->currentText()=="XModem") || (m_protoPb->currentText()=="YModem") || (m_protoPb->currentText()=="ZModem") || (m_protoPb->currentText()=="1kXModem")) { // QProcess sx(this); disconnectTTYRestore(false); m_sz=new Q3Process(this); m_sz->addArgument("sh"); m_sz->addArgument("-c"); // QString tmp=QString("sx -vv \"")+filename+"\" < "+m_deviceCb->currentText()+" > "+m_deviceCb->currentText(); QString tmp=QString("sz "); if (m_protoPb->currentText()=="XModem") { tmp+="--xmodem "; } else if (m_protoPb->currentText()=="YModem") { tmp+="--ymodem "; } else if (m_protoPb->currentText()=="ZModem") { tmp+="--zmodem "; } else if (m_protoPb->currentText()=="1kXModem") { tmp+="--xmodem --1k "; } tmp=tmp+"-vv \""+filename+"\" < "+m_deviceCb->currentText()+" > "+m_deviceCb->currentText(); m_sz->addArgument(tmp); m_sz->setCommunication(Q3Process::Stderr); connect(m_sz, SIGNAL(readyReadStderr()), this, SLOT(readFromStderr())); /* m_sz->addArgument("sx"); m_sz->addArgument("-vv"); m_sz->addArgument(filename); m_sz->setCommunication(QProcess::Stdin|QProcess::Stdout|QProcess::Stderr); connect(m_sz, SIGNAL(readyReadStdout()), this, SLOT(readFromStdout())); connect(m_sz, SIGNAL(readyReadStderr()), this, SLOT(readFromStderr()));*/ connect(m_sz, SIGNAL(processExited()), this, SLOT(sendDone())); if (!m_sz->start()) { QMessageBox::information(this, tr("Comm error"), tr("Could not start sx")); delete m_sz; m_sz=0; connectTTY(); return; } m_progress=new QProgressDialog(tr("Sending file via xmodem..."), tr("Cancel"), 0, 100, this); connect(m_progress, SIGNAL(cancelled()), this, SLOT(killSz())); m_progress->setMinimumDuration(100); QFileInfo fi(filename); m_progressStepSize=fi.size()/1024/100; if (m_progressStepSize<1) { m_progressStepSize=1; } // cerr<<"while(isRunning)"<setValue(0); while (m_sz->isRunning()) { qApp->processEvents(); millisleep(10); } // cerr<<"----------------- sx done"<currentText())); } } void QCPPDialogImpl::killSz() { if (m_sz==0) { return; } m_sz->tryTerminate(); } void QCPPDialogImpl::readFromStdout() { QByteArray ba=m_sz->readStdout(); // cerr<<"readFromStdout() "<0) { int bytesWritten=::write(m_fd, src, (bytesToWrite>CUTECOMM_BUFSIZE?CUTECOMM_BUFSIZE:bytesToWrite)); if (bytesWritten<0) { // cerr<<"readFromStdout() error "<readStderr(); // cerr<<"readFromStderr() "<-1) { QString captured=regex.cap(1); // cerr<<"captured kb: -"<setValue(p); } } } // else // cerr<<"--------"<type()==QEvent::KeyPress)) { if (ke->state()==Qt::NoModifier) { if (ke->key()==Qt::Key_Up) { prevCmd(); return true; } else if (ke->key()==Qt::Key_Down) { nextCmd(); return true; } } else if (ke->modifiers()==Qt::ControlModifier) { if (ke->key()==Qt::Key_C) { // std::cerr<<"c"; m_keyCode=3; sendByte(m_keyCode, 0); m_keyRepeatTimer.setSingleShot(false); m_keyRepeatTimer.start(0); return true; } else if (ke->key()==Qt::Key_Q) { // std::cerr<<"#"; m_keyCode=17; sendByte(m_keyCode, 0); return true; } else if (ke->key()==Qt::Key_S) { m_keyCode=19; sendByte(m_keyCode, 0); return true; } } } else if ((watched==m_cmdLe) && (e->type()==QEvent::KeyRelease)) { m_keyRepeatTimer.stop(); } return false; } void QCPPDialogImpl::sendKey() { // std::cerr<<"-"; sendByte(m_keyCode, 0); } void QCPPDialogImpl::oldCmdClicked(QListWidgetItem* item) { if (item==0) { return; } int index=m_oldCmdsLb->row(item); m_cmdLe->setText(item->text()); m_cmdBufIndex=m_oldCmdsLb->count()-index; m_cmdLe->setFocus(); } void QCPPDialogImpl::prevCmd() { if (m_oldCmdsLb->count()<=m_cmdBufIndex) { return; } // std::cerr<<"prevCmd() count: "<count()<<" bufIndex: "<< m_cmdBufIndex++; QListWidgetItem* item=m_oldCmdsLb->item(m_oldCmdsLb->count()-m_cmdBufIndex); if (item!=0) { m_oldCmdsLb->setCurrentItem(item); m_cmdLe->setText(item->text()); } // std::cerr<<"prev() count: "<count()<<" bufIndex: "<clear(); m_oldCmdsLb->setCurrentItem(0); // TODO ? m_oldCmdsLb->setCurrentIndex(0); } else { QListWidgetItem* it=m_oldCmdsLb->item(m_oldCmdsLb->count()-m_cmdBufIndex); m_oldCmdsLb->setCurrentItem(it); m_cmdLe->setText(it->text()); } // std::cerr<<"next() count: "<count()<<" bufIndex: "<text().trimmed(); m_cmdLe->clear(); if (!cmd.isEmpty()) { if ((m_oldCmdsLb->count()<1) || (m_oldCmdsLb->item(m_oldCmdsLb->count()-1)->text()!=cmd)) { m_oldCmdsLb->addItem(cmd); m_oldCmdsLb->setCurrentRow(m_oldCmdsLb->count()-1); if (m_oldCmdsLb->count()>50) { #if QT_VERSION >= 0x040300 m_oldCmdsLb->removeItemWidget(m_oldCmdsLb->item(0)); #else /* QT_VERSION >= 0x030000 */ m_oldCmdsLb->setItemWidget(m_oldCmdsLb->item(0), 0); #endif /* QT_VERSION >= 0x030000 */ } saveSettings(); } } m_oldCmdsLb->clearSelection(); if (m_fd==-1) { return; } sendString(cmd); /* std::cerr<<"paras: "<paragraphs()<paragraphs()>1100) { m_outputView->setUpdatesEnabled(false); m_outputView->setSelection(0, 0, 100, 0); m_outputView->removeSelectedText(); m_outputView->scrollToBottom(); m_outputView->append("abc\n"); m_outputView->setUpdatesEnabled(true); } else*/ /* m_outputView->setCursorPosition(m_outputView->paragraphs()-1, 0); static int i=0; i++; QString s=QString::number(i); s=" -"+s+"-\n "; m_outputView->insert(s);*/ /* m_outputView->insert("abc"); m_outputView->insert("def"); m_outputView->insert("ghi\n"); m_outputView->update();*/ } bool QCPPDialogImpl::sendString(const QString& s) { unsigned int lineMode=m_inputModeCb->currentIndex(); unsigned int charDelay=m_charDelaySb->value(); if (lineMode==4) // hex { QString hex=s; hex.remove(QRegExp("\\s")); if ((hex.startsWith("0x")) || (hex.startsWith("0X"))) { hex=hex.mid(2); } if (hex.length()%2 != 0) { hex="0"+hex; } for (int i=0; icurrentText(); int baudrate=m_baudCb->currentText().toInt(); int dataBits=m_dataBitsCb->currentText().toInt(); QString parity=m_parityCb->currentText(); QString stop=m_stopCb->currentText(); bool softwareHandshake=m_softwareCb->isChecked(); bool hardwareHandshake=m_hardwareCb->isChecked(); int flags=0; if (m_readCb->isChecked() && m_writeCb->isChecked()) { flags=O_RDWR; } else if (!m_readCb->isChecked() && m_writeCb->isChecked()) { flags=O_WRONLY; } else if (m_readCb->isChecked() && !m_writeCb->isChecked()) { flags=O_RDONLY; } else { QMessageBox::information(this, tr("Error"), tr("Opening the device neither for reading nor writing doesn't seem to make much sense ;-)")); return; } m_fd=open(dev.toLatin1(), flags | O_NDELAY); if (m_fd<0) { std::cerr<<"opening failed"<isChecked()) { int n = fcntl(m_fd, F_GETFL, 0); fcntl(m_fd, F_SETFL, n & ~O_NDELAY); if (tcgetattr(m_fd, &m_oldtio)!=0) { std::cerr<<"tcgetattr() 2 failed"<setEnabled(false); m_deviceCb->setEnabled(false); enableSettingWidgets(false); m_applyCb->setEnabled(false); m_readCb->setEnabled(false); m_writeCb->setEnabled(false); m_isConnected=true; if (m_readCb->isChecked()) { m_notifier=new QSocketNotifier(m_fd, QSocketNotifier::Read, this); connect(m_notifier, SIGNAL(activated(int)), this, SLOT(readData(int))); } m_oldCmdsLb->setEnabled(true); m_cmdLe->setEnabled(true); m_sendPb->setEnabled(true); m_protoPb->setEnabled(true); m_closePb->setEnabled(true); m_cmdLe->setFocus(); m_previousChar = '\0'; m_hexBytes=0; } void QCPPDialogImpl::enableSettingWidgets(bool enable) { m_baudCb->setEnabled(enable); m_dataBitsCb->setEnabled(enable); m_parityCb->setEnabled(enable); m_stopCb->setEnabled(enable); m_softwareCb->setEnabled(enable); m_hardwareCb->setEnabled(enable); } void QCPPDialogImpl::disconnectTTY() { disconnectTTYRestore(m_applyCb->isChecked()); } void QCPPDialogImpl::disconnectTTYRestore(bool restoreSettings) { m_outputTimer.stop(); m_outputBuffer=""; // std::cerr<<"closing "<setEnabled(true); m_deviceCb->setEnabled(true); if (m_applyCb->isChecked()) { enableSettingWidgets(true); } m_applyCb->setEnabled(true); m_readCb->setEnabled(true); m_writeCb->setEnabled(true); m_oldCmdsLb->setEnabled(false); m_cmdLe->setEnabled(false); m_sendPb->setEnabled(false); m_protoPb->setEnabled(false); m_closePb->setEnabled(false); m_connectPb->setFocus(); m_isConnected=false; delete m_notifier; m_notifier=0; } /** This function features some code from minicom 2.0.0, src/sysdep1.c */ void QCPPDialogImpl::setNewOptions(int baudrate, int databits, const QString& parity, const QString& stop, bool softwareHandshake, bool hardwareHandshake) { struct termios newtio; // memset(&newtio, 0, sizeof(newtio)); if (tcgetattr(m_fd, &newtio)!=0) { std::cerr<<"tcgetattr() 3 failed"<writeToStdin(ba); return; } if (m_logFile.isOpen()) { m_logFile.write(m_buf, bytesRead); } QString text; char buf[16]; for (int i=0; iisChecked()) { if ((m_hexBytes % 16) == 0) { snprintf(buf, 16, "%08x: ", m_hexBytes); text+=buf; } unsigned int b=*c; snprintf(buf, 16, "%02x ", b & 0xff); text+=buf; m_hexBytes++; if ((m_hexBytes % 16)==0) { text+="\n"; } else if ((m_hexBytes % 8)==0) { text+=" "; } } else { // also print a newline for \r, and print only one newline for \r\n if ((isprint(*c)) || (*c=='\n') || (*c=='\r')) { if (*c=='\r') { text+='\n'; } else if (*c=='\n') { if (m_previousChar != '\r') { text+='\n'; } } else { text+=(*c); } m_previousChar = *c; } else { unsigned int b=*c; snprintf(buf, 16, "\\0x%02x", b & 0xff); text+=buf; } } c++; } addOutput(text); } void QCPPDialogImpl::addOutput(const QString& text) { m_outputBuffer+=text; if (!m_outputTimer.isActive()) { doOutput(); m_outputTimerStart.restart(); m_outputTimer.setSingleShot(true); m_outputTimer.start(50); } else { if ((m_outputTimerStart.elapsed()>400) || ((m_outputTimerStart.elapsed()>200) && (m_outputBuffer.length()<100))) { doOutput(); m_outputTimerStart.restart(); } m_outputTimer.setSingleShot(true); m_outputTimer.start(50); } } void QCPPDialogImpl::doOutput() { if (m_outputBuffer.isEmpty()) { return; } m_outputView->append(m_outputBuffer); m_outputBuffer.clear(); } void QCPPDialogImpl::hexOutputClicked(bool /* on */) { addOutput("\n"); m_hexBytes=0; } void QCPPDialogImpl::clearOutput() { m_outputView->clear(); m_hexBytes=0; } void QCPPDialogImpl::enableLogging(bool on) { if (m_logFile.isOpen()==on) { return; } if (on) { m_logFile.setFileName(m_logFileLe->text()); QIODevice::OpenMode mode=QIODevice::ReadWrite; if (m_logAppendCb->currentIndex()==0) { mode=mode | QIODevice::Truncate; } else { mode=mode | QIODevice::Append; } if (!m_logFile.open(mode)) { QMessageBox::information(this, tr("Opening file failed"), tr("Could not open file %1 for writing").arg(m_logFileLe->text())); m_enableLoggingCb->setChecked(false); } else { m_logAppendCb->setEnabled(false); m_logFileLe->setEnabled(false); m_logFileFileDialog->setEnabled(false); saveSettings(); } } else { m_logFile.close(); m_logAppendCb->setEnabled(true); m_logFileLe->setEnabled(true); m_logFileFileDialog->setEnabled(true); } } void QCPPDialogImpl::chooseLogFile() { QString logFile=QFileDialog::getSaveFileName(this, tr("Save log file ..."), m_logFileLe->text()); if (!logFile.isEmpty()) { m_logFileLe->setText(logFile); } } cutecom-0.22.0/qcppdialogimpl.h0000644000175100001440000000571411220236172015264 0ustar alexusers/* Copyright (C) 2004-2005 Alexander Neundorf This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef QCPPIALOGIMPL_H #define QCPPIALOGIMPL_H #include "ui_cutecommdlg.h" #include #include #include #include #include //Added by qt3to4: #include #include #include #define CUTECOMM_BUFSIZE (4096) class QListWidgetItem; class QResizeEvent; class Q3Process; class QProgressDialog; class QFileDialog; class QCPPDialogImpl:public QWidget, public Ui::CuteCommDlg { Q_OBJECT public: QCPPDialogImpl(QWidget* parent); virtual bool eventFilter(QObject* watched, QEvent *e); protected slots: void execCmd(); void readData(int fd); void sendFile(); void showAboutMsg(); void oldCmdClicked(QListWidgetItem* item); void saveSettings(); void readFromStdout(); void readFromStderr(); void sendDone(); void connectTTY(); void disconnectTTY(); void killSz(); void enableSettingWidgets(bool enable); void doOutput(); void sendKey(); void hexOutputClicked(bool on); void enableLogging(bool on); void chooseLogFile(); void clearOutput(); protected: void fillBaudCb(); void addOutput(const QString& text); bool sendByte(char c, unsigned int delay); void disconnectTTYRestore(bool restore); void readSettings(); void prevCmd(); void nextCmd(); bool sendString(const QString& s); void setNewOptions(int baudrate, int databits, const QString& parity, const QString& stop, bool softwareHandshake, bool hardwareHandshake); virtual void resizeEvent(QResizeEvent *e); bool m_isConnected; int m_fd; struct termios m_oldtio; unsigned int m_cmdBufIndex; QSocketNotifier *m_notifier; char m_buf[CUTECOMM_BUFSIZE]; Q3Process *m_sz; QProgressDialog *m_progress; int m_progressStepSize; QFileDialog *m_fileDlg; QString m_sendFileDialogStartDir; QTimer m_outputTimer; QTime m_outputTimerStart; QString m_outputBuffer; QTimer m_keyRepeatTimer; char m_keyCode; unsigned int m_hexBytes; char m_previousChar; QFile m_logFile; }; #endif