picocom-1.7/0000775000175000017500000000000011720717024011503 5ustar npatnpatpicocom-1.7/pcxm0000664000175000017500000000012311377605660012403 0ustar npatnpat#!/bin/sh exec picocom \ --send-cmd="sx -vv" \ --receive-cmd="rx -vv" "$@" picocom-1.7/term.h0000664000175000017500000004466011377610237012643 0ustar npatnpat/* vi: set sw=4 ts=4: * * term.h * * Simple terminal management library. Wraps termios(3), and * simplifies the logistics required for the reliable management and * control of terminals. * * Principles of operation: * * After the library is initialized one or more file-descriptors, can * be added to (and latter removed from) the list managed by the * library (framework). These file descriptors must be opened on * terminal devices. For every fd, the original settings of the * associated terminal device are saved by the library. These settings * are restored when the fd is removed from the framework, or at * program termination [by means of an atexit(3) handler installed by * the library], or at user request. The library maintains three * structures for every fd in the framework: The original settings * structure ("origtermios"), keeping the settings of the terminal * device when the respective filedes was added to the framework. The * current settings structure ("currtermios"), keeping the current * settings of the associated terminal device; and the next settings * structure ("nexttermios") which keeps settings to be applied to the * associated terminal device at a latter time, upon user request. * The "term_set_*" functions can be used to modify the device * settings stored in the nexttermios structure. Using functions * provided by the library the user can: Apply the nexttermios * settings to the device. Revert all changes made on nexttermios by * copying the currtermios structure to nexttermios. Reset the device, * by configuring it to the original settings, and copying origtermios * to currtermios and nexttermios. Refresh the device by rereading the * current settings from it and updating currtermios (to catch up with * changes made to the device by means outside of this framework). * * Interface summary: * * F term_lib_init - library initialization * F term_add - add a filedes to the framework * F term_remove - remove a filedes from the framework * F term_erase - remove a filedes from the framework without reset * F term_replace - replace a fd w/o affecting the settings stuctures * F term_reset - revert a device to the settings in "origtermios" * F term_apply - configure a device to the settings in "nexttermios" * F term_revert - discard "nexttermios" by copying-over "currtermios" * F term_refresh - update "currtermios" from the device * F term_set_raw - set "nexttermios" to raw mode * F term_set_baudrate - set the baudrate in "nexttermios" * F term_set_parity - set the parity mode in "nexttermios" * F term_set_databits - set the databits in "nexttermios" * F term_set_flowcntrl - set the flowcntl mode in "nexttermios" * F term_set_hupcl - enable or disable hupcl in "nexttermios" * F term_set_local - set "nexttermios" to local or non-local mode * F term_set - set all params of "nexttermios" in a single stroke * F term_pulse_dtr - pulse the DTR line a device * F term_lower_dtr - lower the DTR line of a device * F term_raise_dtr - raise the DTR line of a device * F term_drain - drain the output from the terminal buffer * F term_flush - discard terminal input and output queue contents * F term_break - generate a break condition on a device * F term_strerror - return a string describing current error condition * F term_perror - print a string describing the current error condition * G term_errno - current error condition of the library * E term_errno_e - error condition codes * E parity_t - library supported parity types * E flocntrl_t - library supported folw-control modes * M MAX_TERM - maximum number of fds that can be managed * * by Nick Patavalis (npat@inaccessnetworks.com) * * originaly by Pantelis Antoniou (panto@intranet.gr), Nick Patavalis * * 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 * * $Id: term.h,v 1.1 2003/05/07 18:00:05 npat Exp $ */ #ifndef TERM_H #define TERM_H /* M MAX_TERMS * * Maximum nuber of terminals that can be managed by the library. Keep * relatively low, since linear searches are used. Reasonable values * would be: 16, 32, 64, etc. */ #define MAX_TERMS 16 /* * E term_errno_e * * Library error-condition codes. These marked with "see errno" * correspond to system errors, so it makes sense to also check the * system's error-condition code (errno) in order to fully determine * what went wrong. * * See the error strings in "term.c" for a description of each. */ enum term_errno_e { TERM_EOK = 0, TERM_ENOINIT, TERM_EFULL, TERM_ENOTFOUND, TERM_EEXISTS, TERM_EATEXIT, TERM_EISATTY, TERM_EFLUSH, /* see errno */ TERM_EGETATTR, /* see errno */ TERM_ESETATTR, /* see errno */ TERM_EBAUD, TERM_ESETOSPEED, TERM_ESETISPEED, TERM_EPARITY, TERM_EDATABITS, TERM_EFLOW, TERM_EDTRDOWN, TERM_EDTRUP, TERM_EDRAIN, /* see errno */ TERM_EBREAK }; /* E parity_e * * Parity modes supported by the library: * * P_NONE - no patiry * P_EVEN - even parity * P_ODD - odd parity */ enum parity_e { P_NONE, P_EVEN, P_ODD }; /* * E flowcntrl_e * * Flow control modes, supported by the library. * * FC_NONE - no flow control * FC_RTSCTS - RTS/CTS handshaking, also known as hardware * flow-control. * FC_XONXOFF - xon/xoff flow control. */ enum flowcntrl_e { FC_NONE, FC_RTSCTS, FC_XONXOFF }; /***************************************************************************/ /* * G term_errno * * Keeps the current library error-condtion code */ extern int term_errno; /***************************************************************************/ /* * F term_strerror * * Return a string descibing the current library error condition. If * the error condition reflects a system error, then the respective * system-error description is appended at the end of the returned * string. The returned string points to a statically allocated buffer * that is overwritten with every call to term_strerror() * * Returns a string describing the current library (and possibly * system) error condition. */ const char *term_strerror (int terrnum, int errnum); /* * F term_perror * * Emit a description of the current library (and possibly system) * error condition to the standard-error stream. The description is * prefixed by a user-supplied string. What is actually emmited is: * * \n * * The description emitted is the string returned by term_strerror(). * * Returns the number of characters emmited to the standard-error * stream or a neagative on failure. */ int term_perror (const char *prefix); /* F term_lib_init * * Initialize the library * * Initialize the library. This function must be called before any * attemt to use the library. If this function is called and the * library is already initialized, all terminals associated with the * file-descriptors in the framework will be reset to their original * settings, and the file-descriptors will be removed from the * framework. An atexit(3) handler is installed by the library which * resets and removes all managed terminals. * * Returns negative on failure, non-negative on success. This function * will only fail if the atexit(3) handler cannot be * installed. Failure to reset a terminal to the original settings is * not considered an error. */ int term_lib_init (void); /* F term_add * * Add the filedes "fd" to the framework. The filedes must be opened * on a terminal device or else the addition will fail. The settings * of the terminal device associated with the filedes are read and * stored in the origtermios structure. * * Returns negative on failure, non-negative on success. */ int term_add (int fd); /* F term_remove * * Remove the filedes "fd" from the framework. The device associated * with the filedes is reset to its original settings (those it had * when it was added to the framework) * * Return negative on failure, non-negative on success. The filedes is * always removed form the framework even if this function returns * failure, indicating that the device reset failed. */ int term_remove (int fd); /* F term_erase * * Remove the filedes "fd" from the framework. The device associated * with the filedes is *not* reset to its original settings. * * Return negative on failure, non-negative on success. The only * reason for failure is the filedes not to be found. */ int term_erase (int fd); /* F term_replace * * Replace a managed filedes without affecting the associated settings * structures. The "newfd" takes the place of "oldfd". "oldfd" is * removed from the framework without the associated device beign * reset (it is most-likely no longer connected to a device anyway, * and reset would fail). The device associated with "newfd" is * configured with "oldfd"s current settings. * * Returns negative on failure, non-negative on success. In case of * failure "oldfd" is not removed from the framework, and no * replacement takes place. * * The usual reason to replace the filedes of a managed terminal is * because the device was closed and re-opened. This function gives * you a way to do transparent "open"s and "close"s: Before you close * a device, it has certain settings managed by the library. When you * close it and then re-open it many of these settings are lost, since * the device reverts to system-default settings. By calling movefd, * you conceptually _maintain_ the old (pre-close) settings to the new * (post-open) filedes. */ int term_replace (int oldfd, int newfd); /* * F term_apply * * Applies the settings stored in the nexttermios structure associated * with the managed filedes "fd", to the respective terminal device. * It then copies nexttermios to currtermios. * * Returns negative on failure, non negative on success. In case of * failure the currtermios structure is not affected. */ int term_apply (int fd); /* * F term_revert * * Discards all the changes made to the nexttermios structure * associated with the managed filedes "fd" that have not been applied * to the device. It does this by copying currtermios to nexttermios. * * Returns negative on failure, non negative on success. Returns * failure only to indicate invalid arguments, so the return value can * be safely ignored. */ int term_revert (int fd); /* F term_reset * * Reset the terminal device associated with the managed filedes "fd" * to its "original" settings. This function applies the settings in * the "origtermios" structure to the actual device. It also discards * the settings in the "currtermios" and "nexttermios" stuctures by * making them equal to "origtermios". * * Returns negative on failure, non-negative of success. On failure * the the "origtermios", "currtermios", and "nexttermios" stuctures * associated with the filedes remain unaffected. */ int term_reset (int fd); /* * F term_refresh * * Updates the contents of the currtermios structure associated with * the managed filedes "fd", by reading the settings from the * respective terminal device. * * Returns negative on failure, non negative on success. On failure * the currtermios structure remains unaffected. */ int term_refresh (int fd); /* F term_set_raw * * Sets the "nexttermios" structure associated with the managed * filedes "fd" to raw mode. The effective settings of the device are * not affected by this function. * * Returns negative on failure, non-negative on success. Returns * failure only to indicate invalid arguments, so the return value can * be safely ignored. * * When in raw mode, no characters are processed by the terminal * driver and there is no line-discipline or buffering. More * technically setting to raw mode means, affecting the following * terminal settings as indicated: * * -ignbrk -brkint -parmrk -istrip -inlcr -igncr -icrnl -ixon * -opost -echo -echonl -icannon -isig -iexten -csize -parenb * cs8 min=1 time=0 */ int term_set_raw (int fd); /* F term_set_baudrate * * Sets the baudrate in the "nexttermios" structure associated with * the managed filedes "fd" to "baudrate". The effective settings of * the device are not affected by this function. * * Supported baudrates: 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, * 1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400 * * Returns negative on failure, non negative on success. Returns * failure only to indicate invalid arguments, so the return value can * be safely ignored. */ int term_set_baudrate (int fd, int baudrate); /* F term_set_parity * * Sets the parity mode in the "nexttermios" structure associated with * the managed filedes "fd" to "parity". The effective settings of the * device are not affected by this function. * * Supported parity modes are: p_even, p_odd, p_none. * * Returns negative on failure, non negative on success. Returns * failure only to indicate invalid arguments, so the return value can * be safely ignored. */ int term_set_parity (int fd, enum parity_e parity); /* F term_set_databits * * Sets the databits number in the "nexttermios" structure associated * with the managed filedes "fd" to "databits". The effective settings * of the device are not affected by this function. * * 5, 6, 7, and 8 databits are supported by the library. * * Returns negative on failure, non negative on success. Returns * failure only to indicate invalid arguments, so the return value can * be safely ignored. */ int term_set_databits (int fd, int databits); /* F term_set_flowcntrl * * Sets the folwcontrol mode in the "nexttermios" structure associated * with the managed filedes "fd" to "flowcntl". The effective settings * of the device are not affected by this function. * * The following flow control modes are supportd by the library: * FC_NONE, FC_RTSCTS, FC_XONXOFF. * * Returns negative on failure, non negative on success. Returns * failure only to indicate invalid arguments, so the return value can * be safely ignored. */ int term_set_flowcntrl (int fd, enum flowcntrl_e flowcntl); /* F term_set_hupcl * * Enables ("on" = nonzero) or disables ("on" = zero) the * "HUP-on-close" setting in the "nexttermios" structure associated * with the managed filedes "fd". The effective settings of the device * are not affected by this function. * * Returns negative on failure, non negative on success. Returns * failure only to indicate invalid arguments, so the return value can * be safely ignored. */ int term_set_hupcl (int fd, int on); /* F term_set_local. * * Enables ("local" = nonzero) or disables ("local" = zero) the * "local-mode" setting in the "nexttermios" structure associated with * the managed filedes "fd". The effective settings of the device are * not affected by this function. * * Returns negative on failure, non negative on success. Returns * failure only to indicate invalid arguments, so the return value can * be safely ignored. */ int term_set_local (int fd, int local); /* F temr_set * * Sets most of the parameters in the "nexttermios" structure * associated with the managed filedes "fd". Actually sets the * following: * * Raw mode if "raw" is nonzero. * Baudrate to "baud". * Parity mode to "parity". * Flow control mode to "fc". * Enables local mode if "local" is nonzero, dis. otherwise. * Enables HUP-on-close if "hupcl" is nonzero, dis. otherwise * * The effective settings of the device are not affected by this * function. Additionally if the filedes "fd" is not managed, it is * added to the framework. * * Returns negative on failure, non negative on success. On failure * none of the settings of "nexttermios" is affected. *If* the filedes * "fd" is already in the framework, then the function returns failure * only to indicate invalid arguments, so, in this case, the return * value can be safely ignored. If the function successfully adds the * filedes to the framework, and following this it fails, then it will * remove the filedes before returning. */ int term_set (int fd, int raw, int baud, enum parity_e parity, int bits, enum flowcntrl_e fc, int local, int hupcl); /* F term_pulse_dtr * * Pulses the DTR line of the device associated with the managed * filedes "fd". The DTR line is lowered for 1sec and then raised * again. * * Returns negative on failure, non negative on success. */ int term_pulse_dtr (int fd); /* F term_lower_dtr * * Lowers the DTR line of the device associated with the managed * filedes "fd". * * Returns negative on failure, non negative on success. */ int term_lower_dtr (int fd); /* F term_raise_dtr * * Raises the DTR line of the device associated with the managed * filedes "fd". * * Returns negative on failure, non negative on success. */ int term_raise_dtr (int fd); /* F term_drain * * Drains (flushes) the output queue of the device associated with the * managed filedes "fd". This functions blocks until all the contents * of output queue have been transmited. * * Returns negative on failure, non negative on success. */ int term_drain (int fd); /* F term_flush * * Discards all the contents of the input AND output queues of the * device associated with the managed filedes "fd". Although it is * called flush this functions does NOT FLUSHES the terminal * queues. It just DISCARDS their contents. The name has stuck from * the POSIX terminal call: "tcflush". * * Returns negative on failure, non negative on success. */ int term_flush (int fd); /* F term_break * * This function generates a break condition on the device associated * with the managed filedes "fd", by transmiting a stream of * zero-bits. The stream of zero-bits has a duriation typically * between 0.25 and 0.5 seconds. * * Returns negative on failure, non negative on success. */ int term_break(int fd); /***************************************************************************/ #endif /* of TERM_H */ /***************************************************************************/ /* * Local Variables: * mode:c * tab-width: 4 * c-basic-offset: 4 * End: */ picocom-1.7/CHANGES0000664000175000017500000001754311720717030012505 0ustar npatnpat------------------------------------------------------------------------ r29 | nick.patavalis@gmail.com | 2012-02-21 15:22:52 +0200 (Tue, 21 Feb 2012) | 3 lines Changed paths: A /tags/1.7 (from /trunk:28) Tagged release 1.7 ------------------------------------------------------------------------ r28 | nick.patavalis@gmail.com | 2012-02-21 15:19:00 +0200 (Tue, 21 Feb 2012) | 2 lines Changed paths: D /trunk/NEWS Removed historic NEWS file ------------------------------------------------------------------------ r27 | nick.patavalis@gmail.com | 2012-02-21 15:08:18 +0200 (Tue, 21 Feb 2012) | 3 lines Changed paths: M /trunk/CONTRIBUTORS Updated contributors ------------------------------------------------------------------------ r26 | nick.patavalis@gmail.com | 2012-02-21 10:53:42 +0200 (Tue, 21 Feb 2012) | 3 lines Changed paths: M /trunk/picocom.8 M /trunk/picocom.8.html M /trunk/picocom.8.ps M /trunk/picocom.8.xml Updated manual ------------------------------------------------------------------------ r25 | nick.patavalis@gmail.com | 2012-02-21 08:40:56 +0200 (Tue, 21 Feb 2012) | 3 lines Changed paths: M /trunk/picocom.c Added O_NOCTTY when opening serial port ------------------------------------------------------------------------ r24 | nick.patavalis@gmail.com | 2012-02-21 08:30:08 +0200 (Tue, 21 Feb 2012) | 4 lines Changed paths: M /trunk/picocom.c Instead of select(FD_SETSIZE...) do select(tty_fd + 1...). We know that tty_fd is the numerically largest filedes. ------------------------------------------------------------------------ r23 | nick.patavalis@gmail.com | 2012-02-21 08:24:49 +0200 (Tue, 21 Feb 2012) | 4 lines Changed paths: M /trunk/picocom.c Handle the case when read(tty_fd) or read(STI) fails with EAGAIN or EWOULDBLOCK ------------------------------------------------------------------------ r22 | nick.patavalis@gmail.com | 2012-02-21 07:42:24 +0200 (Tue, 21 Feb 2012) | 3 lines Changed paths: M /trunk/Makefile Factor-out UUCP_LOCK_DIR in Makefile for easier overriding by builder ------------------------------------------------------------------------ r21 | nick.patavalis@gmail.com | 2012-02-21 07:13:24 +0200 (Tue, 21 Feb 2012) | 3 lines Changed paths: M /trunk/picocom.c Add conditionals to allow compile with UUCP_LOCK_DIR undefined ------------------------------------------------------------------------ r20 | nick.patavalis | 2010-06-24 22:54:23 +0300 (Thu, 24 Jun 2010) | 6 lines Changed paths: M /trunk/picocom.c Corrected typo tha caused the send command to be run instead of the receive command when a filename was given. (fixes issue 5) ------------------------------------------------------------------------ r19 | nick.patavalis | 2010-06-24 22:50:18 +0300 (Thu, 24 Jun 2010) | 3 lines Changed paths: M /tags/1.6/CHANGES.old M /tags/1.6/picocom.c Reverted r18 which was mistakenly applied to the tag ------------------------------------------------------------------------ r18 | nick.patavalis | 2010-06-24 22:44:44 +0300 (Thu, 24 Jun 2010) | 6 lines Changed paths: M /tags/1.6/picocom.c Corrected a typo that caused the send command to be run instead of the receive command, if a filename was given. (fixes issue 5) ------------------------------------------------------------------------ r17 | nick.patavalis | 2010-06-13 00:10:22 +0300 (Sun, 13 Jun 2010) | 3 lines Changed paths: M /trunk/picocom.c Reverted changes to picocom.c applied, by mistake, in r16 ------------------------------------------------------------------------ r16 | nick.patavalis | 2010-06-12 23:41:01 +0300 (Sat, 12 Jun 2010) | 3 lines Changed paths: M /trunk/Makefile M /trunk/picocom.c Incremented version to 1.7 ------------------------------------------------------------------------ r15 | nick.patavalis | 2010-06-12 23:40:28 +0300 (Sat, 12 Jun 2010) | 3 lines Changed paths: A /tags/1.6 (from /trunk:14) Tagged release 1.6 ------------------------------------------------------------------------ r14 | nick.patavalis | 2010-05-29 05:47:00 +0300 (Sat, 29 May 2010) | 10 lines Changed paths: M /trunk/picocom.c Added features: - Local echo - Configurable input mapping (CR --> LF, DEL --> BS, etc) - Configurable output mapping - Configurable local-echo mapping May still need some testing... ------------------------------------------------------------------------ r13 | nick.patavalis | 2010-05-29 02:08:24 +0300 (Sat, 29 May 2010) | 2 lines Changed paths: M /trunk/picocom.8 M /trunk/picocom.8.html M /trunk/picocom.8.ps M /trunk/picocom.8.xml Fixed URL in man page ------------------------------------------------------------------------ r12 | nick.patavalis | 2010-05-29 01:41:19 +0300 (Sat, 29 May 2010) | 3 lines Changed paths: M /trunk/term.c Fixed misconception that prevented the correct setting of the odd-parity mode ------------------------------------------------------------------------ r11 | nick.patavalis | 2010-05-29 01:39:52 +0300 (Sat, 29 May 2010) | 2 lines Changed paths: M /trunk/Makefile Incremented version to 1.6 ------------------------------------------------------------------------ r10 | nick.patavalis | 2010-05-28 23:04:22 +0300 (Fri, 28 May 2010) | 2 lines Changed paths: A /tags/1.5 (from /trunk:9) Tagged 1.5 release ------------------------------------------------------------------------ r9 | nick.patavalis | 2010-05-28 04:39:32 +0300 (Fri, 28 May 2010) | 2 lines Changed paths: M /trunk/CONTRIBUTORS Updated contributors ------------------------------------------------------------------------ r8 | nick.patavalis | 2010-05-28 04:34:18 +0300 (Fri, 28 May 2010) | 5 lines Changed paths: M /trunk/picocom.c Allow non-alpha escape keys (e.g. C-]) Thanks Niels Moller ------------------------------------------------------------------------ r7 | nick.patavalis | 2010-05-28 04:12:12 +0300 (Fri, 28 May 2010) | 6 lines Changed paths: M /trunk/Makefile M /trunk/picocom.c M /trunk/term.c Enabled support for higher baudrates up to 921600. Support is compiled-in conditionally on the HIGH_BAUD macro. Thanks to Pavel Vymetalek ------------------------------------------------------------------------ r6 | nick.patavalis | 2010-05-28 03:42:57 +0300 (Fri, 28 May 2010) | 2 lines Changed paths: M /trunk/Makefile Incremented version number to 1.5 ------------------------------------------------------------------------ r5 | nick.patavalis | 2010-05-28 03:42:21 +0300 (Fri, 28 May 2010) | 2 lines Changed paths: M /trunk/picocom.c Silenced compiler warning ------------------------------------------------------------------------ r4 | nick.patavalis | 2010-05-28 03:38:55 +0300 (Fri, 28 May 2010) | 5 lines Changed paths: M /trunk/picocom.c M /trunk/term.h Changed default send_cmd to "sz -vv" (fixes issue 3) ------------------------------------------------------------------------ r3 | nick.patavalis | 2010-05-28 03:22:25 +0300 (Fri, 28 May 2010) | 2 lines Changed paths: D /trunk/CHANGES A /trunk/CHANGES.old (from /trunk/CHANGES:2) Renamed CHANGES to CHANGES.old (change log from old repository) ------------------------------------------------------------------------ r2 | nick.patavalis | 2010-05-28 03:17:52 +0300 (Fri, 28 May 2010) | 1 line Changed paths: A /trunk/CHANGES A /trunk/CONTRIBUTORS A /trunk/LICENSE.txt A /trunk/Makefile A /trunk/NEWS A /trunk/README A /trunk/TODO A /trunk/pcasc A /trunk/pcxm A /trunk/pcym A /trunk/pczm A /trunk/picocom.8 A /trunk/picocom.8.html A /trunk/picocom.8.ps A /trunk/picocom.8.xml A /trunk/picocom.c A /trunk/term.c A /trunk/term.h Imported 1.4 source ------------------------------------------------------------------------ r1 | (no author) | 2009-07-15 15:01:42 +0300 (Wed, 15 Jul 2009) | 1 line Changed paths: A /branches A /tags A /trunk Initial directory structure. ------------------------------------------------------------------------ picocom-1.7/CHANGES.old0000664000175000017500000001153311377606301013261 0ustar npatnpat------------------------------------------------------------------------ r35 | npat | 2004-08-13 14:18:38 +0300 (Fri, 13 Aug 2004) | 3 lines Changed paths: M /picocom/trunk/Makefile picocom version 1.4 ------------------------------------------------------------------------ r34 | npat | 2004-08-13 14:15:23 +0300 (Fri, 13 Aug 2004) | 4 lines Changed paths: M /picocom/trunk/Makefile Added the "changes" target that generates the CHANGES file from the svn (version control) commit logs. ------------------------------------------------------------------------ r33 | npat | 2004-08-13 05:48:26 +0300 (Fri, 13 Aug 2004) | 4 lines Changed paths: M /picocom/trunk/Makefile M /picocom/trunk/picocom.8.xml Converted the manpage sources to use the xmlmp-1.1 DTD, and hence the xmlmp tools (see http://npat.efault.net/hacks/xmlmp) ------------------------------------------------------------------------ r28 | npat | 2004-08-12 15:17:54 +0300 (Thu, 12 Aug 2004) | 2 lines Changed paths: M /picocom/trunk/TODO Removed stale tasks from TODO. (Now it's empty). ------------------------------------------------------------------------ r27 | npat | 2004-08-12 15:16:03 +0300 (Thu, 12 Aug 2004) | 5 lines Changed paths: M /picocom/trunk/CONTRIBUTORS M /picocom/trunk/picocom.8.xml Added Julius P. Malkiewicz in the contributors list Updated documentation to comply with the changes made since r13 ------------------------------------------------------------------------ r26 | npat | 2004-08-12 14:45:11 +0300 (Thu, 12 Aug 2004) | 9 lines Changed paths: M /picocom/trunk/Makefile M /picocom/trunk/picocom.c Added support for UUCP-style locks. Lock handling is compiled-in if the macro UUCP_LOCK_DIR is defined; if it is, it must contain the name of the lock directory. Locking can be disabled at runtime using the "--noock" option. UUCP-locks support is based on a patch submitted by Julius P. Malkiewicz ------------------------------------------------------------------------ r25 | npat | 2004-08-12 11:55:56 +0300 (Thu, 12 Aug 2004) | 4 lines Changed paths: M /picocom/trunk/picocom.c Implemented th C-\ command, which generates a break sequence. Patch submitted by Julius P. Malkiewicz ------------------------------------------------------------------------ r24 | npat | 2004-08-12 11:52:39 +0300 (Thu, 12 Aug 2004) | 5 lines Changed paths: M /picocom/trunk/picocom.c If two escape-characters are sent in a row, the second is passed-through, and picocom returns to transparrent mode. Patch submitteb by Julius P. Malkiewicz ------------------------------------------------------------------------ r23 | npat | 2004-08-12 11:45:57 +0300 (Thu, 12 Aug 2004) | 7 lines Changed paths: M /picocom/trunk/term.c Fixed "term.c" to compile under FreeBSD (and probably other BSDs also). "term.c" now includes "termios.h" instead of "termio.h" in non-linux system. Added a declaration for "tioold"---that was missing---in the non-linux part of the DTR toggling code. Patch submitted by Julius P. Malkiewicz ------------------------------------------------------------------------ r12 | npat | 2004-08-11 19:03:48 +0300 (Wed, 11 Aug 2004) | 2 lines Changed paths: M /picocom/trunk/CONTRIBUTORS M /picocom/trunk/Makefile M /picocom/trunk/README A /picocom/trunk/picocom.8.xml Added r1.3 ------------------------------------------------------------------------ r10 | npat | 2004-08-11 19:02:35 +0300 (Wed, 11 Aug 2004) | 3 lines Changed paths: A /picocom/trunk/CONTRIBUTORS M /picocom/trunk/Makefile A /picocom/trunk/TODO M /picocom/trunk/picocom.c Added r1.2 ------------------------------------------------------------------------ r8 | npat | 2004-08-11 19:01:25 +0300 (Wed, 11 Aug 2004) | 2 lines Changed paths: M /picocom/trunk/Makefile A /picocom/trunk/NEWS M /picocom/trunk/README A /picocom/trunk/pcasc A /picocom/trunk/pcxm A /picocom/trunk/pcym A /picocom/trunk/pczm M /picocom/trunk/picocom.c Added r1.1 ------------------------------------------------------------------------ r6 | npat | 2004-08-11 18:59:25 +0300 (Wed, 11 Aug 2004) | 2 lines Changed paths: A /picocom/trunk/LICENSE.txt A /picocom/trunk/Makefile A /picocom/trunk/README A /picocom/trunk/picocom.c A /picocom/trunk/term.c A /picocom/trunk/term.h Imported r1.0 sources ------------------------------------------------------------------------ r1 | svn | 2004-08-11 08:02:59 +0300 (Wed, 11 Aug 2004) | 2 lines Changed paths: A /mu0 A /mu0/branches A /mu0/tags A /mu0/trunk A /picocom A /picocom/branches A /picocom/tags A /picocom/trunk A /ppgplot A /ppgplot/branches A /ppgplot/tags A /ppgplot/trunk Imported initial projects directory structure. ------------------------------------------------------------------------ picocom-1.7/TODO0000664000175000017500000000000111377605660012174 0ustar npatnpat picocom-1.7/CONTRIBUTORS0000664000175000017500000000157111720713502013364 0ustar npatnpat The following people contributed suggestions, comments, and fixes: - Oliver Kurth (oku@debian.org) contributed bug fixes and the manual page for picocm. - Julius P. Malkiewicz (julius@sonartech.com.au) contributed FreeBSD portablity fixes, the C-\ command implementation, the UUCP locks implementation, and other minor fixes. - Pavel Vymetalek (pvymetalek@seznam.cz) contributed the higher baudrates support. - Niels Moller (nisse@lysator.liu.se) contributed support for non-alphabetic escape keys. - (lwithers@gmail.com) contributed fixes to select(2) and read(2) error handling. - (bob.dunlop@xyzzy.org.uk) suggested fix to prevent serial port form becoming controlling terminal. - Edgar Johansen (edgar@storteig.com) suggested conditionals to enable compilation without UUCP_LOCK_DIR - Scott Tsai (scott.tw@gmail.com) suggested better UUCP_LOCK_DIR definition picocom-1.7/pcym0000664000175000017500000000012411377605660012405 0ustar npatnpat#!/bin/sh exec picocom \ --send-cmd="sb -vv" \ --receive-cmd="rb -vvv" "$@" picocom-1.7/picocom.c0000664000175000017500000006647711720636170013326 0ustar npatnpat/* vi: set sw=4 ts=4: * * picocom.c * * simple dumb-terminal program. Helps you manually configure and test * stuff like modems, devices w. serial ports etc. * * by Nick Patavalis (npat@efault.net) * * 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 #include #include #include #include #include #include #include #include #include #include #include #include #define _GNU_SOURCE #include #include "term.h" /**********************************************************************/ #define KEY_EXIT '\x18' /* C-x: exit picocom */ #define KEY_QUIT '\x11' /* C-q: exit picocom without reseting port */ #define KEY_PULSE '\x10' /* C-p: pulse DTR */ #define KEY_TOGGLE '\x14' /* C-t: toggle DTR */ #define KEY_BAUD_UP '\x15' /* C-u: increase baudrate (up) */ #define KEY_BAUD_DN '\x04' /* C-d: decrase baudrate (down) */ #define KEY_FLOW '\x06' /* C-f: change flowcntrl mode */ #define KEY_PARITY '\x19' /* C-y: change parity mode */ #define KEY_BITS '\x02' /* C-b: change number of databits */ #define KEY_LECHO '\x03' /* C-c: toggle local echo */ #define KEY_STATUS '\x16' /* C-v: show program option */ #define KEY_SEND '\x13' /* C-s: send file */ #define KEY_RECEIVE '\x12' /* C-r: receive file */ #define KEY_BREAK '\x1c' /* C-\: break */ #define STO STDOUT_FILENO #define STI STDIN_FILENO /**********************************************************************/ /* implemented caracter mappings */ #define M_CRLF (1 << 0) /* map CR --> LF */ #define M_CRCRLF (1 << 1) /* map CR --> CR + LF */ #define M_IGNCR (1 << 2) /* map CR --> */ #define M_LFCR (1 << 3) /* map LF --> CR */ #define M_LFCRLF (1 << 4) /* map LF --> CR + LF */ #define M_IGNLF (1 << 5) /* map LF --> */ #define M_DELBS (1 << 6) /* map DEL --> BS */ #define M_BSDEL (1 << 7) /* map BS --> DEL */ #define M_NFLAGS 8 /* default character mappings */ #define M_I_DFL 0 #define M_O_DFL 0 #define M_E_DFL (M_DELBS | M_CRCRLF) /* character mapping names */ struct map_names_s { char *name; int flag; } map_names[] = { { "crlf", M_CRLF }, { "crcrlf", M_CRCRLF }, { "igncr", M_IGNCR }, { "lfcr", M_LFCR }, { "lfcrlf", M_LFCRLF }, { "ignlf", M_IGNLF }, { "delbs", M_DELBS }, { "bsdel", M_BSDEL }, /* Sentinel */ { NULL, 0 } }; int parse_map (char *s) { char *m, *t; int f, flags, i; flags = 0; while ( (t = strtok(s, ", \t")) ) { for (i=0; (m = map_names[i].name); i++) { if ( ! strcmp(t, m) ) { f = map_names[i].flag; break; } } if ( m ) flags |= f; else { flags = -1; break; } s = NULL; } return flags; } void print_map (int flags) { int i; for (i = 0; i < M_NFLAGS; i++) if ( flags & (1 << i) ) printf("%s,", map_names[i].name); printf("\n"); } /**********************************************************************/ struct { char port[128]; int baud; enum flowcntrl_e flow; char *flow_str; enum parity_e parity; char *parity_str; int databits; int lecho; int noinit; int noreset; #ifdef UUCP_LOCK_DIR int nolock; #endif unsigned char escape; char send_cmd[128]; char receive_cmd[128]; int imap; int omap; int emap; } opts = { .port = "", .baud = 9600, .flow = FC_NONE, .flow_str = "none", .parity = P_NONE, .parity_str = "none", .databits = 8, .lecho = 0, .noinit = 0, .noreset = 0, #ifdef UUCP_LOCK_DIR .nolock = 0, #endif .escape = '\x01', .send_cmd = "sz -vv", .receive_cmd = "rz -vv", .imap = M_I_DFL, .omap = M_O_DFL, .emap = M_E_DFL }; int tty_fd; /**********************************************************************/ #ifdef UUCP_LOCK_DIR /* use HDB UUCP locks .. see * for details */ char lockname[_POSIX_PATH_MAX] = ""; int uucp_lockname(const char *dir, const char *file) { char *p, *cp; struct stat sb; if ( ! dir || *dir == '\0' || stat(dir, &sb) != 0 ) return -1; /* cut-off initial "/dev/" from file-name */ p = strchr(file + 1, '/'); p = p ? p + 1 : (char *)file; /* replace '/'s with '_'s in what remains (after making a copy) */ p = cp = strdup(p); do { if ( *p == '/' ) *p = '_'; } while(*p++); /* build lockname */ snprintf(lockname, sizeof(lockname), "%s/LCK..%s", dir, cp); /* destroy the copy */ free(cp); return 0; } int uucp_lock(void) { int r, fd, pid; char buf[16]; mode_t m; if ( lockname[0] == '\0' ) return 0; fd = open(lockname, O_RDONLY); if ( fd >= 0 ) { r = read(fd, buf, sizeof(buf)); close(fd); /* if r == 4, lock file is binary (old-style) */ pid = (r == 4) ? *(int *)buf : strtol(buf, NULL, 10); if ( pid > 0 && kill((pid_t)pid, 0) < 0 && errno == ESRCH ) { /* stale lock file */ printf("Removing stale lock: %s\n", lockname); sleep(1); unlink(lockname); } else { lockname[0] = '\0'; errno = EEXIST; return -1; } } /* lock it */ m = umask(022); fd = open(lockname, O_WRONLY|O_CREAT|O_EXCL, 0666); if ( fd < 0 ) { lockname[0] = '\0'; return -1; } umask(m); snprintf(buf, sizeof(buf), "%04d\n", getpid()); write(fd, buf, strlen(buf)); close(fd); return 0; } int uucp_unlock(void) { if ( lockname[0] ) unlink(lockname); return 0; } #endif /* of UUCP_LOCK_DIR */ /**********************************************************************/ ssize_t writen_ni(int fd, const void *buff, size_t n) { size_t nl; ssize_t nw; const char *p; p = buff; nl = n; while (nl > 0) { do { nw = write(fd, p, nl); } while ( nw < 0 && errno == EINTR ); if ( nw <= 0 ) break; nl -= nw; p += nw; } return n - nl; } int fd_printf (int fd, const char *format, ...) { char buf[256]; va_list args; int len; va_start(args, format); len = vsnprintf(buf, sizeof(buf), format, args); buf[sizeof(buf) - 1] = '\0'; va_end(args); return writen_ni(fd, buf, len); } void fatal (const char *format, ...) { char *s, buf[256]; va_list args; int len; term_reset(STO); term_reset(STI); va_start(args, format); len = vsnprintf(buf, sizeof(buf), format, args); buf[sizeof(buf) - 1] = '\0'; va_end(args); s = "\r\nFATAL: "; writen_ni(STO, s, strlen(s)); writen_ni(STO, buf, len); s = "\r\n"; writen_ni(STO, s, strlen(s)); /* wait a bit for output to drain */ sleep(1); #ifdef UUCP_LOCK_DIR uucp_unlock(); #endif exit(EXIT_FAILURE); } #define cput(fd, c) do { int cl = c; write((fd), &(cl), 1); } while(0) int fd_readline (int fdi, int fdo, char *b, int bsz) { int r; unsigned char c; unsigned char *bp, *bpe; bp = (unsigned char *)b; bpe = (unsigned char *)b + bsz - 1; while (1) { r = read(fdi, &c, 1); if ( r <= 0 ) { r--; goto out; } switch (c) { case '\b': if ( bp > (unsigned char *)b ) { bp--; cput(fdo, c); cput(fdo, ' '); cput(fdo, c); } else { cput(fdo, '\x07'); } break; case '\r': *bp = '\0'; r = bp - (unsigned char *)b; goto out; default: if ( bp < bpe ) { *bp++ = c; cput(fdo, c); } else { cput(fdo, '\x07'); } break; } } out: return r; } #undef cput /* maximum number of chars that can replace a single characted due to mapping */ #define M_MAXMAP 4 int do_map (char *b, int map, char c) { int n; switch (c) { case '\x7f': /* DEL mapings */ if ( map & M_DELBS ) { b[0] = '\x08'; n = 1; } else { b[0] = c; n = 1; } break; case '\x08': /* BS mapings */ if ( map & M_BSDEL ) { b[0] = '\x7f'; n = 1; } else { b[0] = c; n = 1; } break; case '\x0d': /* CR mappings */ if ( map & M_CRLF ) { b[0] = '\x0a'; n = 1; } else if ( map & M_CRCRLF ) { b[0] = '\x0d'; b[1] = '\x0a'; n = 2; } else if ( map & M_IGNCR ) { n = 0; } else { b[0] = c; n = 1; } break; case '\x0a': /* LF mappings */ if ( map & M_LFCR ) { b[0] = '\x0d'; n = 1; } else if ( map & M_LFCRLF ) { b[0] = '\x0d'; b[1] = '\x0a'; n = 2; } else if ( map & M_IGNLF ) { n = 0; } else { b[0] = c; n = 1; } break; default: b[0] = c; n = 1; break; } return n; } void map_and_write (int fd, int map, char c) { char b[M_MAXMAP]; int n; n = do_map(b, map, c); if ( n ) if ( writen_ni(fd, b, n) < n ) fatal("write to stdout failed: %s", strerror(errno)); } /**********************************************************************/ int baud_up (int baud) { if ( baud < 300 ) baud = 300; else if ( baud == 38400 ) baud = 57600; else baud = baud * 2; #ifndef HIGH_BAUD if ( baud > 115200 ) baud = 115200; #else if ( baud > 921600 ) baud = 921600; #endif return baud; } int baud_down (int baud) { #ifndef HIGH_BAUD if ( baud > 115200 ) baud = 115200; #else if ( baud > 921600 ) baud = 921600; #endif else if ( baud == 57600 ) baud = 38400; else baud = baud / 2; if ( baud < 300) baud = 300; return baud; } int flow_next (int flow, char **flow_str) { switch(flow) { case FC_NONE: flow = FC_RTSCTS; *flow_str = "RTS/CTS"; break; case FC_RTSCTS: flow = FC_XONXOFF; *flow_str = "xon/xoff"; break; case FC_XONXOFF: flow = FC_NONE; *flow_str = "none"; break; default: flow = FC_NONE; *flow_str = "none"; break; } return flow; } int parity_next (int parity, char **parity_str) { switch(parity) { case P_NONE: parity = P_EVEN; *parity_str = "even"; break; case P_EVEN: parity = P_ODD; *parity_str = "odd"; break; case P_ODD: parity = P_NONE; *parity_str = "none"; break; default: parity = P_NONE; *parity_str = "none"; break; } return parity; } int bits_next (int bits) { bits++; if (bits > 8) bits = 5; return bits; } /**********************************************************************/ void child_empty_handler (int signum) { } void establish_child_signal_handlers (void) { struct sigaction empty_action; /* Set up the structure to specify the "empty" action. */ empty_action.sa_handler = child_empty_handler; sigemptyset (&empty_action.sa_mask); empty_action.sa_flags = 0; sigaction (SIGINT, &empty_action, NULL); sigaction (SIGTERM, &empty_action, NULL); } int run_cmd(int fd, ...) { pid_t pid; sigset_t sigm, sigm_old; /* block signals, let child establish its own handlers */ sigemptyset(&sigm); sigaddset(&sigm, SIGTERM); sigprocmask(SIG_BLOCK, &sigm, &sigm_old); pid = fork(); if ( pid < 0 ) { sigprocmask(SIG_SETMASK, &sigm_old, NULL); fd_printf(STO, "*** cannot fork: %s\n", strerror(errno)); return -1; } else if ( pid ) { /* father: picocom */ int r; /* reset the mask */ sigprocmask(SIG_SETMASK, &sigm_old, NULL); /* wait for child to finish */ waitpid(pid, &r, 0); /* reset terminal (back to raw mode) */ term_apply(STI); /* check and report child return status */ if ( WIFEXITED(r) ) { fd_printf(STO, "\r\n*** exit status: %d\r\n", WEXITSTATUS(r)); return WEXITSTATUS(r); } else { fd_printf(STO, "\r\n*** abnormal termination: 0x%x\r\n", r); return -1; } } else { /* child: external program */ int r; long fl; char cmd[512]; establish_child_signal_handlers(); sigprocmask(SIG_SETMASK, &sigm_old, NULL); /* unmanage terminal, and reset it to canonical mode */ term_remove(STI); /* unmanage serial port fd, without reset */ term_erase(fd); /* set serial port fd to blocking mode */ fl = fcntl(fd, F_GETFL); fl &= ~O_NONBLOCK; fcntl(fd, F_SETFL, fl); /* connect stdin and stdout to serial port */ close(STI); close(STO); dup2(fd, STI); dup2(fd, STO); { /* build command-line */ char *c, *ce; const char *s; int n; va_list vls; c = cmd; ce = cmd + sizeof(cmd) - 1; va_start(vls, fd); while ( (s = va_arg(vls, const char *)) ) { n = strlen(s); if ( c + n + 1 >= ce ) break; memcpy(c, s, n); c += n; *c++ = ' '; } va_end(vls); *c = '\0'; } /* run extenral command */ fd_printf(STDERR_FILENO, "%s\n", cmd); r = system(cmd); if ( WIFEXITED(r) ) exit(WEXITSTATUS(r)); else exit(128); } } /**********************************************************************/ #define TTY_Q_SZ 256 struct tty_q { int len; unsigned char buff[TTY_Q_SZ]; } tty_q; /**********************************************************************/ void loop(void) { enum { ST_COMMAND, ST_TRANSPARENT } state; int dtr_up; fd_set rdset, wrset; int newbaud, newflow, newparity, newbits; char *newflow_str, *newparity_str; char fname[128]; int r, n; unsigned char c; tty_q.len = 0; state = ST_TRANSPARENT; dtr_up = 0; for (;;) { FD_ZERO(&rdset); FD_ZERO(&wrset); FD_SET(STI, &rdset); FD_SET(tty_fd, &rdset); if ( tty_q.len ) FD_SET(tty_fd, &wrset); if (select(tty_fd + 1, &rdset, &wrset, NULL, NULL) < 0) fatal("select failed: %d : %s", errno, strerror(errno)); if ( FD_ISSET(STI, &rdset) ) { /* read from terminal */ do { n = read(STI, &c, 1); } while (n < 0 && errno == EINTR); if (n == 0) { fatal("stdin closed"); } else if (n < 0) { /* is this really necessary? better safe than sory! */ if ( errno != EAGAIN && errno != EWOULDBLOCK ) fatal("read from stdin failed: %s", strerror(errno)); else goto skip_proc_STI; } switch (state) { case ST_COMMAND: if ( c == opts.escape ) { state = ST_TRANSPARENT; /* pass the escape character down */ if (tty_q.len + M_MAXMAP <= TTY_Q_SZ) { n = do_map((char *)tty_q.buff + tty_q.len, opts.omap, c); tty_q.len += n; if ( opts.lecho ) map_and_write(STO, opts.emap, c); } else fd_printf(STO, "\x07"); break; } state = ST_TRANSPARENT; switch (c) { case KEY_EXIT: return; case KEY_QUIT: term_set_hupcl(tty_fd, 0); term_flush(tty_fd); term_apply(tty_fd); term_erase(tty_fd); return; case KEY_STATUS: fd_printf(STO, "\r\n"); fd_printf(STO, "*** baud: %d\r\n", opts.baud); fd_printf(STO, "*** flow: %s\r\n", opts.flow_str); fd_printf(STO, "*** parity: %s\r\n", opts.parity_str); fd_printf(STO, "*** databits: %d\r\n", opts.databits); fd_printf(STO, "*** dtr: %s\r\n", dtr_up ? "up" : "down"); break; case KEY_PULSE: fd_printf(STO, "\r\n*** pulse DTR ***\r\n"); if ( term_pulse_dtr(tty_fd) < 0 ) fd_printf(STO, "*** FAILED\r\n"); break; case KEY_TOGGLE: if ( dtr_up ) r = term_lower_dtr(tty_fd); else r = term_raise_dtr(tty_fd); if ( r >= 0 ) dtr_up = ! dtr_up; fd_printf(STO, "\r\n*** DTR: %s ***\r\n", dtr_up ? "up" : "down"); break; case KEY_BAUD_UP: newbaud = baud_up(opts.baud); term_set_baudrate(tty_fd, newbaud); tty_q.len = 0; term_flush(tty_fd); if ( term_apply(tty_fd) >= 0 ) opts.baud = newbaud; fd_printf(STO, "\r\n*** baud: %d ***\r\n", opts.baud); break; case KEY_BAUD_DN: newbaud = baud_down(opts.baud); term_set_baudrate(tty_fd, newbaud); tty_q.len = 0; term_flush(tty_fd); if ( term_apply(tty_fd) >= 0 ) opts.baud = newbaud; fd_printf(STO, "\r\n*** baud: %d ***\r\n", opts.baud); break; case KEY_FLOW: newflow = flow_next(opts.flow, &newflow_str); term_set_flowcntrl(tty_fd, newflow); tty_q.len = 0; term_flush(tty_fd); if ( term_apply(tty_fd) >= 0 ) { opts.flow = newflow; opts.flow_str = newflow_str; } fd_printf(STO, "\r\n*** flow: %s ***\r\n", opts.flow_str); break; case KEY_PARITY: newparity = parity_next(opts.parity, &newparity_str); term_set_parity(tty_fd, newparity); tty_q.len = 0; term_flush(tty_fd); if ( term_apply(tty_fd) >= 0 ) { opts.parity = newparity; opts.parity_str = newparity_str; } fd_printf(STO, "\r\n*** parity: %s ***\r\n", opts.parity_str); break; case KEY_BITS: newbits = bits_next(opts.databits); term_set_databits(tty_fd, newbits); tty_q.len = 0; term_flush(tty_fd); if ( term_apply(tty_fd) >= 0 ) opts.databits = newbits; fd_printf(STO, "\r\n*** databits: %d ***\r\n", opts.databits); break; case KEY_LECHO: opts.lecho = ! opts.lecho; fd_printf(STO, "\r\n*** local echo: %s ***\r\n", opts.lecho ? "yes" : "no"); break; case KEY_SEND: fd_printf(STO, "\r\n*** file: "); r = fd_readline(STI, STO, fname, sizeof(fname)); fd_printf(STO, "\r\n"); if ( r < -1 && errno == EINTR ) break; if ( r <= -1 ) fatal("cannot read filename: %s", strerror(errno)); run_cmd(tty_fd, opts.send_cmd, fname, NULL); break; case KEY_RECEIVE: fd_printf(STO, "*** file: "); r = fd_readline(STI, STO, fname, sizeof(fname)); fd_printf(STO, "\r\n"); if ( r < -1 && errno == EINTR ) break; if ( r <= -1 ) fatal("cannot read filename: %s", strerror(errno)); if ( fname[0] ) run_cmd(tty_fd, opts.receive_cmd, fname, NULL); else run_cmd(tty_fd, opts.receive_cmd, NULL); break; case KEY_BREAK: term_break(tty_fd); fd_printf(STO, "\r\n*** break sent ***\r\n"); break; default: break; } break; case ST_TRANSPARENT: if ( c == opts.escape ) { state = ST_COMMAND; } else { if (tty_q.len + M_MAXMAP <= TTY_Q_SZ) { n = do_map((char *)tty_q.buff + tty_q.len, opts.omap, c); tty_q.len += n; if ( opts.lecho ) map_and_write(STO, opts.emap, c); } else fd_printf(STO, "\x07"); } break; default: assert(0); break; } } skip_proc_STI: if ( FD_ISSET(tty_fd, &rdset) ) { /* read from port */ do { n = read(tty_fd, &c, 1); } while (n < 0 && errno == EINTR); if (n == 0) { fatal("term closed"); } else if ( n < 0 ) { if ( errno != EAGAIN && errno != EWOULDBLOCK ) fatal("read from term failed: %s", strerror(errno)); } else { map_and_write(STO, opts.imap, c); } } if ( FD_ISSET(tty_fd, &wrset) ) { /* write to port */ do { n = write(tty_fd, tty_q.buff, tty_q.len); } while ( n < 0 && errno == EINTR ); if ( n <= 0 ) fatal("write to term failed: %s", strerror(errno)); memcpy(tty_q.buff, tty_q.buff + n, tty_q.len - n); tty_q.len -= n; } } } /**********************************************************************/ void deadly_handler(int signum) { kill(0, SIGTERM); sleep(1); #ifdef UUCP_LOCK_DIR uucp_unlock(); #endif exit(EXIT_FAILURE); } void establish_signal_handlers (void) { struct sigaction exit_action, ign_action; /* Set up the structure to specify the exit action. */ exit_action.sa_handler = deadly_handler; sigemptyset (&exit_action.sa_mask); exit_action.sa_flags = 0; /* Set up the structure to specify the ignore action. */ ign_action.sa_handler = SIG_IGN; sigemptyset (&ign_action.sa_mask); ign_action.sa_flags = 0; sigaction (SIGTERM, &exit_action, NULL); sigaction (SIGINT, &ign_action, NULL); sigaction (SIGHUP, &ign_action, NULL); sigaction (SIGALRM, &ign_action, NULL); sigaction (SIGUSR1, &ign_action, NULL); sigaction (SIGUSR2, &ign_action, NULL); sigaction (SIGPIPE, &ign_action, NULL); } /**********************************************************************/ void show_usage(char *name) { char *s; s = strrchr(name, '/'); s = s ? s+1 : name; printf("picocom v%s\n", VERSION_STR); printf("Usage is: %s [options] \n", s); printf("Options are:\n"); printf(" --aud \n"); printf(" --low s (=soft) | h (=hard) | n (=none)\n"); printf(" --

arity o (=odd) | e (=even) | n (=none)\n"); printf(" --atabits 5 | 6 | 7 | 8\n"); printf(" --scape \n"); printf(" --eho\n"); printf(" --nonit\n"); printf(" --noeset\n"); printf(" --noock\n"); printf(" --end-cmd \n"); printf(" --receie-cmd \n"); printf(" --imap (input mappings)\n"); printf(" --omap (output mappings)\n"); printf(" --emap (local-echo mappings)\n"); printf(" --elp\n"); printf(" is a comma-separated list of one or more of:\n"); printf(" crlf : map CR --> LF\n"); printf(" crcrlf : map CR --> CR + LF\n"); printf(" igncr : ignore CR\n"); printf(" lfcr : map LF --> CR\n"); printf(" lfcrlf : map LF --> CR + LF\n"); printf(" ignlf : ignore LF\n"); printf(" bsdel : map BS --> DEL\n"); printf(" delbs : map DEL --> BS\n"); printf(" indicates the equivalent short option.\n"); printf("Short options are prefixed by \"-\" instead of by \"--\".\n"); } /**********************************************************************/ void parse_args(int argc, char *argv[]) { static struct option longOptions[] = { {"receive-cmd", required_argument, 0, 'v'}, {"send-cmd", required_argument, 0, 's'}, {"imap", required_argument, 0, 'I' }, {"omap", required_argument, 0, 'O' }, {"emap", required_argument, 0, 'E' }, {"escape", required_argument, 0, 'e'}, {"echo", no_argument, 0, 'c'}, {"noinit", no_argument, 0, 'i'}, {"noreset", no_argument, 0, 'r'}, {"nolock", no_argument, 0, 'l'}, {"flow", required_argument, 0, 'f'}, {"baud", required_argument, 0, 'b'}, {"parity", required_argument, 0, 'p'}, {"databits", required_argument, 0, 'd'}, {"help", no_argument, 0, 'h'}, {0, 0, 0, 0} }; while (1) { int optionIndex = 0; int c; int map; /* no default error messages printed. */ opterr = 0; c = getopt_long(argc, argv, "hirlcv:s:r:e:f:b:p:d:", longOptions, &optionIndex); if (c < 0) break; switch (c) { case 's': strncpy(opts.send_cmd, optarg, sizeof(opts.send_cmd)); opts.send_cmd[sizeof(opts.send_cmd) - 1] = '\0'; break; case 'v': strncpy(opts.receive_cmd, optarg, sizeof(opts.receive_cmd)); opts.receive_cmd[sizeof(opts.receive_cmd) - 1] = '\0'; break; case 'I': map = parse_map(optarg); if (map >= 0) opts.imap = map; else fprintf(stderr, "Invalid imap, ignored\n"); break; case 'O': map = parse_map(optarg); if (map >= 0) opts.omap = map; else fprintf(stderr, "Invalid omap, ignored\n"); break; case 'E': map = parse_map(optarg); if (map >= 0) opts.emap = map; else fprintf(stderr, "Invalid emap, ignored\n"); break; case 'c': opts.lecho = 1; break; case 'i': opts.noinit = 1; break; case 'r': opts.noreset = 1; break; case 'l': #ifdef UUCP_LOCK_DIR opts.nolock = 1; #endif break; case 'e': opts.escape = optarg[0] & 0x1f; break; case 'f': switch (optarg[0]) { case 'X': case 'x': opts.flow_str = "xon/xoff"; opts.flow = FC_XONXOFF; break; case 'H': case 'h': opts.flow_str = "RTS/CTS"; opts.flow = FC_RTSCTS; break; case 'N': case 'n': opts.flow_str = "none"; opts.flow = FC_NONE; break; default: fprintf(stderr, "--flow '%c' ignored.\n", optarg[0]); fprintf(stderr, "--flow can be one off: 'x', 'h', or 'n'\n"); break; } break; case 'b': opts.baud = atoi(optarg); break; case 'p': switch (optarg[0]) { case 'e': opts.parity_str = "even"; opts.parity = P_EVEN; break; case 'o': opts.parity_str = "odd"; opts.parity = P_ODD; break; case 'n': opts.parity_str = "none"; opts.parity = P_NONE; break; default: fprintf(stderr, "--parity '%c' ignored.\n", optarg[0]); fprintf(stderr, "--parity can be one off: 'o', 'e', or 'n'\n"); break; } break; case 'd': switch (optarg[0]) { case '5': opts.databits = 5; break; case '6': opts.databits = 6; break; case '7': opts.databits = 7; break; case '8': opts.databits = 8; break; default: fprintf(stderr, "--databits '%c' ignored.\n", optarg[0]); fprintf(stderr, "--databits can be one off: 5, 6, 7 or 8\n"); break; } break; case 'h': show_usage(argv[0]); exit(EXIT_SUCCESS); case '?': default: fprintf(stderr, "Unrecognized option.\n"); fprintf(stderr, "Run with '--help'.\n"); exit(EXIT_FAILURE); } } /* while */ if ( (argc - optind) < 1) { fprintf(stderr, "No port given\n"); exit(EXIT_FAILURE); } strncpy(opts.port, argv[optind], sizeof(opts.port) - 1); opts.port[sizeof(opts.port) - 1] = '\0'; printf("picocom v%s\n", VERSION_STR); printf("\n"); printf("port is : %s\n", opts.port); printf("flowcontrol : %s\n", opts.flow_str); printf("baudrate is : %d\n", opts.baud); printf("parity is : %s\n", opts.parity_str); printf("databits are : %d\n", opts.databits); printf("escape is : C-%c\n", 'a' + opts.escape - 1); printf("local echo is : %s\n", opts.lecho ? "yes" : "no"); printf("noinit is : %s\n", opts.noinit ? "yes" : "no"); printf("noreset is : %s\n", opts.noreset ? "yes" : "no"); #ifdef UUCP_LOCK_DIR printf("nolock is : %s\n", opts.nolock ? "yes" : "no"); #endif printf("send_cmd is : %s\n", opts.send_cmd); printf("receive_cmd is : %s\n", opts.receive_cmd); printf("imap is : "); print_map(opts.imap); printf("omap is : "); print_map(opts.omap); printf("emap is : "); print_map(opts.emap); printf("\n"); } /**********************************************************************/ int main(int argc, char *argv[]) { int r; parse_args(argc, argv); establish_signal_handlers(); r = term_lib_init(); if ( r < 0 ) fatal("term_init failed: %s", term_strerror(term_errno, errno)); #ifdef UUCP_LOCK_DIR if ( ! opts.nolock ) uucp_lockname(UUCP_LOCK_DIR, opts.port); if ( uucp_lock() < 0 ) fatal("cannot lock %s: %s", opts.port, strerror(errno)); #endif tty_fd = open(opts.port, O_RDWR | O_NONBLOCK | O_NOCTTY); if (tty_fd < 0) fatal("cannot open %s: %s", opts.port, strerror(errno)); if ( opts.noinit ) { r = term_add(tty_fd); } else { r = term_set(tty_fd, 1, /* raw mode. */ opts.baud, /* baud rate. */ opts.parity, /* parity. */ opts.databits, /* data bits. */ opts.flow, /* flow control. */ 1, /* local or modem */ !opts.noreset); /* hup-on-close. */ } if ( r < 0 ) fatal("failed to add device %s: %s", opts.port, term_strerror(term_errno, errno)); r = term_apply(tty_fd); if ( r < 0 ) fatal("failed to config device %s: %s", opts.port, term_strerror(term_errno, errno)); r = term_add(STI); if ( r < 0 ) fatal("failed to add I/O device: %s", term_strerror(term_errno, errno)); term_set_raw(STI); r = term_apply(STI); if ( r < 0 ) fatal("failed to set I/O device to raw mode: %s", term_strerror(term_errno, errno)); fd_printf(STO, "Terminal ready\r\n"); loop(); fd_printf(STO, "\r\n"); if ( opts.noreset ) { fd_printf(STO, "Skipping tty reset...\r\n"); term_erase(tty_fd); } fd_printf(STO, "Thanks for using picocom\r\n"); /* wait a bit for output to drain */ sleep(1); #ifdef UUCP_LOCK_DIR uucp_unlock(); #endif return EXIT_SUCCESS; } /**********************************************************************/ /* * Local Variables: * mode:c * tab-width: 4 * c-basic-offset: 4 * End: */ picocom-1.7/README0000664000175000017500000000330411377605660012375 0ustar npatnpat picocom by Nick Patavalis (npat@efault.net) As its name suggests, [picocom] is a minimal dumb-terminal emulation program. It is, in principle, very much like minicom, only it's "pico" instead of "mini"! It was designed to serve as a simple, manual, modem configuration, testing, and debugging tool. It has also served (quite well) as a low-tech "terminal-window" to allow operator intervention in PPP connection scripts (something like the ms-windows "open terminal window before / after dialing" feature). It could also prove useful in many other similar tasks. It is ideal for embedded systems since its memory footprint is minimal (less than 20K, when stripped). Apart from being a handy little tool, [picocom] source distribution includes a simple, easy to use, and thoroughly documented terminal-management library, which could serve other projects as well. This library hides the termios(3) calls, and provides a less complex and safer (though certainly less feature-rich) interface. [picocom] runs on Linux, and with minor modifications it could run on any Unix system with the termios(3) library. For a description of picocom's operation, its command line options, and usage examples, see the manual page included in the source distribution as "picocom.8", and also html-ized as "picocom.8.html". People who have contibuted to picocom, by offering feature implementations, bug-fixes, corrections, and suggestions are listed in the "CONTRIBUTORS" file. The latest version of "picocom" can be downloaded from: http://efault.net/npat/hacks/picocom/ Please feel free to send comments, requests for new features (no promisses, though!), bug-fixes and rants, to the author's email address shown at the top of this file. picocom-1.7/term.c0000664000175000017500000004645611400043217012624 0ustar npatnpat/* vi: set sw=4 ts=4: * * term.c * * General purpose terminal handling library. * * Nick Patavalis (npat@inaccessnetworks.com) * * originaly by Pantelis Antoniou (panto@intranet.gr), Nick Patavalis * * Documentation can be found in the header file "term.h". * * 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 * * $Id$ */ #include #include #include #include #include #ifdef __linux__ #include #else #include #endif /* of __linux__ */ #include "term.h" /***************************************************************************/ static struct term_s { int init; int fd[MAX_TERMS]; struct termios origtermios[MAX_TERMS]; struct termios currtermios[MAX_TERMS]; struct termios nexttermios[MAX_TERMS]; } term; /***************************************************************************/ int term_errno; static const char * const term_err_str[] = { [TERM_EOK] = "No error", [TERM_ENOINIT] = "Framework is uninitialized", [TERM_EFULL] = "Framework is full", [TERM_ENOTFOUND] = "Filedes not in the framework", [TERM_EEXISTS] = "Filedes already in the framework", [TERM_EATEXIT] = "Cannot install atexit handler", [TERM_EISATTY] = "Filedes is not a tty", [TERM_EFLUSH] = "Cannot flush the device", [TERM_EGETATTR] = "Cannot get the device attributes", [TERM_ESETATTR] = "Cannot set the device attributes", [TERM_EBAUD] = "Invalid baud rate", [TERM_ESETOSPEED] = "Cannot set the output speed", [TERM_ESETISPEED] = "Cannot set the input speed", [TERM_EPARITY] = "Invalid parity mode", [TERM_EDATABITS] = "Invalid number of databits", [TERM_EFLOW] = "Invalid flowcontrol mode", [TERM_EDTRDOWN] = "Cannot lower DTR", [TERM_EDTRUP] = "Cannot raise DTR", [TERM_EDRAIN] = "Cannot drain the device", [TERM_EBREAK] = "Cannot send break sequence" }; static char term_err_buff[1024]; const char * term_strerror (int terrnum, int errnum) { const char *rval; switch(terrnum) { case TERM_EFLUSH: case TERM_EGETATTR: case TERM_ESETATTR: case TERM_ESETOSPEED: case TERM_ESETISPEED: case TERM_EDRAIN: case TERM_EBREAK: snprintf(term_err_buff, sizeof(term_err_buff), "%s: %s", term_err_str[terrnum], strerror(errnum)); rval = term_err_buff; break; case TERM_EOK: case TERM_ENOINIT: case TERM_EFULL: case TERM_ENOTFOUND: case TERM_EEXISTS: case TERM_EATEXIT: case TERM_EISATTY: case TERM_EBAUD: case TERM_EPARITY: case TERM_EDATABITS: case TERM_EFLOW: case TERM_EDTRDOWN: case TERM_EDTRUP: snprintf(term_err_buff, sizeof(term_err_buff), "%s", term_err_str[terrnum]); rval = term_err_buff; break; default: rval = NULL; break; } return rval; } int term_perror (const char *prefix) { return fprintf(stderr, "%s %s\n", prefix, term_strerror(term_errno, errno)); } /***************************************************************************/ static int term_find_next_free (void) { int rval, i; do { /* dummy */ if ( ! term.init ) { term_errno = TERM_ENOINIT; rval = -1; break; } for (i = 0; i < MAX_TERMS; i++) if ( term.fd[i] == -1 ) break; if ( i == MAX_TERMS ) { term_errno = TERM_EFULL; rval = -1; break; } rval = i; } while (0); return rval; } /***************************************************************************/ static int term_find (int fd) { int rval, i; do { /* dummy */ if ( ! term.init ) { term_errno = TERM_ENOINIT; rval = -1; break; } for (i = 0; i < MAX_TERMS; i++) if (term.fd[i] == fd) break; if ( i == MAX_TERMS ) { term_errno = TERM_ENOTFOUND; rval = -1; break; } rval = i; } while (0); return rval; } /***************************************************************************/ static void term_exitfunc (void) { int r, i; do { /* dummy */ if ( ! term.init ) break; for (i = 0; i < MAX_TERMS; i++) { if (term.fd[i] == -1) continue; do { /* dummy */ r = tcflush(term.fd[i], TCIOFLUSH); if ( r < 0 ) break; r = tcsetattr(term.fd[i], TCSAFLUSH, &term.origtermios[i]); if ( r < 0 ) break; } while (0); if ( r < 0 ) { char *tname; tname = ttyname(term.fd[i]); if ( ! tname ) tname = "UNKNOWN"; fprintf(stderr, "%s: reset failed for dev %s: %s\n", __FUNCTION__, tname, strerror(errno)); } term.fd[i] = -1; } } while (0); } /***************************************************************************/ int term_lib_init (void) { int rval, r, i; rval = 0; do { /* dummy */ if ( term.init ) { /* reset all terms back to their original settings */ for (i = 0; i < MAX_TERMS; i++) { if (term.fd[i] == -1) continue; do { r = tcflush(term.fd[i], TCIOFLUSH); if ( r < 0 ) break; r = tcsetattr(term.fd[i], TCSAFLUSH, &term.origtermios[i]); if ( r < 0 ) break; } while (0); if ( r < 0 ) { char *tname; tname = ttyname(term.fd[i]); if ( ! tname ) tname = "UNKNOWN"; fprintf(stderr, "%s: reset failed for dev %s: %s\n", __FUNCTION__, tname, strerror(errno)); } term.fd[i] = -1; } } else { /* initialize term structure. */ for (i = 0; i < MAX_TERMS; i++) term.fd[i] = -1; if ( atexit(term_exitfunc) != 0 ) { term_errno = TERM_EATEXIT; rval = -1; break; } /* ok. term struct is now initialized. */ term.init = 1; } } while(0); return rval; } /***************************************************************************/ int term_add (int fd) { int rval, r, i; rval = 0; do { /* dummy */ i = term_find(fd); if ( i >= 0 ) { term_errno = TERM_EEXISTS; rval = -1; break; } if ( ! isatty(fd) ) { term_errno = TERM_EISATTY; rval = -1; break; } i = term_find_next_free(); if ( i < 0 ) { rval = -1; break; } r = tcgetattr(fd, &term.origtermios[i]); if ( r < 0 ) { term_errno = TERM_EGETATTR; rval = -1; break; } term.currtermios[i] = term.origtermios[i]; term.nexttermios[i] = term.origtermios[i]; term.fd[i] = fd; } while (0); return rval; } /***************************************************************************/ int term_remove(int fd) { int rval, r, i; rval = 0; do { /* dummy */ i = term_find(fd); if ( i < 0 ) { rval = -1; break; } do { /* dummy */ r = tcflush(term.fd[i], TCIOFLUSH); if ( r < 0 ) { term_errno = TERM_EFLUSH; rval = -1; break; } r = tcsetattr(term.fd[i], TCSAFLUSH, &term.origtermios[i]); if ( r < 0 ) { term_errno = TERM_ESETATTR; rval = -1; break; } } while (0); term.fd[i] = -1; } while (0); return rval; } /***************************************************************************/ int term_erase(int fd) { int rval, i; rval = 0; do { /* dummy */ i = term_find(fd); if ( i < 0 ) { rval = -1; break; } term.fd[i] = -1; } while (0); return rval; } /***************************************************************************/ int term_replace (int oldfd, int newfd) { int rval, r, i; rval = 0; do { /* dummy */ i = term_find(oldfd); if ( i < 0 ) { rval = -1; break; } r = tcsetattr(newfd, TCSAFLUSH, &term.currtermios[i]); if ( r < 0 ) { term_errno = TERM_ESETATTR; rval = -1; break; } term.fd[i] = newfd; } while (0); return rval; } /***************************************************************************/ int term_reset (int fd) { int rval, r, i; rval = 0; do { /* dummy */ i = term_find(fd); if ( i < 0 ) { rval = -1; break; } r = tcflush(term.fd[i], TCIOFLUSH); if ( r < 0 ) { term_errno = TERM_EFLUSH; rval = -1; break; } r = tcsetattr(term.fd[i], TCSAFLUSH, &term.origtermios[i]); if ( r < 0 ) { term_errno = TERM_ESETATTR; rval = -1; break; } term.currtermios[i] = term.origtermios[i]; term.nexttermios[i] = term.origtermios[i]; } while (0); return rval; } /***************************************************************************/ int term_revert (int fd) { int rval, i; rval = 0; do { /* dummy */ i = term_find(fd); if ( i < 0 ) { rval = -1; break; } term.nexttermios[i] = term.currtermios[i]; } while (0); return rval; } /***************************************************************************/ int term_refresh (int fd) { int rval, r, i; rval = 0; do { /* dummy */ i = term_find(fd); if ( i < 0 ) { rval = -1; break; } r = tcgetattr(fd, &term.currtermios[i]); if ( r < 0 ) { term_errno = TERM_EGETATTR; rval = -1; break; } } while (0); return rval; } /***************************************************************************/ int term_apply (int fd) { int rval, r, i; rval = 0; do { /* dummy */ i = term_find(fd); if ( i < 0 ) { rval = -1; break; } r = tcsetattr(term.fd[i], TCSAFLUSH, &term.nexttermios[i]); if ( r < 0 ) { term_errno = TERM_ESETATTR; rval = -1; break; } term.currtermios[i] = term.nexttermios[i]; } while (0); return rval; } /***************************************************************************/ int term_set_raw (int fd) { int rval, i; rval = 0; do { /* dummy */ i = term_find(fd); if ( i < 0 ) { rval = -1; break; } /* BSD raw mode */ cfmakeraw(&term.nexttermios[i]); /* one byte at a time, no timer */ term.nexttermios[i].c_cc[VMIN] = 1; term.nexttermios[i].c_cc[VTIME] = 0; } while (0); return rval; } /***************************************************************************/ int term_set_baudrate (int fd, int baudrate) { int rval, r, i; speed_t spd; struct termios tio; rval = 0; do { /* dummy */ i = term_find(fd); if ( i < 0 ) { rval = -1; break; } tio = term.nexttermios[i]; switch (baudrate) { case 0: spd = B0; break; case 50: spd = B50; break; case 75: spd = B75; break; case 110: spd = B110; break; case 134: spd = B134; break; case 150: spd = B150; break; case 200: spd = B200; break; case 300: spd = B300; break; case 600: spd = B600; break; case 1200: spd = B1200; break; case 1800: spd = B1800; break; case 2400: spd = B2400; break; case 4800: spd = B4800; break; case 9600: spd = B9600; break; case 19200: spd = B19200; break; case 38400: spd = B38400; break; case 57600: spd = B57600; break; case 115200: spd = B115200; break; #ifdef HIGH_BAUD case 230400: spd = B230400; break; case 460800: spd = B460800; break; case 921600: spd = B921600; break; #endif default: term_errno = TERM_EBAUD; rval = -1; break; } if ( rval < 0 ) break; r = cfsetospeed(&tio, spd); if ( r < 0 ) { term_errno = TERM_ESETOSPEED; rval = -1; break; } r = cfsetispeed(&tio, spd); if ( r < 0 ) { term_errno = TERM_ESETISPEED; rval = -1; break; } term.nexttermios[i] = tio; } while (0); return rval; } /***************************************************************************/ int term_set_parity (int fd, enum parity_e parity) { int rval, i; struct termios *tiop; rval = 0; do { /* dummy */ i = term_find(fd); if ( i < 0 ) { rval = -1; break; } tiop = &term.nexttermios[i]; switch (parity) { case P_EVEN: tiop->c_cflag &= ~PARODD; tiop->c_cflag |= PARENB; break; case P_ODD: tiop->c_cflag |= PARENB | PARODD; break; case P_NONE: tiop->c_cflag &= ~(PARENB | PARODD); break; default: term_errno = TERM_EPARITY; rval = -1; break; } if ( rval < 0 ) break; } while (0); return rval; } /***************************************************************************/ int term_set_databits (int fd, int databits) { int rval, i; struct termios *tiop; rval = 0; do { /* dummy */ i = term_find(fd); if ( i < 0 ) { rval = -1; break; } tiop = &term.nexttermios[i]; switch (databits) { case 5: tiop->c_cflag = (tiop->c_cflag & ~CSIZE) | CS5; break; case 6: tiop->c_cflag = (tiop->c_cflag & ~CSIZE) | CS6; break; case 7: tiop->c_cflag = (tiop->c_cflag & ~CSIZE) | CS7; break; case 8: tiop->c_cflag = (tiop->c_cflag & ~CSIZE) | CS8; break; default: term_errno = TERM_EDATABITS; rval = -1; break; } if ( rval < 0 ) break; } while (0); return rval; } /***************************************************************************/ int term_set_flowcntrl (int fd, enum flowcntrl_e flowcntl) { int rval, i; struct termios *tiop; rval = 0; do { /* dummy */ i = term_find(fd); if ( i < 0 ) { rval = -1; break; } tiop = &term.nexttermios[i]; switch (flowcntl) { case FC_RTSCTS: tiop->c_cflag |= CRTSCTS; tiop->c_iflag &= ~(IXON | IXOFF | IXANY); break; case FC_XONXOFF: tiop->c_cflag &= ~(CRTSCTS); tiop->c_iflag |= IXON | IXOFF; break; case FC_NONE: tiop->c_cflag &= ~(CRTSCTS); tiop->c_iflag &= ~(IXON | IXOFF | IXANY); break; default: term_errno = TERM_EFLOW; rval = -1; break; } if ( rval < 0 ) break; } while (0); return rval; } /***************************************************************************/ int term_set_local(int fd, int local) { int rval, i; struct termios *tiop; rval = 0; do { /* dummy */ i = term_find(fd); if ( i < 0 ) { rval = -1; break; } tiop = &term.nexttermios[i]; if ( local ) tiop->c_cflag |= CLOCAL; else tiop->c_cflag &= ~CLOCAL; } while (0); return rval; } /***************************************************************************/ int term_set_hupcl (int fd, int on) { int rval, i; struct termios *tiop; rval = 0; do { /* dummy */ i = term_find(fd); if ( i < 0 ) { rval = -1; break; } tiop = &term.nexttermios[i]; if ( on ) tiop->c_cflag |= HUPCL; else tiop->c_cflag &= ~HUPCL; } while (0); return rval; } /***************************************************************************/ int term_set(int fd, int raw, int baud, enum parity_e parity, int bits, enum flowcntrl_e fc, int local, int hup_close) { int rval, r, i, ni; struct termios tio; rval = 0; do { /* dummy */ i = term_find(fd); if ( i < 0 ) { ni = term_add(fd); if ( ni < 0 ) { rval = -1; break; } } else { ni = i; } tio = term.nexttermios[ni]; do { /* dummy */ if (raw) { r = term_set_raw(fd); if ( r < 0 ) { rval = -1; break; } } r = term_set_baudrate(fd, baud); if ( r < 0 ) { rval = -1; break; } r = term_set_parity(fd, parity); if ( r < 0 ) { rval = -1; break; } r = term_set_databits(fd, bits); if ( r < 0 ) { rval = -1; break; } r = term_set_flowcntrl(fd, fc); if ( r < 0 ) { rval = -1; break; } r = term_set_local(fd, local); if ( r < 0 ) { rval = -1; break; } r = term_set_hupcl(fd, hup_close); if ( r < 0 ) { rval = -1; break; } } while (0); if ( rval < 0 ) { if ( i < 0 ) /* new addition. must be removed */ term.fd[ni] = -1; else /* just revert to previous settings */ term.nexttermios[ni] = tio; } } while (0); return rval; } /***************************************************************************/ int term_pulse_dtr (int fd) { int rval, r, i; rval = 0; do { /* dummy */ i = term_find(fd); if ( i < 0 ) { rval = -1; break; } #ifdef __linux__ { int opins = TIOCM_DTR; r = ioctl(fd, TIOCMBIC, &opins); if ( r < 0 ) { term_errno = TERM_EDTRDOWN; rval = -1; break; } sleep(1); r = ioctl(fd, TIOCMBIS, &opins); if ( r < 0 ) { term_errno = TERM_EDTRUP; rval = -1; break; } } #else { struct termios tio, tioold; r = tcgetattr(fd, &tio); if ( r < 0 ) { term_errno = TERM_ESETATTR; rval = -1; break; } tioold = tio; cfsetospeed(&tio, B0); cfsetispeed(&tio, B0); r = tcsetattr(fd, TCSANOW, &tio); if ( r < 0 ) { term_errno = TERM_ESETATTR; rval = -1; break; } sleep(1); r = tcsetattr(fd, TCSANOW, &tioold); if ( r < 0 ) { term.currtermios[i] = tio; term_errno = TERM_ESETATTR; rval = -1; break; } } #endif /* of __linux__ */ } while (0); return rval; } /***************************************************************************/ int term_raise_dtr(int fd) { int rval, r, i; rval = 0; do { /* dummy */ i = term_find(fd); if ( i < 0 ) { rval = -1; break; } #ifdef __linux__ { int opins = TIOCM_DTR; r = ioctl(fd, TIOCMBIS, &opins); if ( r < 0 ) { term_errno = TERM_EDTRUP; rval = -1; break; } } #else r = tcsetattr(fd, TCSANOW, &term.currtermios[i]); if ( r < 0 ) { /* FIXME: perhaps try to update currtermios */ term_errno = TERM_ESETATTR; rval = -1; break; } #endif /* of __linux__ */ } while (0); return rval; } /***************************************************************************/ int term_lower_dtr(int fd) { int rval, r, i; rval = 0; do { /* dummy */ i = term_find(fd); if ( i < 0 ) { rval = -1; break; } #ifdef __linux__ { int opins = TIOCM_DTR; r = ioctl(fd, TIOCMBIC, &opins); if ( r < 0 ) { term_errno = TERM_EDTRDOWN; rval = -1; break; } } #else { struct termios tio; r = tcgetattr(fd, &tio); if ( r < 0 ) { term_errno = TERM_EGETATTR; rval = -1; break; } term.currtermios[i] = tio; cfsetospeed(&tio, B0); cfsetispeed(&tio, B0); r = tcsetattr(fd, TCSANOW, &tio); if ( r < 0 ) { term_errno = TERM_ESETATTR; rval = -1; break; } } #endif /* of __linux__ */ } while (0); return rval; } /***************************************************************************/ int term_drain(int fd) { int rval, r; rval = 0; do { /* dummy */ r = term_find(fd); if ( r < 0 ) { rval = -1; break; } do { r = tcdrain(fd); } while ( r < 0 && errno == EINTR); if ( r < 0 ) { term_errno = TERM_EDRAIN; rval = -1; break; } } while (0); return rval; } /***************************************************************************/ int term_flush(int fd) { int rval, r; rval = 0; do { /* dummy */ r = term_find(fd); if ( r < 0 ) { rval = -1; break; } r = tcflush(fd, TCIOFLUSH); if ( r < 0 ) { rval = -1; break; } } while (0); return rval; } /***************************************************************************/ int term_break(int fd) { int rval, r; rval = 0; do { /* dummy */ r = term_find(fd); if ( r < 0 ) { rval = -1; break; } r = tcsendbreak(fd, 0); if ( r < 0 ) { term_errno = TERM_EBREAK; rval = -1; break; } } while (0); return rval; } /**************************************************************************/ /* * Local Variables: * mode:c * tab-width: 4 * c-basic-offset: 4 * End: */ picocom-1.7/picocom.8.ps0000664000175000017500000005714211720655626013670 0ustar npatnpat%!PS-Adobe-3.0 %%Creator: groff version 1.21 %%CreationDate: Tue Feb 21 10:04:53 2012 %%DocumentNeededResources: font Times-Roman %%+ font Times-Bold %%+ font Times-Italic %%DocumentSuppliedResources: procset grops 1.21 0 %%Pages: 4 %%PageOrder: Ascend %%DocumentMedia: Default 612 792 0 () () %%Orientation: Portrait %%EndComments %%BeginDefaults %%PageMedia: Default %%EndDefaults %%BeginProlog %%BeginResource: procset grops 1.21 0 %!PS-Adobe-3.0 Resource-ProcSet /setpacking where{ pop currentpacking true setpacking }if /grops 120 dict dup begin /SC 32 def /A/show load def /B{0 SC 3 -1 roll widthshow}bind def /C{0 exch ashow}bind def /D{0 exch 0 SC 5 2 roll awidthshow}bind def /E{0 rmoveto show}bind def /F{0 rmoveto 0 SC 3 -1 roll widthshow}bind def /G{0 rmoveto 0 exch ashow}bind def /H{0 rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def /I{0 exch rmoveto show}bind def /J{0 exch rmoveto 0 SC 3 -1 roll widthshow}bind def /K{0 exch rmoveto 0 exch ashow}bind def /L{0 exch rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def /M{rmoveto show}bind def /N{rmoveto 0 SC 3 -1 roll widthshow}bind def /O{rmoveto 0 exch ashow}bind def /P{rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def /Q{moveto show}bind def /R{moveto 0 SC 3 -1 roll widthshow}bind def /S{moveto 0 exch ashow}bind def /T{moveto 0 exch 0 SC 5 2 roll awidthshow}bind def /SF{ findfont exch [exch dup 0 exch 0 exch neg 0 0]makefont dup setfont [exch/setfont cvx]cvx bind def }bind def /MF{ findfont [5 2 roll 0 3 1 roll neg 0 0]makefont dup setfont [exch/setfont cvx]cvx bind def }bind def /level0 0 def /RES 0 def /PL 0 def /LS 0 def /MANUAL{ statusdict begin/manualfeed true store end }bind def /PLG{ gsave newpath clippath pathbbox grestore exch pop add exch pop }bind def /BP{ /level0 save def 1 setlinecap 1 setlinejoin DEFS/BPhook known{DEFS begin BPhook end}if 72 RES div dup scale LS{ 90 rotate }{ 0 PL translate }ifelse 1 -1 scale }bind def /EP{ level0 restore showpage }def /DA{ newpath arcn stroke }bind def /SN{ transform .25 sub exch .25 sub exch round .25 add exch round .25 add exch itransform }bind def /DL{ SN moveto SN lineto stroke }bind def /DC{ newpath 0 360 arc closepath }bind def /TM matrix def /DE{ TM currentmatrix pop translate scale newpath 0 0 .5 0 360 arc closepath TM setmatrix }bind def /RC/rcurveto load def /RL/rlineto load def /ST/stroke load def /MT/moveto load def /CL/closepath load def /Fr{ setrgbcolor fill }bind def /setcmykcolor where{ pop /Fk{ setcmykcolor fill }bind def }if /Fg{ setgray fill }bind def /FL/fill load def /LW/setlinewidth load def /Cr/setrgbcolor load def /setcmykcolor where{ pop /Ck/setcmykcolor load def }if /Cg/setgray load def /RE{ findfont dup maxlength 1 index/FontName known not{1 add}if dict begin { 1 index/FID ne 2 index/UniqueID ne and {def}{pop pop}ifelse }forall /Encoding exch def dup/FontName exch def currentdict end definefont pop }bind def /DEFS 0 def /EBEGIN{ moveto DEFS begin }bind def /EEND/end load def /CNT 0 def /level1 0 def /PBEGIN{ /level1 save def translate div 3 1 roll div exch scale neg exch neg exch translate 0 setgray 0 setlinecap 1 setlinewidth 0 setlinejoin 10 setmiterlimit []0 setdash /setstrokeadjust where{ pop false setstrokeadjust }if /setoverprint where{ pop false setoverprint }if newpath /CNT countdictstack def userdict begin /showpage{}def /setpagedevice{}def mark }bind def /PEND{ cleartomark countdictstack CNT sub{end}repeat level1 restore }bind def end def /setpacking where{ pop setpacking }if %%EndResource %%EndProlog %%BeginSetup %%BeginFeature: *PageSize Default << /PageSize [ 612 792 ] /ImagingBBox null >> setpagedevice %%EndFeature %%IncludeResource: font Times-Roman %%IncludeResource: font Times-Bold %%IncludeResource: font Times-Italic grops begin/DEFS 1 dict def DEFS begin/u{.001 mul}bind def end/RES 72 def/PL 792 def/LS false def/ENC0[/asciicircum/asciitilde/Scaron/Zcaron /scaron/zcaron/Ydieresis/trademark/quotesingle/Euro/.notdef/.notdef /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef /.notdef/.notdef/space/exclam/quotedbl/numbersign/dollar/percent /ampersand/quoteright/parenleft/parenright/asterisk/plus/comma/hyphen /period/slash/zero/one/two/three/four/five/six/seven/eight/nine/colon /semicolon/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O /P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright/circumflex /underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y /z/braceleft/bar/braceright/tilde/.notdef/quotesinglbase/guillemotleft /guillemotright/bullet/florin/fraction/perthousand/dagger/daggerdbl /endash/emdash/ff/fi/fl/ffi/ffl/dotlessi/dotlessj/grave/hungarumlaut /dotaccent/breve/caron/ring/ogonek/quotedblleft/quotedblright/oe/lslash /quotedblbase/OE/Lslash/.notdef/exclamdown/cent/sterling/currency/yen /brokenbar/section/dieresis/copyright/ordfeminine/guilsinglleft /logicalnot/minus/registered/macron/degree/plusminus/twosuperior /threesuperior/acute/mu/paragraph/periodcentered/cedilla/onesuperior /ordmasculine/guilsinglright/onequarter/onehalf/threequarters /questiondown/Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE /Ccedilla/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex /Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis /multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn /germandbls/agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla /egrave/eacute/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis /eth/ntilde/ograve/oacute/ocircumflex/otilde/odieresis/divide/oslash /ugrave/uacute/ucircumflex/udieresis/yacute/thorn/ydieresis]def /Times-Italic@0 ENC0/Times-Italic RE/Times-Bold@0 ENC0/Times-Bold RE /Times-Roman@0 ENC0/Times-Roman RE %%EndSetup %%Page: 1 1 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 373.3(picocom\(8\) picocom\(8\))72 48 R/F1 10.95 /Times-Bold@0 SF -.219(NA)72 84 S(ME).219 E F0 (picocom \255 minimal dumb-terminal emulation program)108 96 Q F1 (SYNOPSIS)72 112.8 Q/F2 10/Times-Bold@0 SF(picocom [)108 124.8 Q/F3 10 /Times-Italic@0 SF(options)2.73 E F2(])2.77 E F3(de)2.85 E(vice)-.15 E F1(DESCRIPTION)72 141.6 Q F0 1.423(As its name suggests,)108 153.6 R F2 (picocom)3.923 E F0 1.423 (is a minimal dumb-terminal emulation program. It is, in principle, v) 3.923 F(ery)-.15 E .938(much lik)108 165.6 R(e)-.1 E F2(minicom\(1\)) 3.438 E F0 3.439(,o)3.439 G .939(nly it')-3.439 F 3.439(s")-.55 G .939 (pico" instead of "mini"! It w)-3.439 F .939(as designed to serv)-.1 F 3.439(ea)-.15 G 3.439(sas)-3.439 G .939(imple, manual,)-3.439 F .757 (modem con\214guration, testing, and deb)108 177.6 R .757 (ugging tool. It has also serv)-.2 F .756(ed \(quite well\) as a lo)-.15 F .756(w-tech "terminal-)-.25 F(windo)108 189.6 Q .865(w" to allo)-.25 F 3.365(wo)-.25 G .865(perator interv)-3.365 F .865 (ention in PPP connection scripts \(something lik)-.15 F 3.366(et)-.1 G .866(he ms-windo)-3.366 F .866(ws "open)-.25 F(terminal windo)108 201.6 Q 2.5(wb)-.25 G(efore / after dialing" feature\). It could also pro)-2.5 E .3 -.15(ve u)-.15 H(seful in man).15 E 2.5(yo)-.15 G (ther similar tasks.)-2.5 E(When)108 220.8 Q F2(picocom)3.989 E F0 1.489 (starts it opens the terminal \(serial de)3.989 F 1.489(vice\) gi)-.25 F -.15(ve)-.25 G 3.989(na).15 G 3.988(si)-3.989 G 1.488(ts non-option ar) -3.988 F 1.488(gument. Unless the)-.18 F F3(--noinit)108.01 232.8 Q F0 1.333(option is gi)4.513 F -.15(ve)-.25 G 1.333 (n, it con\214gures the de).15 F 1.333 (vice to the settings speci\214ed by the option-ar)-.25 F 1.334 (guments \(or to)-.18 F .487(some def)108 244.8 R .487 (ault settings\), and sets it to "ra)-.1 F .487(w" mode. If)-.15 F F3 (--noinit)2.996 E F0 .486(is gi)3.666 F -.15(ve)-.25 G .486 (n, the initialization and con\214guration is).15 F .667 (skipped; the de)108 256.8 R .667(vice is just opened. F)-.25 F(ollo) -.15 E .667(wing this,)-.25 F F2(picocom)3.167 E F0 .667 (sets the standard-input and standard-output to)3.167 F(ra)108 268.8 Q 3.289(wm)-.15 G .789(ode. Ha)-3.289 F .789(ving done so, it goes in a l\ oop where it listens for input from stdin, or from the serial port.)-.2 F .589(Input from the serial port is copied to the standard output whil\ e input from the standard input is copied to)108 280.8 R .105 (the serial port.)108 292.8 R F2(picocom)5.105 E F0 .105 (also scans its input stream for a user)2.605 F .105 (-speci\214ed control character)-.2 F 2.605(,c)-.4 G .105 (alled the "escape)-2.605 F .554(character" \(being by def)108 304.8 R .555(ault "C-a"\). If the escape character is seen, then instead of sen\ ding it to the serial-)-.1 F(de)108 316.8 Q .179 (vice, the program enters "command mode" and w)-.25 F .179 (aits for the ne)-.1 F .178 (xt character \(which is called the "function)-.15 F 1.572 (character"\). Depending on the v)108 328.8 R 1.573 (alue of the function character)-.25 F(,)-.4 E F2(picocom)4.073 E F0 1.573(performs one of the operations)4.073 F (described in the "Commands" section belo)108 340.8 Q -.65(w.)-.25 G F1 (COMMANDS)72 364.8 Q F0 1.588(Commands are gi)108 376.8 R -.15(ve)-.25 G 4.088(nt).15 G(o)-4.088 E F2(picocom)4.088 E F0 1.588(by \214rst k)4.088 F -.15(ey)-.1 G 1.587(ing the "espace character" which by def).15 F 1.587(ault is "C-a" \(see)-.1 F .671("Options" belo)108 388.8 R 3.171 (wo)-.25 G 3.172(nh)-3.171 G 1.172 -.25(ow t)-3.172 H 3.172(oc).25 G .672(hange it\), and then k)-3.172 F -.15(ey)-.1 G .672 (ing one for the function \(command\) characters sho).15 F(wn)-.25 E (here.)108 400.8 Q F2([escape character])108 417.6 Q F0 1.244(Send the \ escape character to the serial port and return to "transparent" mode. T\ his means that if the)123 429.6 R .358(escape character \("C-a", by def) 123 441.6 R .359(ault\) is typed twice, the program sends the escape ch\ aracter to the serial)-.1 F .054 (port, and remains in transparent mode. This is a ne)123 453.6 R 2.553 (wb)-.25 G(eha)-2.553 E .053(vior implemented in v1.4. Pre)-.2 F .053 (viously picocom)-.25 F(used to ignore the escape-character when it w) 123 465.6 Q(as entered as a function character)-.1 E(.)-.55 E F2(C-x)108 482.4 Q F0 .567(Exit the program: if the "--noreset" option w)123 494.4 R .567(as not gi)-.1 F -.15(ve)-.25 G 3.067(nt).15 G .567 (hen the serial port is reset to its original set-)-3.067 F (tings before e)123 506.4 Q(xiting; if it w)-.15 E(as gi)-.1 E -.15(ve) -.25 G 2.5(nt).15 G(he serial port is not reset.)-2.5 E F2(C-q)108 523.2 Q F0(Quit the program *without* reseting the serial port, re)123 535.2 Q -.05(ga)-.15 G(rdless of the "--noreset" option.).05 E F2(C-p)108 552 Q F0(Pulse the DTR line. Lo)123 564 Q (wer it for 1 sec, and then raise it ag)-.25 E(ain.)-.05 E F2(C-t)108 580.8 Q F0 -.8(To)123 592.8 S(ggle the DTR line. If DTR is up, then lo) .8 E(wer it. If it is do)-.25 E(wn, then raise it.)-.25 E F2 (C-backslash)108 609.6 Q F0 .026(Generate a break sequence on the seria\ l line. A break sequence is usually generated by marking \(dri)123 621.6 R(ving)-.25 E(to logical one\) the serial Tx line for an amount of time\ coresponding to se)123 633.6 Q -.15(ve)-.25 G(ral character durations.) .15 E F2(C-u)108 650.4 Q F0 .601(Baud up. Increase the baud-rate. The l\ ist of baud-rates stepped-through by this command is: 300, 600,)123 662.4 R(1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200.)123 674.4 Q F2(C-d)108 691.2 Q F0 1.555(Baud do)123 703.2 R 1.555(wn. Decrease the \ baud-rate. The list of baud-rates stepped-through by this command is th\ e)-.25 F(same as for the "baud-up" command.)123 715.2 Q(1)535 768 Q 0 Cg EP %%Page: 2 2 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 373.3(picocom\(8\) picocom\(8\))72 48 R/F1 10 /Times-Bold@0 SF(C-f)108 84 Q F0(Cycle through \215o)123 96 Q (w-control settings \(R)-.25 E(TS/CTS, XON/XOFF)-.6 E 2.5(,n)-.8 G (one\).)-2.5 E F1(C-y)108 112.8 Q F0(Cycle through parity settings \(e) 123 124.8 Q -.15(ve)-.25 G(n, odd, none\).).15 E F1(C-b)108 141.6 Q F0 (Cycle through databits-number settings \(5, 6, 7, 8\).)123 153.6 Q F1 (C-c)108 170.4 Q F0 -.8(To)123 182.4 S(ggle local-echo mode.).8 E F1 (C-v)108 199.2 Q F0(Sho)123 211.2 Q 4.02(wp)-.25 G 1.52 (rogram options \(lik)-4.02 F 4.02(eb)-.1 G 1.521(aud rate, data bits, \ etc\). Only the options that can be modi\214ed online)-4.02 F (\(through commands\) are sho)123 223.2 Q (wn, not those that can only be set at the command-line.)-.25 E F1(C-s) 108 240 Q F0(Send \(upload\) a \214le \(see "Sending and Recei)123 252 Q (ving Files" belo)-.25 E(w\))-.25 E F1(C-r)108 268.8 Q F0(Recei)123 280.8 Q .3 -.15(ve \()-.25 H(do).15 E (wnload\) a \214le \(see "Sending and Recei)-.25 E(ving Files" belo)-.25 E(w\))-.25 E .054(After performing one of the abo)108 297.6 R .354 -.15 (ve o)-.15 H .054(perations the program lea).15 F -.15(ve)-.2 G 2.554 (st).15 G .054(he command mode and enters transparent)-2.554 F (mode. Example: T)108 309.6 Q 2.5(oi)-.8 G(ncrease the baud-rate by tw) -2.5 E 2.5(os)-.1 G(teps, you ha)-2.5 E .3 -.15(ve t)-.2 H 2.5(ot).15 G (ype:)-2.5 E(C-a, C-u, C-a, C-u)108 328.8 Q (assuming of-course that "C-a" is the escape character)108 348 Q(.)-.55 E/F2 10.95/Times-Bold@0 SF(SENDING AND RECEIVING FILES)72 372 Q F1 (picocom)108 384 Q F0 .427(can send and recei)2.926 F .727 -.15(ve \214) -.25 H .427(les o).15 F -.15(ve)-.15 G 2.927(rt).15 G .427 (he serial port using e)-2.927 F .427 (xternal programs that implement the respec-)-.15 F(ti)108 396 Q .3 -.15 (ve p)-.25 H(rotocols. In Linux typical programs for this purpose are:) .15 E<8a>108 412.8 Q F1(rx\(1\))123 412.8 Q F0 2.5(-r)2.5 G(ecei)-2.5 E .3 -.15(ve u)-.25 H(sing the X-MODEM protocol).15 E<8a>108 429.6 Q F1 (rb\(1\))123 429.6 Q F0 2.5(-r)2.5 G(ecei)-2.5 E .3 -.15(ve u)-.25 H (sing the Y).15 E(-MODEM protocol)-1.11 E<8a>108 446.4 Q F1(rz\(1\))123 446.4 Q F0 2.5(-r)2.5 G(ecei)-2.5 E .3 -.15(ve u)-.25 H (sing the Z-MODEM protocol).15 E<8a>108 463.2 Q F1(sx\(1\))123 463.2 Q F0 2.5(-s)2.5 G(end using the X-MODEM protocol)-2.5 E<8a>108 480 Q F1 (sb\(1\))123 480 Q F0 2.5(-s)2.5 G(end using the Y)-2.5 E (-MODEM protocol)-1.11 E<8a>108 496.8 Q F1(sz\(1\))123 496.8 Q F0 2.5 (-s)2.5 G(end using the Z-MODEM protocol)-2.5 E<8a>108 513.6 Q F1 (ascii-xfr\(1\))123 513.6 Q F0 2.5(-r)2.5 G(ecei)-2.5 E .3 -.15(ve o) -.25 H 2.5(rt).15 G(ransmit ASCII \214les)-2.5 E .692(The name of, and \ the command-line options to, the program to be used for transmitting \ \214les are gi)108 530.4 R -.15(ve)-.25 G 3.191(nb).15 G(y)-3.191 E 2.843(the "--send-cmd" option. Similarly the program to recei)108 542.4 R 3.143 -.15(ve \214)-.25 H 2.843(les, and its ar).15 F 2.844 (gumets, are gi)-.18 F -.15(ve)-.25 G 5.344(nb).15 G 5.344(yt)-5.344 G (he)-5.344 E("--recei)108 554.4 Q -.15(ve)-.25 G .118(-cmd" option. F) .15 F .117(or e)-.15 F .117(xample, in order to start a)-.15 F F1 (picocom)2.617 E F0 .117 (session that uses "sz" to transmit \214les, and)2.617 F("rz" to recei) 108 566.4 Q -.15(ve)-.25 G 2.5(,y).15 G(ou ha)-2.5 E .3 -.15(ve t)-.2 H 2.5(os).15 G(ay something lik)-2.5 E 2.5(et)-.1 G(his:)-2.5 E (picocom --send-cmd "sz -vv" --recei)108 585.6 Q -.15(ve)-.25 G (-cmd "rz -vv").15 E .309(During the picocom session, if you k)108 604.8 R .609 -.15(ey t)-.1 H .309(he "send" or "recei).15 F -.15(ve)-.25 G 2.809("c).15 G .309(ommands \(e.g. by pressing C-a, C-s, or C-)-2.809 F .431(a, C-r\) you will be prompted for a \214lename. At this prompt you\ can enter one or more \214le-names, and an)108 616.8 R(y)-.15 E .487 (additional ar)108 628.8 R .487(guments to the transmission or receptio\ n program. After that, picocom will start the the e)-.18 F(xter)-.15 E (-)-.2 E .403 (nal program as speci\214ed by the "--send-cmd", or "--recei)108 640.8 R -.15(ve)-.25 G .403(-cmd" option, and with an).15 F 2.902<798c>-.15 G .402(lenames and addi-)-2.902 F 1.195(tional ar)108 652.8 R 1.195 (guments you may ha)-.18 F 1.495 -.15(ve s)-.2 H 1.195 (upplied. The standard input and output of the e).15 F 1.195 (xternal program will be)-.15 F .851 (connected to the serial port. The standard error of the e)108 664.8 R .851(xternal program will be connected to the terminal)-.15 F 1.399 (which---while the program is running---will re)108 676.8 R -.15(ve)-.25 G 1.399(rt to canonical mode. Pressing 'C-c' while the e).15 F(xternal) -.15 E(program is running will prematurely terminate it, and return con\ trol to)108 688.8 Q F1(picocom)2.5 E F0(2)535 768 Q 0 Cg EP %%Page: 3 3 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 373.3(picocom\(8\) picocom\(8\))72 48 R/F1 10.95 /Times-Bold@0 SF(INPUT)72 84 Q 2.738(,O)-.81 G(UTPUT)-2.738 E 2.738(,A) -.81 G(ND ECHO MAPPING)-2.738 E F0 .373 (Using the "--imap", "--omap", and "--emap" options you can mak)108 96 R (e)-.1 E/F2 10/Times-Bold@0 SF(picocom)2.873 E F0 .372 (map \(tranlate, replace\) certain)2.873 F .214 (special characters after being read from the serial port \(with)108 108 R/F3 10/Times-Italic@0 SF(--imap)2.724 E F0 .215 (\), before being written to the serial port)2.905 F(\(with)108 120 Q F3 (--omap)3.34 E F0 .83(\), and before being locally echoed to the termin\ al \(standard output\) if local echo is enabled)3.52 F(\(with)108 132 Q F3(--emap)3.495 E F0 .985(\). These mapping options tak)3.675 F .986 (e, each, a single ar)-.1 F .986 (gument which is a comma-separated list of)-.18 F (one or more of the follo)108 144 Q(wing identi\214ers:)-.25 E<8a>108 160.8 Q(crlf: map CR to LF)123 160.8 Q<8a>108 177.6 Q (crcrlf: map CR to CR + LF)123 177.6 Q<8a>108 194.4 Q(igncr: ignore CR) 123 194.4 Q<8a>108 211.2 Q(lfcr: map LF to CR)123 211.2 Q<8a>108 228 Q (lfcrlf: map LF to CR + LF)123 228 Q<8a>108 244.8 Q(ignlf: ignore LF)123 244.8 Q<8a>108 261.6 Q(bsdel: map BS --> DEL)123 261.6 Q<8a>108 278.4 Q (delbs: map DEL --> BS)123 278.4 Q -.15(Fo)108 295.2 S 2.5(re).15 G (xample the command:)-2.65 E (picocom --omap crlf,delbs --imap inglf,bsdel --emap crcrlf ...)108 314.4 Q .86(will: Replace e)108 333.6 R -.15(ve)-.25 G .86(ry CR \(carr\ iage return, 0x0d\) caracter with LF \(line feed, 0x0a\) and e).15 F -.15(ve)-.25 G .86(ry DEL \(delete,).15 F .054(0x7f\) character with BS\ \(backspace, 0x08\) before writing it to the serial port. Ignore \(not\ write to the termi-)108 345.6 R .782(nal\) e)108 357.6 R -.15(ve)-.25 G .781(ry LF character read from the serial port and replace e).15 F -.15 (ve)-.25 G .781(ry BS character read from the serial port).15 F 1.42 (with DEL. Replace e)108 369.6 R -.15(ve)-.25 G 1.42(ry CR character wi\ th CR and LF when echoing to the terminal \(if local-echo is).15 F (enabled\).)108 381.6 Q F1(OPTIONS)72 405.6 Q F2(picocom)108 417.6 Q F0 (accepts the follo)2.5 E(wing command-line options)-.25 E F2 (--baud | -b)108 434.4 Q F0 (De\214nes the baud-rate to set the serial-port \(terminal\) to.)123 446.4 Q F2(--\215o)108 463.2 Q 2.5(w|-)-.1 G(f)-2.5 E F0 (De\214nes the \215o)123 475.2 Q (w-control mode to set the serial-port to. Must be one of:)-.25 E<8a>123 492 Q(\264x' for xon/xof)138 492 Q 2.5(f\()-.25 G(softw)-2.5 E (are\) mode)-.1 E<8a>123 508.8 Q(\264h' for hardw)138 508.8 Q(are \215o) -.1 E 2.5(wc)-.25 G(ontrol \(R)-2.5 E(TS/CTS\))-.6 E<8a>123 525.6 Q (\264n' for no \215o)138 525.6 Q 2.5(wc)-.25 G(ontrol)-2.5 E(\(Def)123 542.4 Q(ault: 'n'\))-.1 E F2(--parity | -p)108 559.2 Q F0 (De\214nes the parity mode to set the serial-port to. Must be one of:) 123 571.2 Q<8a>123 588 Q(\264o' for odd parity mode.)138 588 Q<8a>123 604.8 Q(\264e' for e)138 604.8 Q -.15(ve)-.25 G 2.5(np).15 G (arity mode.)-2.5 E<8a>123 621.6 Q(\264n' for no parity)138 621.6 Q 2.5 (,m)-.65 G(ode.)-2.5 E(\(Def)123 638.4 Q(ault: 'n'\))-.1 E F2 (--databits | -d)108 655.2 Q F0(De\214nes the number of data bits in e) 123 667.2 Q -.15(ve)-.25 G(ry character).15 E 2.5(.M)-.55 G (ust be one of: 5, 6, 7, 8)-2.5 E(\(Def)123 686.4 Q(ault: 8\))-.1 E F2 (--esacpe | -e)108 703.2 Q F0 1.151 (De\214nes the character that will mak)123 715.2 R 3.651(ep)-.1 G 1.151 (icocom enter command-mode \(see description abo)-3.651 F -.15(ve)-.15 G 1.15(\). If 'x' is).15 F(gi)123 727.2 Q -.15(ve)-.25 G (n, then C-x will mak).15 E 2.5(ep)-.1 G(icocom enter command mode.)-2.5 E(3)535 768 Q 0 Cg EP %%Page: 4 4 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 373.3(picocom\(8\) picocom\(8\))72 48 R(\(Def) 123 84 Q(ault: 'a'\))-.1 E/F1 10/Times-Bold@0 SF(--echo | -c)108 100.8 Q F0 .193(Enable local echo. Ev)123 112.8 R .193(ery character being read\ from the terminal \(standard input\) is echoed to the termi-)-.15 F(na\ l \(standard output\) subject to the echo-mapping con\214guration \(see) 123 124.8 Q/F2 10/Times-Italic@0 SF(--emap)2.51 E F0(option.)2.69 E (\(Def)123 144 Q(ault: Disabled\))-.1 E F1(--noinit | -i)108 160.8 Q F0 .847(If gi)123 172.8 R -.15(ve)-.25 G(n,).15 E F1(picocom)3.347 E F0 .846(will not initialize, reset, or otherwise meddle with the serial po\ rt at start-up. It will)3.347 F 1.705 (just open it. This is useful, for e)123 184.8 R 1.706 (xample, for connecting)-.15 F F1(picocom)4.206 E F0 1.706 (to already-connected modems, or)4.206 F .864(already con\214gured port\ s without terminating the connection, or altering the settings. If requ\ ired serial)123 196.8 R (port parameters can then be adjusted at run-time by commands.)123 208.8 Q F1(--nor)108 225.6 Q(eset | -r)-.18 E F0 .18(If gi)123 237.6 R -.15 (ve)-.25 G(n,).15 E F1(picocom)2.68 E F0 .18 (will not *reset* the serial port when e)2.68 F .18 (xiting. It will just close the \214ledes and do noth-)-.15 F .798 (ing more. This is useful, for e)123 249.6 R .798(xample, for lea)-.15 F .798(ving modems connected when e)-.2 F(xiting)-.15 E F1 .797 (picocom picocom)3.297 F F0 .42 (using the "Quit" command \(instead of "Exit"\), which ne)123 261.6 R -.15(ve)-.25 G 2.92(rr).15 G .42 (esets the serial port. If "--noreset" is gi)-2.92 F -.15(ve)-.25 G(n) .15 E(then "Quit" and "Exit" beha)123 273.6 Q .3 -.15(ve e)-.2 H (ssentially the same.).15 E F1(--nolock | -l)108 290.4 Q F0 2.07(If gi) 123 302.4 R -.15(ve)-.25 G(n,).15 E F1(picocom)4.57 E F0 2.07(will *not\ * attempt to lock the serial port before opening it. Normally picocom) 4.57 F .456(attempts to get a UUCP-style lock-\214le \(e.g. "/v)123 314.4 R .456(ar/lock/LCK..ttyS0"\) before opening the port. F)-.25 F .457(ailing to)-.15 F .914(do so, results in the program e)123 326.4 R .914(xiting after emitting an error)-.15 F .913 (-message. It is possible that your picocom)-.2 F (binary is compiled without this option.)123 338.4 Q F1(--send-cmd | -s) 108 355.2 Q F0(Speci\214es the e)123 367.2 Q(xternal program \(and an) -.15 E 2.5(ya)-.15 G -.18(rg)-2.5 G (uments to it\) that will be used for transmitting \214les.).18 E(Def) 123 386.4 Q(ault: "sz -vv")-.1 E F1(--r)108 403.2 Q(ecei)-.18 E -.1(ve) -.1 G(-cmd | -v).1 E F0(Speci\214es the e)123 415.2 Q (xternal program \(and an)-.15 E 2.5(ya)-.15 G -.18(rg)-2.5 G (uments to it\) that will be used for recei).18 E(ving \214les.)-.25 E (\(Def)123 434.4 Q(ault: "rz -vv"\))-.1 E F1(--imap)108 451.2 Q F0 .324 (Speci\214es the input character map \(i.e. special characters to be re\ placed when read from the serial port\).)123 463.2 R (Example: "--imap crlf,delbs")123 475.2 Q(\(Def)123 494.4 Q (aul: Empty\))-.1 E F1(--omap)108 511.2 Q F0 .752(Speci\214es the outpu\ t character map \(i.e. special characters to be replaced before being w\ ritten to serial)123 523.2 R(port\). Example: "--omap crcrlf,bsdel")123 535.2 Q(\(Def)123 554.4 Q(aul: Empty\))-.1 E F1(--emap)108 571.2 Q F0 .572(Speci\214es the local-echo character map \(i.e. special characters\ to be replaced before being echoed-back)123 583.2 R(to the terminal, i\ f local-echo is enabled\). Example: "--emap crcrlf,bsdel")123 595.2 Q (\(Def)123 614.4 Q(aul: delbs,crcrlf\))-.1 E F1(--help | -h)108 631.2 Q F0(Print a short help message describing the command-line options.)123 643.2 Q/F3 10.95/Times-Bold@0 SF -.548(AU)72 660 S(THOR).548 E F0 (picocom w)108 672 Q(as written by Nick P)-.1 E(ata)-.15 E -.25(va)-.2 G (lis \(npat@ef).25 E(ault.net\))-.1 E F3 -1.04 -1.588(AV A)72 696 T (ILABILITY)1.588 E F0(The latest v)108 708 Q (ersion of "picocom" can be do)-.15 E(wnloaded from:)-.25 E F1 (http://code.google.com/p/picocom/)2.5 E F0(4)535 768 Q 0 Cg EP %%Trailer end %%EOF picocom-1.7/picocom.8.html0000664000175000017500000004037011720655626014205 0ustar npatnpat picocom(8)

picocom(8) picocom(8)

NAME

picocom -- minimal dumb-terminal emulation program

SYNOPSIS

  • picocom [ options ] device

DESCRIPTION

As its name suggests, picocom is a minimal dumb-terminal emulation program. It is, in principle, very much like minicom(1), only it's "pico" instead of "mini"! It was designed to serve as a simple, manual, modem configuration, testing, and debugging tool. It has also served (quite well) as a low-tech "terminal-window" to allow operator intervention in PPP connection scripts (something like the ms-windows "open terminal window before / after dialing" feature). It could also prove useful in many other similar tasks.

When picocom starts it opens the terminal (serial device) given as its non-option argument. Unless the --noinit option is given, it configures the device to the settings specified by the option-arguments (or to some default settings), and sets it to "raw" mode. If --noinit is given, the initialization and configuration is skipped; the device is just opened. Following this, picocom sets the standard-input and standard-output to raw mode. Having done so, it goes in a loop where it listens for input from stdin, or from the serial port. Input from the serial port is copied to the standard output while input from the standard input is copied to the serial port. picocom also scans its input stream for a user-specified control character, called the "escape character" (being by default "C-a"). If the escape character is seen, then instead of sending it to the serial-device, the program enters "command mode" and waits for the next character (which is called the "function character"). Depending on the value of the function character, picocom performs one of the operations described in the "Commands" section below.

COMMANDS

Commands are given to picocom by first keying the "espace character" which by default is "C-a" (see "Options" below on how to change it), and then keying one for the function (command) characters shown here.

[escape character]

Send the escape character to the serial port and return to "transparent" mode. This means that if the escape character ("C-a", by default) is typed twice, the program sends the escape character to the serial port, and remains in transparent mode. This is a new behavior implemented in v1.4. Previously picocom used to ignore the escape-character when it was entered as a function character.

C-x

Exit the program: if the "--noreset" option was not given then the serial port is reset to its original settings before exiting; if it was given the serial port is not reset.

C-q

Quit the program *without* reseting the serial port, regardless of the "--noreset" option.

C-p

Pulse the DTR line. Lower it for 1 sec, and then raise it again.

C-t

Toggle the DTR line. If DTR is up, then lower it. If it is down, then raise it.

C-backslash

Generate a break sequence on the serial line. A break sequence is usually generated by marking (driving to logical one) the serial Tx line for an amount of time coresponding to several character durations.

C-u

Baud up. Increase the baud-rate. The list of baud-rates stepped-through by this command is: 300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200.

C-d

Baud down. Decrease the baud-rate. The list of baud-rates stepped-through by this command is the same as for the "baud-up" command.

C-f

Cycle through flow-control settings (RTS/CTS, XON/XOFF, none).

C-y

Cycle through parity settings (even, odd, none).

C-b

Cycle through databits-number settings (5, 6, 7, 8).

C-c

Toggle local-echo mode.

C-v

Show program options (like baud rate, data bits, etc). Only the options that can be modified online (through commands) are shown, not those that can only be set at the command-line.

C-s

Send (upload) a file (see "Sending and Receiving Files" below)

C-r

Receive (download) a file (see "Sending and Receiving Files" below)

After performing one of the above operations the program leaves the command mode and enters transparent mode. Example: To increase the baud-rate by two steps, you have to type:

C-a, C-u, C-a, C-u

assuming of-course that "C-a" is the escape character.

SENDING AND RECEIVING FILES

picocom can send and receive files over the serial port using external programs that implement the respective protocols. In Linux typical programs for this purpose are:

  • rx(1) - receive using the X-MODEM protocol

  • rb(1) - receive using the Y-MODEM protocol

  • rz(1) - receive using the Z-MODEM protocol

  • sx(1) - send using the X-MODEM protocol

  • sb(1) - send using the Y-MODEM protocol

  • sz(1) - send using the Z-MODEM protocol

  • ascii-xfr(1) - receive or transmit ASCII files

The name of, and the command-line options to, the program to be used for transmitting files are given by the "--send-cmd" option. Similarly the program to receive files, and its argumets, are given by the "--receive-cmd" option. For example, in order to start a picocom session that uses "sz" to transmit files, and "rz" to receive, you have to say something like this:

picocom --send-cmd "sz -vv" --receive-cmd "rz -vv"

During the picocom session, if you key the "send" or "receive" commands (e.g. by pressing C-a, C-s, or C-a, C-r) you will be prompted for a filename. At this prompt you can enter one or more file-names, and any additional arguments to the transmission or reception program. After that, picocom will start the the external program as specified by the "--send-cmd", or "--receive-cmd" option, and with any filenames and additional arguments you may have supplied. The standard input and output of the external program will be connected to the serial port. The standard error of the external program will be connected to the terminal which---while the program is running---will revert to canonical mode. Pressing 'C-c' while the external program is running will prematurely terminate it, and return control to picocom. Pressing 'C-c' at any other time, has no special effect; the character is normally passed to the serial port.

INPUT, OUTPUT, AND ECHO MAPPING

Using the "--imap", "--omap", and "--emap" options you can make picocom map (tranlate, replace) certain special characters after being read from the serial port (with --imap), before being written to the serial port (with --omap), and before being locally echoed to the terminal (standard output) if local echo is enabled (with --emap). These mapping options take, each, a single argument which is a comma-separated list of one or more of the following identifiers:

  • crlf: map CR to LF
  • crcrlf: map CR to CR + LF
  • igncr: ignore CR
  • lfcr: map LF to CR
  • lfcrlf: map LF to CR + LF
  • ignlf: ignore LF
  • bsdel: map BS --> DEL
  • delbs: map DEL --> BS

For example the command:

picocom --omap crlf,delbs --imap inglf,bsdel --emap crcrlf ...

will: Replace every CR (carriage return, 0x0d) caracter with LF (line feed, 0x0a) and every DEL (delete, 0x7f) character with BS (backspace, 0x08) before writing it to the serial port. Ignore (not write to the terminal) every LF character read from the serial port and replace every BS character read from the serial port with DEL. Replace every CR character with CR and LF when echoing to the terminal (if local-echo is enabled).

OPTIONS

picocom accepts the following command-line options

--baud | -b

Defines the baud-rate to set the serial-port (terminal) to.

--flow | -f

Defines the flow-control mode to set the serial-port to. Must be one of:

  • \'x' for xon/xoff (software) mode

  • \'h' for hardware flow control (RTS/CTS)

  • \'n' for no flow control

(Default: 'n')

--parity | -p

Defines the parity mode to set the serial-port to. Must be one of:

  • \'o' for odd parity mode.

  • \'e' for even parity mode.

  • \'n' for no parity, mode.

(Default: 'n')

--databits | -d

Defines the number of data bits in every character. Must be one of: 5, 6, 7, 8

(Default: 8)

--esacpe | -e

Defines the character that will make picocom enter command-mode (see description above). If 'x' is given, then C-x will make picocom enter command mode.

(Default: 'a')

--echo | -c

Enable local echo. Every character being read from the terminal (standard input) is echoed to the terminal (standard output) subject to the echo-mapping configuration (see --emap option.

(Default: Disabled)

--noinit | -i

If given, picocom will not initialize, reset, or otherwise meddle with the serial port at start-up. It will just open it. This is useful, for example, for connecting picocom to already-connected modems, or already configured ports without terminating the connection, or altering the settings. If required serial port parameters can then be adjusted at run-time by commands.

--noreset | -r

If given, picocom will not *reset* the serial port when exiting. It will just close the filedes and do nothing more. This is useful, for example, for leaving modems connected when exiting picocom. Regardless whether the "--noreset" option is given the user can exit picocom using the "Quit" command (instead of "Exit"), which never resets the serial port. If "--noreset" is given then "Quit" and "Exit" behave essentially the same.

--nolock | -l

If given, picocom will *not* attempt to lock the serial port before opening it. Normally picocom attempts to get a UUCP-style lock-file (e.g. "/var/lock/LCK..ttyS0") before opening the port. Failing to do so, results in the program exiting after emitting an error-message. It is possible that your picocom binary is compiled without this option.

--send-cmd | -s

Specifies the external program (and any arguments to it) that will be used for transmitting files.

Default: "sz -vv"

--receive-cmd | -v

Specifies the external program (and any arguments to it) that will be used for receiving files.

(Default: "rz -vv")

--imap

Specifies the input character map (i.e. special characters to be replaced when read from the serial port). Example: "--imap crlf,delbs"

(Defaul: Empty)

--omap

Specifies the output character map (i.e. special characters to be replaced before being written to serial port). Example: "--omap crcrlf,bsdel"

(Defaul: Empty)

--emap

Specifies the local-echo character map (i.e. special characters to be replaced before being echoed-back to the terminal, if local-echo is enabled). Example: "--emap crcrlf,bsdel"

(Defaul: delbs,crcrlf)

--help | -h

Print a short help message describing the command-line options.

AUTHOR

picocom was written by Nick Patavalis (npat@efault.net)

AVAILABILITY

The latest version of "picocom" can be downloaded from: http://code.google.com/p/picocom/

picocom(8)
picocom-1.7/pczm0000664000175000017500000000013211377605660012405 0ustar npatnpat#!/bin/sh exec picocom \ --send-cmd="sz -vv -b" \ --receive-cmd="rz -vvv -b" "$@" picocom-1.7/picocom.8.xml0000664000175000017500000003443611720655626014047 0ustar npatnpat picocom [ options ] device

As its name suggests, picocom is a minimal dumb-terminal emulation program. It is, in principle, very much like , only it's "pico" instead of "mini"! It was designed to serve as a simple, manual, modem configuration, testing, and debugging tool. It has also served (quite well) as a low-tech "terminal-window" to allow operator intervention in PPP connection scripts (something like the ms-windows "open terminal window before / after dialing" feature). It could also prove useful in many other similar tasks.

When picocom starts it opens the terminal (serial device) given as its non-option argument. Unless the --noinit option is given, it configures the device to the settings specified by the option-arguments (or to some default settings), and sets it to "raw" mode. If --noinit is given, the initialization and configuration is skipped; the device is just opened. Following this, picocom sets the standard-input and standard-output to raw mode. Having done so, it goes in a loop where it listens for input from stdin, or from the serial port. Input from the serial port is copied to the standard output while input from the standard input is copied to the serial port. picocom also scans its input stream for a user-specified control character, called the "escape character" (being by default "C-a"). If the escape character is seen, then instead of sending it to the serial-device, the program enters "command mode" and waits for the next character (which is called the "function character"). Depending on the value of the function character, picocom performs one of the operations described in the "Commands" section below.

Commands are given to picocom by first keying the "espace character" which by default is "C-a" (see "Options" below on how to change it), and then keying one for the function (command) characters shown here.

[escape character]

Send the escape character to the serial port and return to "transparent" mode. This means that if the escape character ("C-a", by default) is typed twice, the program sends the escape character to the serial port, and remains in transparent mode. This is a new behavior implemented in v1.4. Previously picocom used to ignore the escape-character when it was entered as a function character.

C-x

Exit the program: if the "--noreset" option was not given then the serial port is reset to its original settings before exiting; if it was given the serial port is not reset.

C-q

Quit the program *without* reseting the serial port, regardless of the "--noreset" option.

C-p

Pulse the DTR line. Lower it for 1 sec, and then raise it again.

C-t

Toggle the DTR line. If DTR is up, then lower it. If it is down, then raise it.

C-backslash

Generate a break sequence on the serial line. A break sequence is usually generated by marking (driving to logical one) the serial Tx line for an amount of time coresponding to several character durations.

C-u

Baud up. Increase the baud-rate. The list of baud-rates stepped-through by this command is: 300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200.

C-d

Baud down. Decrease the baud-rate. The list of baud-rates stepped-through by this command is the same as for the "baud-up" command.

C-f

Cycle through flow-control settings (RTS/CTS, XON/XOFF, none).

C-y

Cycle through parity settings (even, odd, none).

C-b

Cycle through databits-number settings (5, 6, 7, 8).

C-c

Toggle local-echo mode.

C-v

Show program options (like baud rate, data bits, etc). Only the options that can be modified online (through commands) are shown, not those that can only be set at the command-line.

C-s

Send (upload) a file (see "Sending and Receiving Files" below)

C-r

Receive (download) a file (see "Sending and Receiving Files" below)

After performing one of the above operations the program leaves the command mode and enters transparent mode. Example: To increase the baud-rate by two steps, you have to type:

C-a, C-u, C-a, C-u

assuming of-course that "C-a" is the escape character.

picocom can send and receive files over the serial port using external programs that implement the respective protocols. In Linux typical programs for this purpose are:

  • - receive using the X-MODEM protocol

  • - receive using the Y-MODEM protocol

  • - receive using the Z-MODEM protocol

  • - send using the X-MODEM protocol

  • - send using the Y-MODEM protocol

  • - send using the Z-MODEM protocol

  • - receive or transmit ASCII files

The name of, and the command-line options to, the program to be used for transmitting files are given by the "--send-cmd" option. Similarly the program to receive files, and its argumets, are given by the "--receive-cmd" option. For example, in order to start a picocom session that uses "sz" to transmit files, and "rz" to receive, you have to say something like this:

picocom --send-cmd "sz -vv" --receive-cmd "rz -vv"

During the picocom session, if you key the "send" or "receive" commands (e.g. by pressing C-a, C-s, or C-a, C-r) you will be prompted for a filename. At this prompt you can enter one or more file-names, and any additional arguments to the transmission or reception program. After that, picocom will start the the external program as specified by the "--send-cmd", or "--receive-cmd" option, and with any filenames and additional arguments you may have supplied. The standard input and output of the external program will be connected to the serial port. The standard error of the external program will be connected to the terminal which---while the program is running---will revert to canonical mode. Pressing 'C-c' while the external program is running will prematurely terminate it, and return control to picocom. Pressing 'C-c' at any other time, has no special effect; the character is normally passed to the serial port.

Using the "--imap", "--omap", and "--emap" options you can make picocom map (tranlate, replace) certain special characters after being read from the serial port (with --imap), before being written to the serial port (with --omap), and before being locally echoed to the terminal (standard output) if local echo is enabled (with --emap). These mapping options take, each, a single argument which is a comma-separated list of one or more of the following identifiers:

  • crlf: map CR to LF
  • crcrlf: map CR to CR + LF
  • igncr: ignore CR
  • lfcr: map LF to CR
  • lfcrlf: map LF to CR + LF
  • ignlf: ignore LF
  • bsdel: map BS --> DEL
  • delbs: map DEL --> BS

For example the command:

picocom --omap crlf,delbs --imap inglf,bsdel --emap crcrlf ...

will: Replace every CR (carriage return, 0x0d) caracter with LF (line feed, 0x0a) and every DEL (delete, 0x7f) character with BS (backspace, 0x08) before writing it to the serial port. Ignore (not write to the terminal) every LF character read from the serial port and replace every BS character read from the serial port with DEL. Replace every CR character with CR and LF when echoing to the terminal (if local-echo is enabled).

picocom accepts the following command-line options

--baud | -b

Defines the baud-rate to set the serial-port (terminal) to.

--flow | -f

Defines the flow-control mode to set the serial-port to. Must be one of:

  • \'x' for xon/xoff (software) mode

  • \'h' for hardware flow control (RTS/CTS)

  • \'n' for no flow control

(Default: 'n')

--parity | -p

Defines the parity mode to set the serial-port to. Must be one of:

  • \'o' for odd parity mode.

  • \'e' for even parity mode.

  • \'n' for no parity, mode.

(Default: 'n')

--databits | -d

Defines the number of data bits in every character. Must be one of: 5, 6, 7, 8

(Default: 8)

--esacpe | -e

Defines the character that will make picocom enter command-mode (see description above). If 'x' is given, then C-x will make picocom enter command mode.

(Default: 'a')

--echo | -c

Enable local echo. Every character being read from the terminal (standard input) is echoed to the terminal (standard output) subject to the echo-mapping configuration (see --emap option.

(Default: Disabled)

--noinit | -i

If given, picocom will not initialize, reset, or otherwise meddle with the serial port at start-up. It will just open it. This is useful, for example, for connecting picocom to already-connected modems, or already configured ports without terminating the connection, or altering the settings. If required serial port parameters can then be adjusted at run-time by commands.

--noreset | -r

If given, picocom will not *reset* the serial port when exiting. It will just close the filedes and do nothing more. This is useful, for example, for leaving modems connected when exiting picocom. Regardless whether the "--noreset" option is given the user can exit picocom using the "Quit" command (instead of "Exit"), which never resets the serial port. If "--noreset" is given then "Quit" and "Exit" behave essentially the same.

--nolock | -l

If given, picocom will *not* attempt to lock the serial port before opening it. Normally picocom attempts to get a UUCP-style lock-file (e.g. "/var/lock/LCK..ttyS0") before opening the port. Failing to do so, results in the program exiting after emitting an error-message. It is possible that your picocom binary is compiled without this option.

--send-cmd | -s

Specifies the external program (and any arguments to it) that will be used for transmitting files.

Default: "sz -vv"

--receive-cmd | -v

Specifies the external program (and any arguments to it) that will be used for receiving files.

(Default: "rz -vv")

--imap

Specifies the input character map (i.e. special characters to be replaced when read from the serial port). Example: "--imap crlf,delbs"

(Defaul: Empty)

--omap

Specifies the output character map (i.e. special characters to be replaced before being written to serial port). Example: "--omap crcrlf,bsdel"

(Defaul: Empty)

--emap

Specifies the local-echo character map (i.e. special characters to be replaced before being echoed-back to the terminal, if local-echo is enabled). Example: "--emap crcrlf,bsdel"

(Defaul: delbs,crcrlf)

--help | -h

Print a short help message describing the command-line options.

picocom was written by Nick Patavalis (npat@efault.net)

The latest version of "picocom" can be downloaded from:

picocom-1.7/picocom.80000664000175000017500000002614211720655626013243 0ustar npatnpat.TH "picocom" "8" "" "" "" .SH NAME picocom \- minimal dumb-terminal emulation program .SH SYNOPSIS .B picocom [ .I options .B ] .I device .br .SH DESCRIPTION As its name suggests, .B picocom is a minimal dumb-terminal emulation program. It is, in principle, very much like .B minicom(1) , only it's "pico" instead of "mini"! It was designed to serve as a simple, manual, modem configuration, testing, and debugging tool. It has also served (quite well) as a low-tech "terminal-window" to allow operator intervention in PPP connection scripts (something like the ms-windows "open terminal window before / after dialing" feature). It could also prove useful in many other similar tasks. .br .sp 0.6v When .B picocom starts it opens the terminal (serial device) given as its non-option argument. Unless the .I --noinit option is given, it configures the device to the settings specified by the option-arguments (or to some default settings), and sets it to "raw" mode. If .I --noinit is given, the initialization and configuration is skipped; the device is just opened. Following this, .B picocom sets the standard-input and standard-output to raw mode. Having done so, it goes in a loop where it listens for input from stdin, or from the serial port. Input from the serial port is copied to the standard output while input from the standard input is copied to the serial port. .B picocom also scans its input stream for a user-specified control character, called the "escape character" (being by default "C-a"). If the escape character is seen, then instead of sending it to the serial-device, the program enters "command mode" and waits for the next character (which is called the "function character"). Depending on the value of the function character, .B picocom performs one of the operations described in the "Commands" section below. .br .sp 0.6v .SH COMMANDS Commands are given to .B picocom by first keying the "espace character" which by default is "C-a" (see "Options" below on how to change it), and then keying one for the function (command) characters shown here. .TP 3 .B [escape character] Send the escape character to the serial port and return to "transparent" mode. This means that if the escape character ("C-a", by default) is typed twice, the program sends the escape character to the serial port, and remains in transparent mode. This is a new behavior implemented in v1.4. Previously picocom used to ignore the escape-character when it was entered as a function character. .TP 3 .B C-x Exit the program: if the "--noreset" option was not given then the serial port is reset to its original settings before exiting; if it was given the serial port is not reset. .TP 3 .B C-q Quit the program *without* reseting the serial port, regardless of the "--noreset" option. .TP 3 .B C-p Pulse the DTR line. Lower it for 1 sec, and then raise it again. .TP 3 .B C-t Toggle the DTR line. If DTR is up, then lower it. If it is down, then raise it. .TP 3 .B C-backslash Generate a break sequence on the serial line. A break sequence is usually generated by marking (driving to logical one) the serial Tx line for an amount of time coresponding to several character durations. .TP 3 .B C-u Baud up. Increase the baud-rate. The list of baud-rates stepped-through by this command is: 300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200. .TP 3 .B C-d Baud down. Decrease the baud-rate. The list of baud-rates stepped-through by this command is the same as for the "baud-up" command. .TP 3 .B C-f Cycle through flow-control settings (RTS/CTS, XON/XOFF, none). .TP 3 .B C-y Cycle through parity settings (even, odd, none). .TP 3 .B C-b Cycle through databits-number settings (5, 6, 7, 8). .TP 3 .B C-c Toggle local-echo mode. .TP 3 .B C-v Show program options (like baud rate, data bits, etc). Only the options that can be modified online (through commands) are shown, not those that can only be set at the command-line. .TP 3 .B C-s Send (upload) a file (see "Sending and Receiving Files" below) .TP 3 .B C-r Receive (download) a file (see "Sending and Receiving Files" below) .PP After performing one of the above operations the program leaves the command mode and enters transparent mode. Example: To increase the baud-rate by two steps, you have to type: .br .sp 0.6v C-a, C-u, C-a, C-u .br .sp 0.6v assuming of-course that "C-a" is the escape character. .br .sp 0.6v .SH SENDING AND RECEIVING FILES .B picocom can send and receive files over the serial port using external programs that implement the respective protocols. In Linux typical programs for this purpose are: .IP \(em 3 .B rx(1) - receive using the X-MODEM protocol .IP \(em 3 .B rb(1) - receive using the Y-MODEM protocol .IP \(em 3 .B rz(1) - receive using the Z-MODEM protocol .IP \(em 3 .B sx(1) - send using the X-MODEM protocol .IP \(em 3 .B sb(1) - send using the Y-MODEM protocol .IP \(em 3 .B sz(1) - send using the Z-MODEM protocol .IP \(em 3 .B ascii-xfr(1) - receive or transmit ASCII files .PP The name of, and the command-line options to, the program to be used for transmitting files are given by the "--send-cmd" option. Similarly the program to receive files, and its argumets, are given by the "--receive-cmd" option. For example, in order to start a .B picocom session that uses "sz" to transmit files, and "rz" to receive, you have to say something like this: .br .sp 0.6v picocom --send-cmd "sz -vv" --receive-cmd "rz -vv" .br .sp 0.6v During the picocom session, if you key the "send" or "receive" commands (e.g. by pressing C-a, C-s, or C-a, C-r) you will be prompted for a filename. At this prompt you can enter one or more file-names, and any additional arguments to the transmission or reception program. After that, picocom will start the the external program as specified by the "--send-cmd", or "--receive-cmd" option, and with any filenames and additional arguments you may have supplied. The standard input and output of the external program will be connected to the serial port. The standard error of the external program will be connected to the terminal which---while the program is running---will revert to canonical mode. Pressing 'C-c' while the external program is running will prematurely terminate it, and return control to .B picocom . Pressing 'C-c' at any other time, has no special effect; the character is normally passed to the serial port. .br .sp 0.6v .SH INPUT, OUTPUT, AND ECHO MAPPING Using the "--imap", "--omap", and "--emap" options you can make .B picocom map (tranlate, replace) certain special characters after being read from the serial port (with .I --imap ), before being written to the serial port (with .I --omap ), and before being locally echoed to the terminal (standard output) if local echo is enabled (with .I --emap ). These mapping options take, each, a single argument which is a comma-separated list of one or more of the following identifiers: .IP \(em 3 crlf: map CR to LF .IP \(em 3 crcrlf: map CR to CR + LF .IP \(em 3 igncr: ignore CR .IP \(em 3 lfcr: map LF to CR .IP \(em 3 lfcrlf: map LF to CR + LF .IP \(em 3 ignlf: ignore LF .IP \(em 3 bsdel: map BS --> DEL .IP \(em 3 delbs: map DEL --> BS .PP For example the command: .br .sp 0.6v picocom --omap crlf,delbs --imap inglf,bsdel --emap crcrlf ... .br .sp 0.6v will: Replace every CR (carriage return, 0x0d) caracter with LF (line feed, 0x0a) and every DEL (delete, 0x7f) character with BS (backspace, 0x08) before writing it to the serial port. Ignore (not write to the terminal) every LF character read from the serial port and replace every BS character read from the serial port with DEL. Replace every CR character with CR and LF when echoing to the terminal (if local-echo is enabled). .br .sp 0.6v .SH OPTIONS .B picocom accepts the following command-line options .TP 3 .B --baud | -b Defines the baud-rate to set the serial-port (terminal) to. .TP 3 .B --flow | -f Defines the flow-control mode to set the serial-port to. Must be one of: .RS 3 .IP \(em 3 \'x' for xon/xoff (software) mode .IP \(em 3 \'h' for hardware flow control (RTS/CTS) .IP \(em 3 \'n' for no flow control .PP (Default: 'n') .RE .TP 3 .B --parity | -p Defines the parity mode to set the serial-port to. Must be one of: .RS 3 .IP \(em 3 \'o' for odd parity mode. .IP \(em 3 \'e' for even parity mode. .IP \(em 3 \'n' for no parity, mode. .PP (Default: 'n') .RE .TP 3 .B --databits | -d Defines the number of data bits in every character. Must be one of: 5, 6, 7, 8 .br .sp 0.6v (Default: 8) .TP 3 .B --esacpe | -e Defines the character that will make picocom enter command-mode (see description above). If 'x' is given, then C-x will make picocom enter command mode. .br .sp 0.6v (Default: 'a') .TP 3 .B --echo | -c Enable local echo. Every character being read from the terminal (standard input) is echoed to the terminal (standard output) subject to the echo-mapping configuration (see .I --emap option. .br .sp 0.6v (Default: Disabled) .TP 3 .B --noinit | -i If given, .B picocom will not initialize, reset, or otherwise meddle with the serial port at start-up. It will just open it. This is useful, for example, for connecting .B picocom to already-connected modems, or already configured ports without terminating the connection, or altering the settings. If required serial port parameters can then be adjusted at run-time by commands. .TP 3 .B --noreset | -r If given, .B picocom will not *reset* the serial port when exiting. It will just close the filedes and do nothing more. This is useful, for example, for leaving modems connected when exiting .B picocom . Regardless whether the "--noreset" option is given the user can exit .B picocom using the "Quit" command (instead of "Exit"), which never resets the serial port. If "--noreset" is given then "Quit" and "Exit" behave essentially the same. .TP 3 .B --nolock | -l If given, .B picocom will *not* attempt to lock the serial port before opening it. Normally picocom attempts to get a UUCP-style lock-file (e.g. "/var/lock/LCK..ttyS0") before opening the port. Failing to do so, results in the program exiting after emitting an error-message. It is possible that your picocom binary is compiled without this option. .TP 3 .B --send-cmd | -s Specifies the external program (and any arguments to it) that will be used for transmitting files. .br .sp 0.6v Default: "sz -vv" .TP 3 .B --receive-cmd | -v Specifies the external program (and any arguments to it) that will be used for receiving files. .br .sp 0.6v (Default: "rz -vv") .TP 3 .B --imap Specifies the input character map (i.e. special characters to be replaced when read from the serial port). Example: "--imap crlf,delbs" .br .sp 0.6v (Defaul: Empty) .TP 3 .B --omap Specifies the output character map (i.e. special characters to be replaced before being written to serial port). Example: "--omap crcrlf,bsdel" .br .sp 0.6v (Defaul: Empty) .TP 3 .B --emap Specifies the local-echo character map (i.e. special characters to be replaced before being echoed-back to the terminal, if local-echo is enabled). Example: "--emap crcrlf,bsdel" .br .sp 0.6v (Defaul: delbs,crcrlf) .TP 3 .B --help | -h Print a short help message describing the command-line options. .PP .SH AUTHOR picocom was written by Nick Patavalis (npat@efault.net) .br .sp 0.6v .SH AVAILABILITY The latest version of "picocom" can be downloaded from: .B http://code.google.com/p/picocom/ picocom-1.7/Makefile0000664000175000017500000000135711720627300013146 0ustar npatnpat VERSION=1.7 UUCP_LOCK_DIR=/var/lock # CC = gcc CPPFLAGS=-DVERSION_STR=\"$(VERSION)\" \ -DUUCP_LOCK_DIR=\"$(UUCP_LOCK_DIR)\" \ -DHIGH_BAUD CFLAGS = -Wall -g # LD = gcc LDFLAGS = -g LDLIBS = picocom : picocom.o term.o # $(LD) $(LDFLAGS) -o $@ $+ $(LDLIBS) picocom.o : picocom.c term.h term.o : term.c term.h doc : picocom.8 picocom.8.html picocom.8.ps changes : svn log -v . > CHANGES picocom.8 : picocom.8.xml xmlmp2man < $< > $@ picocom.8.html : picocom.8.xml xmlmp2html < $< > $@ picocom.8.ps : picocom.8 groff -mandoc -Tps $< > $@ clean: rm -f picocom.o term.o rm -f *~ rm -f \#*\# distclean: clean rm -f picocom realclean: distclean rm -f picocom.8 rm -f picocom.8.html rm -f picocom.8.ps rm -f CHANGES picocom-1.7/pcasc0000664000175000017500000000014711377605660012533 0ustar npatnpat#!/bin/sh exec ./picocom \ --send-cmd="ascii-xfr -sv -l5" \ --receive-cmd="ascii-xfr -rv" "$@" picocom-1.7/LICENSE.txt0000664000175000017500000004313111377605660013342 0ustar npatnpat 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) 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) year 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.