1
0
mirror of https://github.com/UzixLS/picocom.git synced 2025-07-19 07:21:18 +03:00

Merge branch 'master' into custombaud

This commit is contained in:
Nick Patavalis
2015-08-19 01:26:18 +03:00
14 changed files with 2126 additions and 775 deletions

View File

@ -1,11 +1,11 @@
VERSION=1.9a
VERSION=2.0a
# CC = gcc
#CC = gcc
CPPFLAGS=-DVERSION_STR=\"$(VERSION)\"
CFLAGS = -Wall -g
# LD = gcc
#LD = gcc
LDFLAGS = -g
LDLIBS =
@ -27,18 +27,23 @@ CPPFLAGS += -DUSE_FLOCK
#CPPFLAGS += -DUUCP_LOCK_DIR=\"$(UUCP_LOCK_DIR)\"
## Comment these out to disable "linenoise"-library support
SEND_RECEIVE_HISTFILE = .picocom_send_receive
CPPFLAGS += -DSEND_RECEIVE_HISTFILE=\"$(SEND_RECEIVE_HISTFILE)\" \
HISTFILE = .picocom_history
CPPFLAGS += -DHISTFILE=\"$(HISTFILE)\" \
-DLINENOISE
picocom : linenoise-1.0/linenoise.o
linenoise-1.0/linenoise.o : linenoise-1.0/linenoise.c linenoise-1.0/linenoise.h
## Comment this IN to remove help strings (saves ~ 4-6 Kb).
#CPPFLAGS += -DNO_HELP
picocom : picocom.o term.o
picocom : picocom.o term.o fdio.o split.o
# $(LD) $(LDFLAGS) -o $@ $+ $(LDLIBS)
picocom.o : picocom.c term.h
term.o : term.c term.h
split.o : split.c split.h
fdio.o : fdio.c fdio.h
doc : picocom.8 picocom.8.html picocom.8.ps
@ -56,7 +61,7 @@ picocom.8.ps : picocom.8
groff -mandoc -Tps $< > $@
clean:
rm -f picocom.o term.o linenoise-1.0/linenoise.o
rm -f picocom.o term.o fdio.o split.o linenoise-1.0/linenoise.o
rm -f *~
rm -f \#*\#

171
README.md
View File

@ -13,19 +13,18 @@ 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.
low-tech serial communications program to allow access to all types of
devices that provide serial consoles. It could also prove useful in
many other similar tasks.
It is ideal for embedded systems since its memory footprint is minimal
(approximately 30K, when stripped). Apart from being a handy little
tool, *picocom* source distribution includes a simple, easy to use,
tool, *picocom's* 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 no or minor
modifications it could run on any Unix system with the termios(3)
modifications it could run on any Unix-like system with the termios(3)
library.
For a description of picocom's operation, its command line options,
@ -39,3 +38,163 @@ the "CONTRIBUTORS" file.
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.
## Compilation / Installation
Change into picocom's source directory and say:
```
make
```
This will be enough to compile picocom for most modern Unix-like
systems. If you want, you can then strip the resulting binary like
this:
```
strip picocom
```
Striping the binary is not required, it just reduces its size by a few
kilobytes. Then you can copy the picocom binary, as well as the
man-page, to wherever you put your binaries and man-pages. For
example:
```
cp picocom ~/bin
cp picocom.8 ~/man/man8
```
Again, this is not strictly necessary. You can run picocom and read
its man-page directly from the source directory.
If something goes wrong and picocom can't compile cleanly, or if it's
lacking a feature you need, take a look at the included Makefile. It's
very simple and easy to understand. It allows you to select
compile-time options and enable or disable some compile-time features
by commenting in or out the respective lines.
## Using picocom
If your computer is a PC and has the standard on-board RS-233 ports
(usually accessible as two male DB9 connectors at the back) then under
Linux these are accessed through device nodes most likely named:
`/dev/ttyS0` and `/dev/ttyS1`. If your computer has no on-board serial
ports, then you will need a USB-to-Serial adapter (or something
similar). Once inserted to a USB port and recognized by Linux, a
device node is created for each serial port accessed through the
adapter(s). These nodes are most likely named `/dev/ttyUSB0`,
`/dev/ttyUSB1`, and so on. For other systems and other Unix-like OSes
you will have to consult their documentation as to how the serial port
device nodes are named. Lets assume your serial port is accessed
through a device node named `/dev/ttyS0`.
You can start picocom with its default option values (default serial
port settings) like this:
```
picocom /dev/ttyS0
```
If you have not installed the picocom binary to a suitable place, then
you can run it directly from the source distribution directory like
this:
```
./picocom /dev/ttyS0
```
If this fails with a message like:
```
FATAL: cannot open /dev/ttyS0: Permission denied
```
This means that you do not have permissions to access the serial
port's device node. To overcome this you can run picocom as root:
```
sudo picocom /dev/ttyS0
```
Alternatively, and preferably, you can add yourself to the user-group
that your system has for allowing access to serial ports. For most
Unix-like systems this group is called "dialout". Consult you system's
documentation to find out how you can do this (as it differs form
system to system). On most Linux systems you can do it like this:
```
sudo usermod -a -G dialout username
```
You will need to log-out and then log-in back again for this change to
take effect.
You can explicitly set one or more of the serial port settings to the
desired values using picocom's command line options. For example, to
set the baud-rate to 115200bps (the default is 9600bps), and enable
hardware flow-control (RTS/CTS handshake) you can say:
```
picocom -b 115200 -f h /dev/ttyS0
```
or:
```
picocom --baud 115200 --flow h /dev/ttyS0
```
To see all available options run picocom like this:
```
picocom --help
```
Once picocom starts, it initializes the serial port and prints the
message:
```
Terminal is ready
```
From now on, every character you type is sent to the serial port, and
every character received from the serial port is sent ro your
terminal. Including control and special characters. Assuming that
there is nothing connected to the other end of your serial port, to
respond to the characters you send it (e.g. echo them back to you),
then nothing that you type in picocom will appear on your
terminal. This is normal.
To exit picocom you have to type:
```
C-a, C-x
```
Which means you have to type [Conttol-A] followed by [Control-X]. You
can do this by pressing and holding down the [Control] key, then
pressing (and releasing) the [A] key and then pressing (and releasing)
the [X] key (while you still keep [Control] held down).
This `C-a` is called the "escape character". It is used to inform
picocom that the next character typed is to be interpreted as a
command to picocom itself (in this case the exit command) and not to
be sent-down to the serial port. There are several other commands
(other than `C-a`, `C-x`), all prefixed by `C-a`.
Next you should take a look at the very detailed picocom manual
page. It can be accessed like this (assuming you are inside the
picocom distribution source directory):
```
man ./picocom.8
```
or (assuming you have installed the manual page to a suitable place):
```
man picocom
```
Thanks for using picocom

168
fdio.c Normal file
View File

@ -0,0 +1,168 @@
/* vi: set sw=4 ts=4:
*
* fdio.c
*
* Functions for doing I/O on file descriptors.
*
* 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 <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <unistd.h>
#include <errno.h>
#include <stdarg.h>
/**********************************************************************/
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);
}
/**********************************************************************/
#ifndef LINENOISE
static int
cput(int fd, char c)
{
return write(fd, &c, 1);
}
static int
cdel (int fd)
{
const char del[] = "\b \b";
return write(fd, del, sizeof(del) - 1);
}
static int
xput (int fd, unsigned char c)
{
const char hex[] = "0123456789abcdef";
char b[4];
b[0] = '\\'; b[1] = 'x'; b[2] = hex[c >> 4]; b[3] = hex[c & 0x0f];
return write(fd, b, sizeof(b) - 1);
}
static int
xdel (int fd)
{
const char del[] = "\b\b\b\b \b\b\b\b";
return write(fd, del, sizeof(del) - 1);
}
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 = -1; goto out; }
switch (c) {
case '\b':
case '\x7f':
if ( bp > (unsigned char *)b ) {
bp--;
if ( isprint(*bp) )
cdel(fdo);
else
xdel(fdo);
} else {
cput(fdo, '\x07');
}
break;
case '\x03': /* CTRL-c */
r = -1;
errno = EINTR;
goto out;
case '\r':
*bp = '\0';
r = bp - (unsigned char *)b;
goto out;
default:
if ( bp < bpe ) {
*bp++ = c;
if ( isprint(c) )
cput(fdo, c);
else
xput(fdo, c);
} else {
cput(fdo, '\x07');
}
break;
}
}
out:
return r;
}
#endif /* of LINENOISE */
/**********************************************************************/
/*
* Local Variables:
* mode:c
* tab-width: 4
* c-basic-offset: 4
* indent-tabs-mode: nil
* End:
*/

48
fdio.h Normal file
View File

@ -0,0 +1,48 @@
/* vi: set sw=4 ts=4:
*
* fdio.h
*
* Functions for doing I/O on file descriptors.
*
* 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
*/
#ifndef FDIO_H
ssize_t writen_ni(int fd, const void *buff, size_t n);
int fd_printf (int fd, const char *format, ...);
#ifndef LINENOISE
int fd_readline (int fdi, int fdo, char *b, int bsz);
#endif
#endif /* of FDIO_H */
/**********************************************************************/
/*
* Local Variables:
* mode:c
* tab-width: 4
* c-basic-offset: 4
* indent-tabs-mode: nil
* End:
*/

View File

@ -756,7 +756,12 @@ static int linenoiseEdit(int stdin_fd, int stdout_fd, char *buf, size_t buflen,
char seq[3];
nread = read(l.ifd,&c,1);
if (nread <= 0) return l.len;
if (nread < 0) {
return nread;
} else if (nread == 0) {
errno = EAGAIN;
return -1;
}
/* Only autocomplete when the callback is set. It returns < 0 when
* there was an error reading from fd. Otherwise it will return the

View File

@ -5,17 +5,17 @@ picocom \- minimal dumb-terminal emulation program
\fBpicocom [ \fIoptions\fB ] \fIdevice\fB
\f1
.SH DESCRIPTION
As its name suggests, picocom is a minimal dumb-terminal emulation program. It is, in principle, very much like \fBminicom(1)\f1, 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.
As its name suggests, picocom is a minimal dumb-terminal emulation program. It is, in principle, very much like \fBminicom(1)\f1, 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 serial communications program to allow access to all types of devices that provide serial consoles. 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 \fI--noinit\f1 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 \fI--noinit\f1 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.
When picocom starts it opens the terminal (serial device) given as its non-option argument. Unless the \fB--noinit\f1 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 \fB--noinit\f1 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.
.SH 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.
[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.
[C-x]: Exit the program: if the \fI--noreset\f1 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-x]: Exit the program: if the \fB--noreset\f1 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 \fI--noreset\f1 option.
[C-q]: Quit the program *without* reseting the serial port, regardless of the \fB--noreset\f1 option.
[C-p]: Pulse the DTR line. Lower it for 1 sec, and then raise it again.
@ -33,9 +33,13 @@ Commands are given to picocom by first keying the "espace character" which by de
[C-b]: Cycle through databits-number settings (5, 6, 7, 8).
[C-j]: Cycle through stopbits-number settings (1, 2).
[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-v]: Show program options (like baud rate, data bits, etc) as well as the actual serial port settings. Only the options and port settings that can be modified online (through commands) are shown, not those that can only be set at the command-line. If an actual port setting is different than the current value of the respective option (for whatever reason) then the value of the option is shown, followed by the value of the actual port setting in parenthesis. Example: "*** baud: 115200 (9600)". This means that a baud rate of 115200bps has been selected (from the command line, or using commands) but the serial port is actually operating at 9600bps (the driver may not support the higher setting, and has silently replaced it with a safe default, or the setting may have been changed from outside picocom). If the option and the corresponding port setting are the same, only a single value is shown. Example: "*** baud: 9600".
[C-h] or [C-k]: Show help or show keys. Prints a short description of all available function (command) keys.
[C-s]: Send (upload) a file (see "Sending and Receiving Files" below)
@ -46,6 +50,8 @@ After performing one of the above operations the program leaves the command mode
C-a, C-u, C-a, C-u
assuming of-course that "C-a" is the escape character.
Commands that change program options ([C-u], [C-d], [C-f], etc) also display a message showing the new option value. If the new option value cannot be applied succesfully to the serial port (for whatever reason), then the respective actual current port setting is also shown. See the description of the [C-v] command, above, for more on this.
.SH 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:
@ -63,13 +69,17 @@ picocom can send and receive files over the serial port using external programs
\fBascii-xfr(1)\f1 - 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 \fI--send-cmd\f1 option. Similarly the program to receive files, and its argumets, are given by the \fI--receive-cmd\f1 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:
The name of, and the command-line options to, the program to be used for transmitting files are given by the \fB--send-cmd\f1 option. Similarly the program to receive files, and its argumets, are given by the \fB--receive-cmd\f1 option. For example, in order to start a picocom session that uses "sz" to transmit files, and "rz" to receive files, 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. Command-line editing and pathname completion are available at this prompt, if you have compiled picocom with support for the linenoise library. Pressing 'C-c' at this prompt will cancel the file transfer command and return to normal picocom operation. After entering a filename (and / or additional transmission or reception program arguments) and assuming you have not canceled the operation by pressing C-c, picocom will start the the external program as specified by the \fI--send-cmd\f1, or \fI--receive-cmd\f1 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.
If the argument to the \fB--send-cmd\f1 option, or the argument to the \fB--receive-cmd\f1 option is the empty string, then the respective command is disabled. For example, in order to disable both the "send" and the "receive" commands you can invoke picocom like this:
picocom --send-cmd '' --receive-cmd ''
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. Command-line editing and pathname completion are available at this prompt, if you have compiled picocom with support for the linenoise library. Pressing 'C-c' at this prompt will cancel the file transfer command and return to normal picocom operation. After entering a filename (and / or additional transmission or reception program arguments) and assuming you have not canceled the operation by pressing C-c, picocom will start the the external program as specified by the \fB--send-cmd\f1, or \fB--receive-cmd\f1 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.
.SH INPUT, OUTPUT, AND ECHO MAPPING
Using the \fI--imap\f1, \fI--omap\f1, and \fI--emap\f1 options you can make picocom map (tranlate, replace) certain special characters after being read from the serial port (with \fI--imap\f1), before being written to the serial port (with \fI--omap\f1), and before being locally echoed to the terminal (standard output) if local echo is enabled (with \fI--emap\f1). 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)
Using the \fB--imap\f1, \fB--omap\f1, and \fB--emap\f1 options you can make picocom map (tranlate, replace) certain special characters after being read from the serial port (with \fB--imap\f1), before being written to the serial port (with \fB--omap\f1), and before being locally echoed to the terminal (standard output) if local echo is enabled (with \fB--emap\f1). 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:
@ -91,26 +101,29 @@ picocom accepts the following command-line options
\fB--databits | -d
\f1Defines the number of data bits in every character. Must be one of: 5, 6, 7, 8. (Default: 8)
.TP
\fB--stopbits | -p
\f1Defines the number of stop bits in every character. Must be one of: 1, or 2. (Default: 1)
.TP
\fB--esacpe | -e
\f1Defines 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')
.TP
\fB--echo | -c
\f1Enable 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 \fI--emap\f1 option. (Default: Disabled)
\f1Enable 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 \fB--emap\f1 option. (Default: Disabled)
.TP
\fB--noinit | -i
\f1If 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.
.TP
\fB--noreset | -r
\f1If 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 \fI--noreset\f1 option is given the user can exit picocom using the "Quit" command (instead of "Exit"), which never resets the serial port. If \fI--noreset\f1 is given then "Quit" and "Exit" behave essentially the same.
\f1If 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 \fB--noreset\f1 option is given the user can exit picocom using the "Quit" command (instead of "Exit"), which never resets the serial port. If \fB--noreset\f1 is given then "Quit" and "Exit" behave essentially the same.
.TP
\fB--nolock | -l
\f1If 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.
\f1If given, picocom will *not* attempt to lock the serial port before opening it. Normally, depending on how it's compiled, picocom attempts to get a UUCP-style lock-file (e.g. "/var/lock/LCK..ttyS0") before opening the port, or attempts to lock the port device-node using \fBflock(2)\f1. Failing to do so, results in the program exiting after emitting an error-message. It is possible that your picocom binary is compiled without support for locking. In this case the \fB--nolock\f1 option is accepted, but has no effect.
.TP
\fB--send-cmd | -s
\f1Specifies the external program (and any arguments to it) that will be used for transmitting files. (Default: "sz -vv")
\f1Specifies the external program (and any arguments to it) that will be used for transmitting files. If the argument to \fB--send-cmd\f1 is the empty string (''), the send-file command is disabled. (Default: "sz -vv")
.TP
\fB--receive-cmd | -v
\f1Specifies the external program (and any arguments to it) that will be used for receiving files. (Default: "rz -vv")
\f1Specifies the external program (and any arguments to it) that will be used for receiving files. If the argument to \fB--receive-cmd\f1 is the empty string (''), the receive-file command is disabled. (Default: "rz -vv")
.TP
\fB--imap
\f1Specifies the input character map (i.e. special characters to be replaced when read from the serial port). Example: "--imap crlf,delbs". (Defaul: Empty)
@ -122,8 +135,8 @@ picocom accepts the following command-line options
\f1Specifies 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)
.TP
\fB--help | -h
\f1Print a short help message describing the command-line options.
\f1Print a short help message describing the command-line options. picocom's version, compile-time options, and enabled features are also shown.
.SH AUTHOR
picocom was written by Nick Patavalis (npat@efault.net)
.SH AVAILABILITY
The latest version of "picocom" can be downloaded from: \fBhttps://github.com/npat-efault/picocom/releases\f1
The latest release of "picocom" can be downloaded from: \fBhttps://github.com/npat-efault/picocom/releases\f1

View File

@ -14,25 +14,23 @@
<p>
As its name suggests, picocom is a minimal
dumb-terminal emulation program. It is, in principle, very much
like <b>minicom (1)</b>, only it's &quot;pico&quot;
instead of &quot;mini&quot;! 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 &quot;terminal-window&quot; to allow
operator intervention in PPP connection scripts (something like
the ms-windows &quot;open terminal window before / after dialing&quot;
feature). It could also prove useful in many other similar
As its name suggests, picocom is a minimal dumb-terminal
emulation program. It is, in principle, very much like <b>minicom (1)</b>, only it's &quot;pico&quot; instead of
&quot;mini&quot;! 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 serial communications program to
allow access to all types of devices that provide serial
consoles. It could also prove useful in many other similar
tasks.
</p>
<p>
When picocom starts it opens the terminal (serial
device) given as its non-option argument. Unless the
<em>--noinit</em> option is given, it configures the device to
<b>--noinit</b> option is given, it configures the device to
the settings specified by the option-arguments (or to some
default settings), and sets it to &quot;raw&quot; mode. If
<em>--noinit</em> is given, the initialization and
<b>--noinit</b> 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
@ -66,20 +64,18 @@
and return to &quot;transparent&quot; mode. This means that if the escape
character (&quot;C-a&quot;, 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.
transparent mode.
</p>
<p>
[C-x]: Exit the program: if the <em>--noreset</em> option was
[C-x]: Exit the program: if the <b>--noreset</b> 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.
</p>
<p>
[C-q]: Quit the program *without* reseting the serial port,
regardless of the <em>--noreset</em> option.
regardless of the <b>--noreset</b> option.
</p>
<p>
@ -129,15 +125,35 @@
[C-b]: Cycle through databits-number settings (5, 6, 7, 8).
</p>
<p>
[C-j]: Cycle through stopbits-number settings (1, 2).
</p>
<p>
[C-c]: Toggle local-echo mode.
</p>
<p>
[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-v]: Show program options (like baud rate, data bits, etc) as
well as the actual serial port settings. Only the options and
port settings that can be modified online (through commands) are
shown, not those that can only be set at the command-line. If an
actual port setting is different than the current value of the
respective option (for whatever reason) then the value of the
option is shown, followed by the value of the actual port
setting in parenthesis. Example: &quot;*** baud: 115200 (9600)&quot;. This
means that a baud rate of 115200bps has been selected (from the
command line, or using commands) but the serial port is actually
operating at 9600bps (the driver may not support the higher
setting, and has silently replaced it with a safe default, or
the setting may have been changed from outside picocom). If the
option and the corresponding port setting are the same, only a
single value is shown. Example: &quot;*** baud: 9600&quot;.
</p>
<p>
[C-h] or [C-k]: Show help or show keys. Prints a short
description of all available function (command) keys.
</p>
<p>
@ -161,6 +177,16 @@
<p>
assuming of-course that &quot;C-a&quot; is the escape character.
</p>
<p>
Commands that change program options ([C-u], [C-d], [C-f], etc)
also display a message showing the new option value. If the new
option value cannot be applied succesfully to the serial port
(for whatever reason), then the respective actual current port
setting is also shown. See the description of the [C-v] command,
above, for more on this.
</p>
@ -190,17 +216,29 @@
<p>
The name of, and the command-line options to, the program to be
used for transmitting files are given by the
<em>--send-cmd</em> option. Similarly the program to receive
<b>--send-cmd</b> option. Similarly the program to receive
files, and its argumets, are given by the
<em>--receive-cmd</em> option. For example, in order to start
<b>--receive-cmd</b> option. For example, in order to start
a picocom session that uses &quot;sz&quot; to transmit files, and
&quot;rz&quot; to receive, you have to say something like this:
&quot;rz&quot; to receive files, you have to say something like this:
</p>
<p>
picocom --send-cmd &quot;sz -vv&quot; --receive-cmd &quot;rz -vv&quot;
</p>
<p>
If the argument to the <b>--send-cmd</b> option, or the
argument to the <b>--receive-cmd</b> option is the empty
string, then the respective command is disabled. For example, in
order to disable both the &quot;send&quot; and the &quot;receive&quot; commands you
can invoke picocom like this:
</p>
<p>
picocom --send-cmd '' --receive-cmd ''
</p>
<p>
During the picocom session, if you key the &quot;send&quot; or &quot;receive&quot;
commands (e.g. by pressing C-a, C-s, or C-a, C-r) you will be
@ -215,7 +253,7 @@
transmission or reception program arguments) and assuming you
have not canceled the operation by pressing C-c, picocom will
start the the external program as specified by the
<em>--send-cmd</em>, or <em>--receive-cmd</em> option, and
<b>--send-cmd</b>, or <b>--receive-cmd</b> 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
@ -233,13 +271,13 @@
<h2>INPUT, OUTPUT, AND ECHO MAPPING</h2>
<p>
Using the <em>--imap</em>, <em>--omap</em>, and
<em>--emap</em> options you can make picocom map
Using the <b>--imap</b>, <b>--omap</b>, and
<b>--emap</b> options you can make picocom map
(tranlate, replace) certain special characters after being read
from the serial port (with <em>--imap</em>), before being
written to the serial port (with <em>--omap</em>), and before
from the serial port (with <b>--imap</b>), before being
written to the serial port (with <b>--omap</b>), and before
being locally echoed to the terminal (standard output) if local
echo is enabled (with <em>--emap</em>). These mapping options
echo is enabled (with <b>--emap</b>). These mapping options
take, each, a single argument which is a comma-separated list of
one or more of the following identifiers: &quot;crlf&quot; (map CR to LF),
&quot;crcrlf&quot; (map CR to CR + LF), &quot;igncr&quot; (ignore CR), &quot;lfcr&quot; (map
@ -312,6 +350,16 @@
</p>
<b><p>--stopbits | -p</p></b>
<p>
Defines the number of stop bits in every character. Must be
one of: 1, or 2. (Default: 1)
</p>
<b><p>--esacpe | -e</p></b>
@ -331,7 +379,7 @@
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 <em>--emap</em> option. (Default: Disabled)
(see <b>--emap</b> option. (Default: Disabled)
</p>
@ -359,9 +407,9 @@
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 <em>--noreset</em> option is given the user can exit
the <b>--noreset</b> option is given the user can exit
picocom using the &quot;Quit&quot; command (instead of &quot;Exit&quot;),
which never resets the serial port. If <em>--noreset</em>
which never resets the serial port. If <b>--noreset</b>
is given then &quot;Quit&quot; and &quot;Exit&quot; behave essentially the same.
</p>
@ -372,12 +420,14 @@
<p>
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. &quot;/var/lock/LCK..ttyS0&quot;)
before opening the port. Failing to do so, results in the
serial port before opening it. Normally, depending on how
it's compiled, picocom attempts to get a UUCP-style
lock-file (e.g. &quot;/var/lock/LCK..ttyS0&quot;) before opening the
port, or attempts to lock the port device-node using <b>flock (2)</b>. 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.
possible that your picocom binary is compiled without
support for locking. In this case the <b>--nolock</b>
option is accepted, but has no effect.
</p>
@ -387,8 +437,9 @@
<p>
Specifies the external program (and any arguments to it)
that will be used for transmitting files. (Default: &quot;sz
-vv&quot;)
that will be used for transmitting files. If the argument to
<b>--send-cmd</b> is the empty string (''), the
send-file command is disabled. (Default: &quot;sz -vv&quot;)
</p>
@ -398,7 +449,9 @@
<p>
Specifies the external program (and any arguments to it)
that will be used for receiving files. (Default: &quot;rz -vv&quot;)
that will be used for receiving files. If the argument to
<b>--receive-cmd</b> is the empty string (''), the
receive-file command is disabled. (Default: &quot;rz -vv&quot;)
</p>
@ -442,7 +495,8 @@
<p>
Print a short help message describing the command-line
options.
options. picocom's version, compile-time options, and enabled
features are also shown.
</p>
@ -457,7 +511,7 @@
<h2>AVAILABILITY</h2>
<p>The latest version of &quot;picocom&quot; can be downloaded from: <a href = "https://github.com/npat-efault/picocom/releases">https://github.com/npat-efault/picocom/releases</a>
<p>The latest release of &quot;picocom&quot; can be downloaded from: <a href = "https://github.com/npat-efault/picocom/releases">https://github.com/npat-efault/picocom/releases</a>
</p>

View File

@ -1,11 +1,11 @@
%!PS-Adobe-3.0
%%Creator: groff version 1.22.2
%%CreationDate: Sat Aug 8 21:30:50 2015
%%CreationDate: Wed Aug 19 00:17:32 2015
%%DocumentNeededResources: font Times-Roman
%%+ font Times-Bold
%%+ font Times-Italic
%%DocumentSuppliedResources: procset grops 1.22 2
%%Pages: 4
%%Pages: 5
%%PageOrder: Ascend
%%DocumentMedia: Default 612 792 0 () ()
%%Orientation: Portrait
@ -246,25 +246,23 @@ imal dumb-terminal emulation program. It is, in principle, v)108 153.6 R
(ery)-.15 E 1.141(much lik)108 165.6 R(e)-.1 E F2(minicom\(1\))3.641 E
F0 3.641(,o)C 1.141(nly it')-3.641 F 3.641(s")-.55 G 1.141
(pico" instead of "mini"! It w)-3.641 F 1.141(as designed to serv)-.1 F
3.641(ea)-.15 G 3.642(sas)-3.641 G 1.142(imple, manual,)-3.642 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
3.641(ea)-.15 G 3.642(sas)-3.641 G 1.142(imple, manual,)-3.642 F .462
(modem con\214guration, testing, and deb)108 177.6 R .461
(ugging tool. It has also serv)-.2 F .461(ed \(quite well\) as a lo)-.15
F .461(w-tech serial com-)-.25 F .21(munications program to allo)108
189.6 R 2.71(wa)-.25 G .21(ccess to all types of de)-2.71 F .21
(vices that pro)-.25 F .21(vide serial consoles. It could also pro)-.15
F -.15(ve)-.15 G(useful in man)108 201.6 Q 2.5(yo)-.15 G
(ther similar tasks.)-2.5 E 1.563
(When picocom starts it opens the terminal \(serial de)108 225.6 R 1.563
(vice\) gi)-.25 F -.15(ve)-.25 G 4.063(na).15 G 4.062(si)-4.063 G 1.562
(ts non-option ar)-4.062 F 1.562(gument. Unless the)-.18 F F3(--noinit)
108 237.6 Q F0 1.376(option is gi)3.876 F -.15(ve)-.25 G 1.376
(n, it con\214gures the de).15 F 1.376
(vice to the settings speci\214ed by the option-ar)-.25 F 1.377
(guments \(or to)-.18 F .528(some def)108 249.6 R .527
(ault settings\), and sets it to "ra)-.1 F .527(w" mode. If)-.15 F F3
(--noinit)3.027 E F0 .527(is gi)3.027 F -.15(ve)-.25 G .527
(ts non-option ar)-4.062 F 1.562(gument. Unless the)-.18 F F2(--noinit)
108 237.6 Q F0 1.271(option is gi)3.771 F -.15(ve)-.25 G 1.272
(n, it con\214gures the de).15 F 1.272
(vice to the settings speci\214ed by the option-ar)-.25 F 1.272
(guments \(or to)-.18 F .429(some def)108 249.6 R .429
(ault settings\), and sets it to "ra)-.1 F .429(w" mode. If)-.15 F F2
(--noinit)2.929 E F0 .429(is gi)2.929 F -.15(ve)-.25 G .428
(n, the initialization and con\214guration is).15 F .746
(skipped; the de)108 261.6 R .746(vice is just opened. F)-.25 F(ollo)
-.15 E .747
@ -296,39 +294,35 @@ G 3.172(nh)-3.171 G 1.172 -.25(ow t)-3.172 H 3.172(oc).25 G .672
o the serial port and return to "transparent" mode. This)108 422.4 R .06
(means that if the escape character \("C-a", by def)108 434.4 R .06
(ault\) is typed twice, the program sends the escape character)-.1 F
.211(to the serial port, and remains in transparent mode. This is a ne)
108 446.4 R 2.71(wb)-.25 G(eha)-2.71 E .21
(vior implemented in v1.4. Pre)-.2 F(viously)-.25 E
(picocom used to ignore the escape-character when it w)108 458.4 Q
(as entered as a function character)-.1 E(.)-.55 E .34
([C-x]: Exit the program: if the)108 482.4 R F3(--nor)2.84 E(eset)-.37 E
F0 .34(option w)2.84 F .34(as not gi)-.1 F -.15(ve)-.25 G 2.84(nt).15 G
.34(hen the serial port is reset to its original set-)-2.84 F
(tings before e)108 494.4 Q(xiting; if it w)-.15 E(as gi)-.1 E -.15(ve)
(to the serial port, and remains in transparent mode.)108 446.4 Q .248
([C-x]: Exit the program: if the)108 470.4 R F2(--nor)2.748 E(eset)-.18
E F0 .248(option w)2.748 F .248(as not gi)-.1 F -.15(ve)-.25 G 2.747(nt)
.15 G .247(hen the serial port is reset to its original set-)-2.747 F
(tings before e)108 482.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
([C-q]: Quit the program *without* reseting the serial port, re)108
518.4 Q -.05(ga)-.15 G(rdless of the).05 E F3(--nor)2.5 E(eset)-.37 E F0
(option.)2.5 E([C-p]: Pulse the DTR line. Lo)108 542.4 Q
506.4 Q -.05(ga)-.15 G(rdless of the).05 E F2(--nor)2.5 E(eset)-.18 E F0
(option.)2.5 E([C-p]: Pulse the DTR line. Lo)108 530.4 Q
(wer it for 1 sec, and then raise it ag)-.25 E(ain.)-.05 E([C-t]: T)108
566.4 Q(oggle the DTR line. If DTR is up, then lo)-.8 E
554.4 Q(oggle 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 1.66([C-backslash\
]: Generate a break sequence on the serial line. A break sequence is us\
ually generated by)108 590.4 R .471(marking \(dri)108 602.4 R .471(ving\
ually generated by)108 578.4 R .472(marking \(dri)108 590.4 R .471(ving\
to logical one\) the serial Tx line for an amount of time coresponding\
to se)-.25 F -.15(ve)-.25 G .472(ral character).15 F(durations.)108
614.4 Q .442([C-u]: Baud up. Increase the baud-rate. The list of baud-r\
ates stepped-through by this command is: 50, 75,)108 638.4 R .044(110, \
to se)-.25 F -.15(ve)-.25 G .471(ral character).15 F(durations.)108
602.4 Q .442([C-u]: Baud up. Increase the baud-rate. The list of baud-r\
ates stepped-through by this command is: 50, 75,)108 626.4 R .044(110, \
134, 150, 200, 300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 1\
15200. If HIGH_B)108 650.4 R -.55(AU)-.35 G 2.544(Ds).55 G(up-)-2.544 E
1.705(port is compiled in, then the follo)108 662.4 R 1.705
15200. If HIGH_B)108 638.4 R -.55(AU)-.35 G 2.543(Ds).55 G(up-)-2.543 E
1.705(port is compiled in, then the follo)108 650.4 R 1.705
(wing baud-rates are also added to the list: 230400, 460800, 500000,)
-.25 F .757(576000, 921600, 1000000, 1152000, 1500000, 2000000, 2500000\
, 3000000, 3500000, 4000000. Depend-)108 674.4 R(ing on you system, an)
108 686.4 Q 2.5(yo)-.15 G 2.5(ft)-2.5 G
(he higher baud rates may be missing.)-2.5 E .656([C-d]: Baud do)108
710.4 R .655(wn. Decrease the baud-rate. The list of baud-rates stepped\
, 3000000, 3500000, 4000000. Depend-)108 662.4 R(ing on you system, an)
108 674.4 Q 2.5(yo)-.15 G 2.5(ft)-2.5 G
(he higher baud rates may be missing.)-2.5 E .655([C-d]: Baud do)108
698.4 R .655(wn. Decrease the baud-rate. The list of baud-rates stepped\
-through by this command is the)-.25 F
(same as for the "baud-up" command.)108 722.4 Q 187.62(Manuals User)72
(same as for the "baud-up" command.)108 710.4 Q 187.62(Manuals User)72
768 R(1)219.56 E 0 Cg EP
%%Page: 2 2
%%BeginPageSetup
@ -341,206 +335,274 @@ E 2.5(sM)-.55 G 131.795(anual picocom\(8\))-2.5 F
([C-y]: Cycle through parity settings \(e)108 108 Q -.15(ve)-.25 G
(n, odd, none\).).15 E
([C-b]: Cycle through databits-number settings \(5, 6, 7, 8\).)108 132 Q
([C-c]: T)108 156 Q(oggle local-echo mode.)-.8 E .728([C-v]: Sho)108 180
R 3.228(wp)-.25 G .728(rogram options \(lik)-3.228 F 3.229(eb)-.1 G .729
(aud rate, data bits, etc\). Only the options that can be modi\214ed on\
line)-3.229 F(\(through commands\) are sho)108 192 Q
(wn, not those that can only be set at the command-line.)-.25 E
([C-s]: Send \(upload\) a \214le \(see "Sending and Recei)108 216 Q
(ving Files" belo)-.25 E(w\))-.25 E([C-r]: Recei)108 240 Q .3 -.15
([C-j]: Cycle through stopbits-number settings \(1, 2\).)108 156 Q
([C-c]: T)108 180 Q(oggle local-echo mode.)-.8 E .674([C-v]: Sho)108 204
R 3.174(wp)-.25 G .674(rogram options \(lik)-3.174 F 3.174(eb)-.1 G .674
(aud rate, data bits, etc\) as well as the actual serial port settings.\
Only)-3.174 F .2(the options and port settings that can be modi\214ed \
online \(through commands\) are sho)108 216 R .2(wn, not those that can)
-.25 F .158
(only be set at the command-line. If an actual port setting is dif)108
228 R .157(ferent than the current v)-.25 F .157(alue of the respecti)
-.25 F -.15(ve)-.25 G .358(option \(for whate)108 240 R -.15(ve)-.25 G
2.858(rr).15 G .358(eason\) then the v)-2.858 F .358
(alue of the option is sho)-.25 F .359(wn, follo)-.25 F .359
(wed by the v)-.25 F .359(alue of the actual port)-.25 F .278(setting i\
n parenthesis. Example: "*** baud: 115200 \(9600\)". This means that a \
baud rate of 115200bps has)108 252 R 1.652
(been selected \(from the command line, or using commands\) b)108 264 R
1.652(ut the serial port is actually operating at)-.2 F .76
(9600bps \(the dri)108 276 R -.15(ve)-.25 G 3.26(rm).15 G .759(ay not s\
upport the higher setting, and has silently replaced it with a safe def)
-3.26 F .759(ault, or)-.1 F .341(the setting may ha)108 288 R .642 -.15
(ve b)-.2 H .342(een changed from outside picocom\). If the option and \
the corresponding port setting).15 F(are the same, only a single v)108
300 Q(alue is sho)-.25 E(wn. Example: "*** baud: 9600".)-.25 E 1.402
([C-h] or [C-k]: Sho)108 324 R 3.902(wh)-.25 G 1.401(elp or sho)-3.902 F
3.901(wk)-.25 G -.15(ey)-4.001 G 1.401
(s. Prints a short description of all a).15 F -.25(va)-.2 G 1.401
(ilable function \(command\)).25 F -.1(ke)108 336 S(ys.)-.05 E
([C-s]: Send \(upload\) a \214le \(see "Sending and Recei)108 360 Q
(ving Files" belo)-.25 E(w\))-.25 E([C-r]: Recei)108 384 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 264 R .354 -.15(ve o)-.15 H .054
(After performing one of the abo)108 408 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
276 Q 2.5(oi)-.8 G(ncrease the baud-rate by tw)-2.5 E 2.5(os)-.1 G
420 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 300 Q
(assuming of-course that "C-a" is the escape character)108 324 Q(.)-.55
E/F1 10.95/Times-Bold@0 SF(SENDING AND RECEIVING FILES)72 340.8 Q F0
.496(picocom can send and recei)108 352.8 R .796 -.15(ve \214)-.25 H
.496(les o).15 F -.15(ve)-.15 G 2.996(rt).15 G .496
(he serial port using e)-2.996 F .497
(xternal programs that implement the respec-)-.15 F(ti)108 364.8 Q .3
-.15(ve p)-.25 H
(C-a, C-u, C-a, C-u)108 444 Q
(assuming of-course that "C-a" is the escape character)108 468 Q(.)-.55
E .505(Commands that change program options \([C-u], [C-d], [C-f], etc\
\) also display a message sho)108 492 R .504(wing the ne)-.25 F(w)-.25 E
.37(option v)108 504 R .37(alue. If the ne)-.25 F 2.87(wo)-.25 G .37
(ption v)-2.87 F .371
(alue cannot be applied succesfully to the serial port \(for whate)-.25
F -.15(ve)-.25 G 2.871(rr).15 G(eason\),)-2.871 E 1.316
(then the respecti)108 516 R 1.616 -.15(ve a)-.25 H 1.316
(ctual current port setting is also sho).15 F 1.315
(wn. See the description of the [C-v] command,)-.25 F(abo)108 528 Q -.15
(ve)-.15 G 2.5(,f).15 G(or more on this.)-2.5 E/F1 10.95/Times-Bold@0 SF
(SENDING AND RECEIVING FILES)72 544.8 Q F0 .496
(picocom can send and recei)108 556.8 R .796 -.15(ve \214)-.25 H .496
(les o).15 F -.15(ve)-.15 G 2.996(rt).15 G .496(he serial port using e)
-2.996 F .497(xternal programs that implement the respec-)-.15 F(ti)108
568.8 Q .3 -.15(ve p)-.25 H
(rotocols. In Linux typical programs for this purpose are:).15 E/F2 10
/Times-Bold@0 SF(rx\(1\))108 388.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 F2(rb\(1\))108 412.8 Q F0
/Times-Bold@0 SF(rx\(1\))108 592.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 F2(rb\(1\))108 616.8 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 F2(rz\(1\))108 436.8 Q F0 2.5(-r)2.5 G(ecei)
(-MODEM protocol)-1.11 E F2(rz\(1\))108 640.8 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 F2(sx\(1\))
108 460.8 Q F0 2.5(-s)2.5 G(end using the X-MODEM protocol)-2.5 E F2
(sb\(1\))108 484.8 Q F0 2.5(-s)2.5 G(end using the Y)-2.5 E
(-MODEM protocol)-1.11 E F2(sz\(1\))108 508.8 Q F0 2.5(-s)2.5 G
(end using the Z-MODEM protocol)-2.5 E F2(ascii-xfr\(1\))108 532.8 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 op\
tions to, the program to be used for transmitting \214les are gi)108
556.8 R -.15(ve)-.25 G 3.191(nb).15 G(y)-3.191 E(the)108 568.8 Q/F3 10
/Times-Italic@0 SF(--send-cmd)3.148 E F0 .649
(option. Similarly the program to recei)3.148 F .949 -.15(ve \214)-.25 H
.649(les, and its ar).15 F .649(gumets, are gi)-.18 F -.15(ve)-.25 G
3.149(nb).15 G 3.149(yt)-3.149 G(he)-3.149 E F3(--r)3.149 E(eceive-)-.37
E(cmd)108 580.8 Q F0 1.136(option. F)3.636 F 1.136(or e)-.15 F 1.135(xa\
mple, in order to start a picocom session that uses "sz" to transmit \
\214les, and "rz" to)-.15 F(recei)108 592.8 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 616.8 Q
-.15(ve)-.25 G(-cmd "rz -vv").15 E .309
(During the picocom session, if you k)108 640.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 652.8 R(y)-.15 E .532(additional ar)108
664.8 R .533(guments to the transmission or reception program. Command-\
line editing and pathname com-)-.18 F .983(pletion are a)108 676.8 R
-.25(va)-.2 G .983(ilable at this prompt, if you ha).25 F 1.282 -.15
(ve c)-.2 H .982(ompiled picocom with support for the linenoise library)
.15 F(.)-.65 E .077(Pressing 'C-c' at this prompt will cancel the \214l\
e transfer command and return to normal picocom operation.)108 688.8 R
.597(After entering a \214lename \(and / or additional transmission or \
reception program ar)108 700.8 R .597(guments\) and assuming)-.18 F .478
(you ha)108 712.8 R .778 -.15(ve n)-.2 H .479(ot canceled the operation\
by pressing C-c, picocom will start the the e).15 F .479
(xternal program as speci-)-.15 F .352(\214ed by the)108 724.8 R F3
(--send-cmd)2.852 E F0 2.852(,o)C(r)-2.852 E F3(--r)2.852 E(eceive-cmd)
-.37 E F0 .352(option, and with an)2.852 F 2.852<798c>-.15 G .352
(lenames and additional ar)-2.852 F .352(guments you may)-.18 F 187.62
(Manuals User)72 768 R(2)219.56 E 0 Cg EP
108 664.8 Q F0 2.5(-s)2.5 G(end using the X-MODEM protocol)-2.5 E F2
(sb\(1\))108 688.8 Q F0 2.5(-s)2.5 G(end using the Y)-2.5 E
(-MODEM protocol)-1.11 E F2(sz\(1\))108 712.8 Q F0 2.5(-s)2.5 G
(end using the Z-MODEM protocol)-2.5 E 187.62(Manuals User)72 768 R(2)
219.56 E 0 Cg EP
%%Page: 3 3
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Times-Roman@0 SF 131.795(picocom\(8\) System)72 48 R(Manager')2.5
E 2.5(sM)-.55 G 131.795(anual picocom\(8\))-2.5 F(ha)108 84 Q 1.022 -.15
(ve s)-.2 H .723(upplied. The standard input and output of the e).15 F
.723(xternal program will be connected to the serial port.)-.15 F .523
(The standard error of the e)108 96 R .522(xternal program will be conn\
ected to the terminal which---while the program is)-.15 F .683
(running---will re)108 108 R -.15(ve)-.25 G .683
(rt to canonical mode. Pressing 'C-c' while the e).15 F .684
(xternal program is running will prema-)-.15 F .03(turely terminate it,\
and return control to picocom. Pressing 'C-c' at an)108 120 R 2.529(yo)
-.15 G .029(ther time, has no special ef)-2.529 F .029(fect; the)-.25 F
(character is normally passed to the serial port.)108 132 Q/F1 10.95
/Times-Bold@0 SF(INPUT)72 148.8 Q 2.738(,O)-.81 G(UTPUT)-2.738 E 2.738
(,A)-.81 G(ND ECHO MAPPING)-2.738 E F0 .036(Using the)108 160.8 R/F2 10
/Times-Italic@0 SF(--imap)2.536 E F0(,)A F2(--omap)2.536 E F0 2.536(,a)C
(nd)-2.536 E F2(--emap)2.536 E F0 .036(options you can mak)2.536 F 2.536
(ep)-.1 G .036(icocom map \(tranlate, replace\) certain special)-2.536 F
.778(characters after being read from the serial port \(with)108 172.8 R
F2(--imap)3.278 E F0 .777
(\), before being written to the serial port \(with)B F2(--omap)108
184.8 Q F0 1.051(\), and before being locally echoed to the terminal \(\
standard output\) if local echo is enabled \(with)B F2(--emap)108 196.8
Q F0 .895(\). These mapping options tak)B .895(e, each, a single ar)-.1
F .894(gument which is a comma-separated list of one or)-.18 F .984
(more of the follo)108 208.8 R .985(wing identi\214ers: "crlf" \(map CR\
to LF\), "crcrlf" \(map CR to CR + LF\), "igncr" \(ignore)-.25 F .197(\
CR\), "lfcr" \(map LF to CR\), "lfcrlf" \(map LF to CR + LF\), "ignlf" \
\(ignore LF\), "bsdel" \(map BS --> DEL\),)108 220.8 R
("delbs" \(map DEL --> BS\))108 232.8 Q -.15(Fo)108 256.8 S 2.5(re).15 G
(xample the command:)-2.65 E
E 2.5(sM)-.55 G 131.795(anual picocom\(8\))-2.5 F/F1 10/Times-Bold@0 SF
(ascii-xfr\(1\))108 84 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 com\
mand-line options to, the program to be used for transmitting \214les a\
re gi)108 108 R -.15(ve)-.25 G 3.191(nb).15 G(y)-3.191 E(the)108 120 Q
F1(--send-cmd)2.905 E F0 .405(option. Similarly the program to recei)
2.905 F .706 -.15(ve \214)-.25 H .406(les, and its ar).15 F .406
(gumets, are gi)-.18 F -.15(ve)-.25 G 2.906(nb).15 G 2.906(yt)-2.906 G
(he)-2.906 E F1(--r)2.906 E(ecei)-.18 E -.1(ve)-.1 G(-).1 E(cmd)108 132
Q F0 1.048(option. F)3.548 F 1.048(or e)-.15 F 1.047(xample, in order t\
o start a picocom session that uses "sz" to transmit \214les, and "rz" \
to)-.15 F(recei)108 144 Q .3 -.15(ve \214)-.25 H(les, you ha).15 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 168 Q -.15(ve)-.25 G
(-cmd "rz -vv").15 E .377(If the ar)108 192 R .377(gument to the)-.18 F
F1(--send-cmd)2.877 E F0 .377(option, or the ar)2.877 F .377
(gument to the)-.18 F F1(--r)2.877 E(ecei)-.18 E -.1(ve)-.1 G(-cmd).1 E
F0 .377(option is the empty string,)2.877 F .191(then the respecti)108
204 R .491 -.15(ve c)-.25 H .191(ommand is disabled. F).15 F .191(or e)
-.15 F .19(xample, in order to disable both the "send" and the "recei)
-.15 F -.15(ve)-.25 G(").15 E(commands you can in)108 216 Q -.2(vo)-.4 G
.2 -.1(ke p).2 H(icocom lik).1 E 2.5(et)-.1 G(his:)-2.5 E
(picocom --send-cmd ')108 240 Q 2.5('-)-.74 G(-recei)-2.5 E -.15(ve)-.25
G(-cmd ').15 E(')-.74 E .309(During the picocom session, if you k)108
264 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 276 R(y)-.15 E .532
(additional ar)108 288 R .533(guments to the transmission or reception \
program. Command-line editing and pathname com-)-.18 F .983
(pletion are a)108 300 R -.25(va)-.2 G .983
(ilable at this prompt, if you ha).25 F 1.282 -.15(ve c)-.2 H .982
(ompiled picocom with support for the linenoise library).15 F(.)-.65 E
.077(Pressing 'C-c' at this prompt will cancel the \214le transfer comm\
and and return to normal picocom operation.)108 312 R .597(After enteri\
ng a \214lename \(and / or additional transmission or reception program\
ar)108 324 R .597(guments\) and assuming)-.18 F .478(you ha)108 336 R
.778 -.15(ve n)-.2 H .479(ot canceled the operation by pressing C-c, pi\
cocom will start the the e).15 F .479(xternal program as speci-)-.15 F
1.389(\214ed by the)108 348 R F1(--send-cmd)3.889 E F0 3.889(,o)C(r)
-3.889 E F1(--r)3.889 E(ecei)-.18 E -.1(ve)-.1 G(-cmd).1 E F0 1.389
(option, and with an)3.889 F 3.888<798c>-.15 G 1.388
(lenames and additional ar)-3.888 F 1.388(guments you)-.18 F .804
(may ha)108 360 R 1.104 -.15(ve s)-.2 H .805
(upplied. The standard input and output of the e).15 F .805
(xternal program will be connected to the serial)-.15 F .853
(port. The standard error of the e)108 372 R .852(xternal program will \
be connected to the terminal which---while the pro-)-.15 F .544
(gram is running---will re)108 384 R -.15(ve)-.25 G .545
(rt to canonical mode. Pressing 'C-c' while the e).15 F .545
(xternal program is running will)-.15 F 1.128(prematurely terminate it,\
and return control to picocom. Pressing 'C-c' at an)108 396 R 3.628(yo)
-.15 G 1.128(ther time, has no special)-3.628 F(ef)108 408 Q
(fect; the character is normally passed to the serial port.)-.25 E/F2
10.95/Times-Bold@0 SF(INPUT)72 424.8 Q 2.738(,O)-.81 G(UTPUT)-2.738 E
2.738(,A)-.81 G(ND ECHO MAPPING)-2.738 E F0 .442(Using the)108 436.8 R
F1(--imap)2.942 E F0(,)A F1(--omap)2.942 E F0 2.942(,a)C(nd)-2.942 E F1
(--emap)2.942 E F0 .443(options you can mak)2.943 F 2.943(ep)-.1 G .443
(icocom map \(tranlate, replace\) certain spe-)-2.943 F 1.072
(cial characters after being read from the serial port \(with)108 448.8
R F1(--imap)3.572 E F0 1.071
(\), before being written to the serial port)B(\(with)108 460.8 Q F1
(--omap)3.446 E F0 .946(\), and before being locally echoed to the term\
inal \(standard output\) if local echo is enabled)B(\(with)108 472.8 Q
F1(--emap)3.62 E F0 1.12(\). These mapping options tak)B 1.12
(e, each, a single ar)-.1 F 1.12
(gument which is a comma-separated list of)-.18 F 1.122
(one or more of the follo)108 484.8 R 1.123(wing identi\214ers: "crlf" \
\(map CR to LF\), "crcrlf" \(map CR to CR + LF\), "igncr")-.25 F .017(\
\(ignore CR\), "lfcr" \(map LF to CR\), "lfcrlf" \(map LF to CR + LF\),\
"ignlf" \(ignore LF\), "bsdel" \(map BS -->)108 496.8 R
(DEL\), "delbs" \(map DEL --> BS\))108 508.8 Q -.15(Fo)108 532.8 S 2.5
(re).15 G(xample the command:)-2.65 E
(picocom --omap crlf,delbs --imap inglf,bsdel --emap crcrlf ...)108
280.8 Q .86(will: Replace e)108 304.8 R -.15(ve)-.25 G .86(ry CR \(carr\
556.8 Q .86(will: Replace e)108 580.8 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 316.8 R .781(nal\) e)108 328.8 R -.15(ve)-.25 G
write to the termi-)108 592.8 R .781(nal\) e)108 604.8 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 340.8 R -.15(ve)-.25 G 1.42(ry CR character wi\
(with DEL. Replace e)108 616.8 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 352.8 Q F1(OPTIONS)72 369.6 Q F0
(picocom accepts the follo)108 381.6 Q(wing command-line options)-.25 E
/F3 10/Times-Bold@0 SF(--baud | -b)108 398.4 Q F0
(enabled\).)108 628.8 Q F2(OPTIONS)72 645.6 Q F0
(picocom accepts the follo)108 657.6 Q(wing command-line options)-.25 E
F1(--baud | -b)108 674.4 Q F0
(De\214nes the baud-rate to set the serial-port \(terminal\) to.)144
410.4 Q F3(--\215o)108 427.2 Q 2.5(w|-)-.1 G(f)-2.5 E F0 .33
(De\214nes the \215o)144 439.2 R .33(w-control mode to set the serial-p\
686.4 Q F1(--\215o)108 703.2 Q 2.5(w|-)-.1 G(f)-2.5 E F0 .33
(De\214nes the \215o)144 715.2 R .33(w-control mode to set the serial-p\
ort to. Must be one of: 'x' for xon/xof)-.25 F 2.83(f\()-.25 G(softw)
-2.83 E(are\))-.1 E(mode, 'h' for hardw)144 451.2 Q(are \215o)-.1 E 2.5
-2.83 E(are\))-.1 E(mode, 'h' for hardw)144 727.2 Q(are \215o)-.1 E 2.5
(wc)-.25 G(ontrol \(R)-2.5 E(TS/CTS\), 'n' for no \215o)-.6 E 2.5(wc)
-.25 G(ontrol. \(Def)-2.5 E(ault: 'n'\))-.1 E F3(--parity | -p)108 468 Q
F0 .685(De\214nes the parity mode to set the serial-port to. Must be on\
e of: 'o' for odd parity mode, 'e' for)144 480 R -2.15 -.25(ev e)144 492
T 2.5(np).25 G(arity mode, 'n' for no parity mode. \(Def)-2.5 E
(ault: 'n'\))-.1 E F3(--databits | -d)108 508.8 Q F0
(De\214nes the number of data bits in e)144 520.8 Q -.15(ve)-.25 G
(ry character).15 E 2.5(.M)-.55 G(ust be one of: 5, 6, 7, 8. \(Def)-2.5
E(ault: 8\))-.1 E F3(--esacpe | -e)108 537.6 Q F0 .329
(De\214nes the character that will mak)144 549.6 R 2.829(ep)-.1 G .329
(icocom enter command-mode \(see description abo)-2.829 F -.15(ve)-.15 G
.33(\). If 'x').15 F(is gi)144 561.6 Q -.15(ve)-.25 G
(n, then C-x will mak).15 E 2.5(ep)-.1 G
(icocom enter command mode. \(Def)-2.5 E(ault: 'a'\))-.1 E F3
(--echo | -c)108 578.4 Q F0 .602(Enable local echo. Ev)144 590.4 R .602
(ery character being read from the terminal \(standard input\) is echoe\
d to the)-.15 F .156(terminal \(standard output\) subject to the echo-m\
apping con\214guration \(see)144 602.4 R F2(--emap)2.657 E F0 .157
(option. \(Def)2.657 F(ault:)-.1 E(Disabled\))144 614.4 Q F3
(--noinit | -i)108 631.2 Q F0 .785(If gi)144 643.2 R -.15(ve)-.25 G .785
(n, picocom will not initialize, reset, or otherwise meddle with the se\
rial port at start-up. It).15 F 2.742
(will just open it. This is useful, for e)144 655.2 R 2.743
(xample, for connecting picocom to already-connected)-.15 F .038(modems\
, or already con\214gured ports without terminating the connection, or \
altering the settings. If)144 667.2 R(required serial port parameters c\
an then be adjusted at run-time by commands.)144 679.2 Q F3(--nor)108
696 Q(eset | -r)-.18 E F0 .396(If gi)144 708 R -.15(ve)-.25 G .396
(n, picocom will not *reset* the serial port when e).15 F .397
(xiting. It will just close the \214ledes and do)-.15 F .696
(nothing more. This is useful, for e)144 720 R .696(xample, for lea)-.15
F .696(ving modems connected when e)-.2 F .696(xiting picocom.)-.15 F
187.62(Manuals User)72 768 R(3)219.56 E 0 Cg EP
-.25 G(ontrol. \(Def)-2.5 E(ault: 'n'\))-.1 E 187.62(Manuals User)72 768
R(3)219.56 E 0 Cg EP
%%Page: 4 4
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Times-Roman@0 SF 131.795(picocom\(8\) System)72 48 R(Manager')2.5
E 2.5(sM)-.55 G 131.795(anual picocom\(8\))-2.5 F(Re)144 84 Q -.05(ga)
-.15 G .545(rdless whether the).05 F/F1 10/Times-Italic@0 SF(--nor)3.045
E(eset)-.37 E F0 .545(option is gi)3.045 F -.15(ve)-.25 G 3.045(nt).15 G
.545(he user can e)-3.045 F .546(xit picocom using the "Quit" com-)-.15
F .822(mand \(instead of "Exit"\), which ne)144 96 R -.15(ve)-.25 G
3.321(rr).15 G .821(esets the serial port. If)-3.321 F F1(--nor)3.321 E
(eset)-.37 E F0 .821(is gi)3.321 F -.15(ve)-.25 G 3.321(nt).15 G .821
(hen "Quit" and)-3.321 F("Exit" beha)144 108 Q .3 -.15(ve e)-.2 H
(ssentially the same.).15 E/F2 10/Times-Bold@0 SF(--nolock | -l)108
124.8 Q F0 .744(If gi)144 136.8 R -.15(ve)-.25 G .744(n, picocom will *\
not* attempt to lock the serial port before opening it. Normally picoco\
m).15 F .389(attempts to get a UUCP-style lock-\214le \(e.g. "/v)144
148.8 R .388(ar/lock/LCK..ttyS0"\) before opening the port. F)-.25 F
(ail-)-.15 E .294(ing to do so, results in the program e)144 160.8 R
.294(xiting after emitting an error)-.15 F .294
(-message. It is possible that your)-.2 F
(picocom binary is compiled without this option.)144 172.8 Q F2
(--send-cmd | -s)108 189.6 Q F0 1.102(Speci\214es the e)144 201.6 R
1.102(xternal program \(and an)-.15 F 3.601(ya)-.15 G -.18(rg)-3.601 G
1.101(uments to it\) that will be used for transmitting \214les.).18 F
(\(Def)144 213.6 Q(ault: "sz -vv"\))-.1 E F2(--r)108 230.4 Q(ecei)-.18 E
-.1(ve)-.1 G(-cmd | -v).1 E F0 1.86(Speci\214es the e)144 242.4 R 1.86
(xternal program \(and an)-.15 F 4.36(ya)-.15 G -.18(rg)-4.36 G 1.86
(uments to it\) that will be used for recei).18 F 1.86(ving \214les.)
-.25 F(\(Def)144 254.4 Q(ault: "rz -vv"\))-.1 E F2(--imap)108 271.2 Q F0
.575(Speci\214es the input character map \(i.e. special characters to b\
e replaced when read from the serial)144 271.2 R
(port\). Example: "--imap crlf,delbs". \(Def)144 283.2 Q(aul: Empty\))
-.1 E F2(--omap)108 300 Q F0 1.031(Speci\214es the output character map\
\(i.e. special characters to be replaced before being written to)144
300 R(serial port\). Example: "--omap crcrlf,bsdel". \(Def)144 312 Q
(aul: Empty\))-.1 E F2(--emap)108 328.8 Q F0 .408(Speci\214es the local\
E 2.5(sM)-.55 G 131.795(anual picocom\(8\))-2.5 F/F1 10/Times-Bold@0 SF
(--parity | -p)108 84 Q F0 .685(De\214nes the parity mode to set the se\
rial-port to. Must be one of: 'o' for odd parity mode, 'e' for)144 96 R
-2.15 -.25(ev e)144 108 T 2.5(np).25 G
(arity mode, 'n' for no parity mode. \(Def)-2.5 E(ault: 'n'\))-.1 E F1
(--databits | -d)108 124.8 Q F0(De\214nes the number of data bits in e)
144 136.8 Q -.15(ve)-.25 G(ry character).15 E 2.5(.M)-.55 G
(ust be one of: 5, 6, 7, 8. \(Def)-2.5 E(ault: 8\))-.1 E F1
(--stopbits | -p)108 153.6 Q F0(De\214nes the number of stop bits in e)
144 165.6 Q -.15(ve)-.25 G(ry character).15 E 2.5(.M)-.55 G
(ust be one of: 1, or 2. \(Def)-2.5 E(ault: 1\))-.1 E F1(--esacpe | -e)
108 182.4 Q F0 .329(De\214nes the character that will mak)144 194.4 R
2.829(ep)-.1 G .329(icocom enter command-mode \(see description abo)
-2.829 F -.15(ve)-.15 G .33(\). If 'x').15 F(is gi)144 206.4 Q -.15(ve)
-.25 G(n, then C-x will mak).15 E 2.5(ep)-.1 G
(icocom enter command mode. \(Def)-2.5 E(ault: 'a'\))-.1 E F1
(--echo | -c)108 223.2 Q F0 .602(Enable local echo. Ev)144 235.2 R .602
(ery character being read from the terminal \(standard input\) is echoe\
d to the)-.15 F .004(terminal \(standard output\) subject to the echo-m\
apping con\214guration \(see)144 247.2 R F1(--emap)2.505 E F0 .005
(option. \(Def)2.505 F(ault:)-.1 E(Disabled\))144 259.2 Q F1
(--noinit | -i)108 276 Q F0 .785(If gi)144 288 R -.15(ve)-.25 G .785(n,\
picocom will not initialize, reset, or otherwise meddle with the seria\
l port at start-up. It).15 F 2.742
(will just open it. This is useful, for e)144 300 R 2.743
(xample, for connecting picocom to already-connected)-.15 F .038(modems\
, or already con\214gured ports without terminating the connection, or \
altering the settings. If)144 312 R(required serial port parameters can\
then be adjusted at run-time by commands.)144 324 Q F1(--nor)108 340.8
Q(eset | -r)-.18 E F0 .396(If gi)144 352.8 R -.15(ve)-.25 G .396
(n, picocom will not *reset* the serial port when e).15 F .397
(xiting. It will just close the \214ledes and do)-.15 F .696
(nothing more. This is useful, for e)144 364.8 R .696(xample, for lea)
-.15 F .696(ving modems connected when e)-.2 F .696(xiting picocom.)-.15
F(Re)144 376.8 Q -.05(ga)-.15 G .422(rdless whether the).05 F F1(--nor)
2.922 E(eset)-.18 E F0 .422(option is gi)2.922 F -.15(ve)-.25 G 2.922
(nt).15 G .422(he user can e)-2.922 F .422
(xit picocom using the "Quit" com-)-.15 F .706
(mand \(instead of "Exit"\), which ne)144 388.8 R -.15(ve)-.25 G 3.206
(rr).15 G .706(esets the serial port. If)-3.206 F F1(--nor)3.205 E(eset)
-.18 E F0 .705(is gi)3.205 F -.15(ve)-.25 G 3.205(nt).15 G .705
(hen "Quit" and)-3.205 F("Exit" beha)144 400.8 Q .3 -.15(ve e)-.2 H
(ssentially the same.).15 E F1(--nolock | -l)108 417.6 Q F0 .139(If gi)
144 429.6 R -.15(ve)-.25 G .139(n, picocom will *not* attempt to lock t\
he serial port before opening it. Normally).15 F 2.64(,d)-.65 G
(epending)-2.64 E 8.802(on ho)144 441.6 R 11.302(wi)-.25 G(t')-11.302 E
11.302(sc)-.55 G 8.802
(ompiled, picocom attempts to get a UUCP-style lock-\214le \(e.g.)
-11.302 F("/v)144 453.6 Q 1.323(ar/lock/LCK..ttyS0"\) before opening th\
e port, or attempts to lock the port de)-.25 F 1.324(vice-node using)
-.25 F F1(\215ock\(2\))144 465.6 Q F0 2.892(.F)C .391
(ailing to do so, results in the program e)-3.042 F .391
(xiting after emitting an error)-.15 F .391(-message. It is pos-)-.2 F
.698(sible that your picocom binary is compiled without support for loc\
king. In this case the)144 477.6 R F1(--nolock)3.198 E F0
(option is accepted, b)144 489.6 Q(ut has no ef)-.2 E(fect.)-.25 E F1
(--send-cmd | -s)108 506.4 Q F0 .46(Speci\214es the e)144 518.4 R .46
(xternal program \(and an)-.15 F 2.96(ya)-.15 G -.18(rg)-2.96 G .46
(uments to it\) that will be used for transmitting \214les. If).18 F
.663(the ar)144 530.4 R .663(gument to)-.18 F F1(--send-cmd)3.163 E F0
.663(is the empty string \(')3.163 F .664
('\), the send-\214le command is disabled. \(Def)-.74 F(ault:)-.1 E
("sz -vv"\))144 542.4 Q F1(--r)108 559.2 Q(ecei)-.18 E -.1(ve)-.1 G
(-cmd | -v).1 E F0 .237(Speci\214es the e)144 571.2 R .237
(xternal program \(and an)-.15 F 2.737(ya)-.15 G -.18(rg)-2.737 G .236
(uments to it\) that will be used for recei).18 F .236
(ving \214les. If the)-.25 F(ar)144 583.2 Q .286(gument to)-.18 F F1
(--r)2.786 E(ecei)-.18 E -.1(ve)-.1 G(-cmd).1 E F0 .286
(is the empty string \(')2.786 F .286('\), the recei)-.74 F -.15(ve)-.25
G .286(-\214le command is disabled. \(Def).15 F(ault:)-.1 E("rz -vv"\))
144 595.2 Q F1(--imap)108 612 Q F0 .575(Speci\214es the input character\
map \(i.e. special characters to be replaced when read from the serial)
144 612 R(port\). Example: "--imap crlf,delbs". \(Def)144 624 Q
(aul: Empty\))-.1 E F1(--omap)108 640.8 Q F0 1.031(Speci\214es the outp\
ut character map \(i.e. special characters to be replaced before being \
written to)144 640.8 R
(serial port\). Example: "--omap crcrlf,bsdel". \(Def)144 652.8 Q
(aul: Empty\))-.1 E F1(--emap)108 669.6 Q F0 .408(Speci\214es the local\
-echo character map \(i.e. special characters to be replaced before bei\
ng echoed-)144 328.8 R 4.24(back to the terminal, if local-echo is enab\
led\). Example: "--emap crcrlf,bsdel". \(Def)144 340.8 R(aul:)-.1 E
(delbs,crcrlf\))144 352.8 Q F2(--help | -h)108 369.6 Q F0
(Print a short help message describing the command-line options.)144
381.6 Q/F3 10.95/Times-Bold@0 SF -.548(AU)72 398.4 S(THOR).548 E F0
(picocom w)108 410.4 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 427.2 T
(ILABILITY)1.588 E F0 5.149(The latest v)108 439.2 R 5.149
(ersion of "picocom" can be do)-.15 F 5.149(wnloaded from:)-.25 F F2
(https://github)7.648 E(.com/npat-efault/pico-)-.4 E(com/r)108 451.2 Q
(eleases)-.18 E F0 187.62(Manuals User)72 768 R(4)219.56 E 0 Cg EP
ng echoed-)144 669.6 R 4.24(back to the terminal, if local-echo is enab\
led\). Example: "--emap crcrlf,bsdel". \(Def)144 681.6 R(aul:)-.1 E
(delbs,crcrlf\))144 693.6 Q 187.62(Manuals User)72 768 R(4)219.56 E 0 Cg
EP
%%Page: 5 5
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Times-Roman@0 SF 131.795(picocom\(8\) System)72 48 R(Manager')2.5
E 2.5(sM)-.55 G 131.795(anual picocom\(8\))-2.5 F/F1 10/Times-Bold@0 SF
(--help | -h)108 84 Q F0 .335(Print a short help message describing the\
command-line options. picocom')144 96 R 2.834(sv)-.55 G .334
(ersion, compile-time)-2.984 F
(options, and enabled features are also sho)144 108 Q(wn.)-.25 E/F2
10.95/Times-Bold@0 SF -.548(AU)72 124.8 S(THOR).548 E F0(picocom w)108
136.8 Q(as written by Nick P)-.1 E(ata)-.15 E -.25(va)-.2 G
(lis \(npat@ef).25 E(ault.net\))-.1 E F2 -1.04 -1.588(AV A)72 153.6 T
(ILABILITY)1.588 E F0 5.319(The latest release of "picocom" can be do)
108 165.6 R 5.319(wnloaded from:)-.25 F F1(https://github)7.819 E
(.com/npat-efault/pico-)-.4 E(com/r)108 177.6 Q(eleases)-.18 E F0 187.62
(Manuals User)72 768 R(5)219.56 E 0 Cg EP
%%Trailer
end
%%EOF

View File

@ -13,25 +13,24 @@
<description>
<p>
As its name suggests, <b>picocom</b> is a minimal
dumb-terminal emulation program. It is, in principle, very much
like <manref name="minicom" section="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
As its name suggests, <b>picocom</b> is a minimal dumb-terminal
emulation program. It is, in principle, very much like <manref
name="minicom" section="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 serial communications program to
allow access to all types of devices that provide serial
consoles. It could also prove useful in many other similar
tasks.
</p>
<p>
When <b>picocom</b> starts it opens the terminal (serial
device) given as its non-option argument. Unless the
<arg>--noinit</arg> option is given, it configures the device to
<opt>--noinit</opt> 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
<arg>--noinit</arg> is given, the initialization and
<opt>--noinit</opt> is given, the initialization and
configuration is skipped; the device is just opened. Following
this, <b>picocom</b> sets the standard-input and
standard-output to raw mode. Having done so, it goes in a loop
@ -63,20 +62,18 @@
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.
transparent mode.
</p>
<p>
[C-x]: Exit the program: if the <arg>--noreset</arg> option was
[C-x]: Exit the program: if the <opt>--noreset</opt> 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.
</p>
<p>
[C-q]: Quit the program *without* reseting the serial port,
regardless of the <arg>--noreset</arg> option.
regardless of the <opt>--noreset</opt> option.
</p>
<p>
@ -126,15 +123,35 @@
[C-b]: Cycle through databits-number settings (5, 6, 7, 8).
</p>
<p>
[C-j]: Cycle through stopbits-number settings (1, 2).
</p>
<p>
[C-c]: Toggle local-echo mode.
</p>
<p>
[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-v]: Show program options (like baud rate, data bits, etc) as
well as the actual serial port settings. Only the options and
port settings that can be modified online (through commands) are
shown, not those that can only be set at the command-line. If an
actual port setting is different than the current value of the
respective option (for whatever reason) then the value of the
option is shown, followed by the value of the actual port
setting in parenthesis. Example: "*** baud: 115200 (9600)". This
means that a baud rate of 115200bps has been selected (from the
command line, or using commands) but the serial port is actually
operating at 9600bps (the driver may not support the higher
setting, and has silently replaced it with a safe default, or
the setting may have been changed from outside picocom). If the
option and the corresponding port setting are the same, only a
single value is shown. Example: "*** baud: 9600".
</p>
<p>
[C-h] or [C-k]: Show help or show keys. Prints a short
description of all available function (command) keys.
</p>
<p>
@ -158,6 +175,16 @@
<p>
assuming of-course that "C-a" is the escape character.
</p>
<p>
Commands that change program options ([C-u], [C-d], [C-f], etc)
also display a message showing the new option value. If the new
option value cannot be applied succesfully to the serial port
(for whatever reason), then the respective actual current port
setting is also shown. See the description of the [C-v] command,
above, for more on this.
</p>
</section>
<section name = "SENDING AND RECEIVING FILES">
@ -185,17 +212,29 @@
<p>
The name of, and the command-line options to, the program to be
used for transmitting files are given by the
<arg>--send-cmd</arg> option. Similarly the program to receive
<opt>--send-cmd</opt> option. Similarly the program to receive
files, and its argumets, are given by the
<arg>--receive-cmd</arg> option. For example, in order to start
<opt>--receive-cmd</opt> option. For example, in order to start
a <b>picocom</b> session that uses "sz" to transmit files, and
"rz" to receive, you have to say something like this:
"rz" to receive files, you have to say something like this:
</p>
<p>
picocom --send-cmd "sz -vv" --receive-cmd "rz -vv"
</p>
<p>
If the argument to the <opt>--send-cmd</opt> option, or the
argument to the <opt>--receive-cmd</opt> option is the empty
string, then the respective command is disabled. For example, in
order to disable both the "send" and the "receive" commands you
can invoke picocom like this:
</p>
<p>
picocom --send-cmd '' --receive-cmd ''
</p>
<p>
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
@ -210,7 +249,7 @@
transmission or reception program arguments) and assuming you
have not canceled the operation by pressing C-c, picocom will
start the the external program as specified by the
<arg>--send-cmd</arg>, or <arg>--receive-cmd</arg> option, and
<opt>--send-cmd</opt>, or <opt>--receive-cmd</opt> 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
@ -226,13 +265,13 @@
<section name = "INPUT, OUTPUT, AND ECHO MAPPING">
<p>
Using the <arg>--imap</arg>, <arg>--omap</arg>, and
<arg>--emap</arg> options you can make <b>picocom</b> map
Using the <opt>--imap</opt>, <opt>--omap</opt>, and
<opt>--emap</opt> options you can make <b>picocom</b> map
(tranlate, replace) certain special characters after being read
from the serial port (with <arg>--imap</arg>), before being
written to the serial port (with <arg>--omap</arg>), and before
from the serial port (with <opt>--imap</opt>), before being
written to the serial port (with <opt>--omap</opt>), and before
being locally echoed to the terminal (standard output) if local
echo is enabled (with <arg>--emap</arg>). These mapping options
echo is enabled (with <opt>--emap</opt>). 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
@ -303,6 +342,16 @@
</p>
</optdesc>
</option>
<option>
<opt><p>--stopbits | -p</p></opt>
<optdesc>
<p>
Defines the number of stop bits in every character. Must be
one of: 1, or 2. (Default: 1)
</p>
</optdesc>
</option>
<option>
<opt><p>--esacpe | -e</p></opt>
@ -322,7 +371,7 @@
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 <arg>--emap</arg> option. (Default: Disabled)
(see <opt>--emap</opt> option. (Default: Disabled)
</p>
</optdesc>
</option>
@ -350,9 +399,9 @@
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</b>. Regardless whether
the <arg>--noreset</arg> option is given the user can exit
the <opt>--noreset</opt> option is given the user can exit
<b>picocom</b> using the "Quit" command (instead of "Exit"),
which never resets the serial port. If <arg>--noreset</arg>
which never resets the serial port. If <opt>--noreset</opt>
is given then "Quit" and "Exit" behave essentially the same.
</p>
</optdesc>
@ -363,12 +412,15 @@
<optdesc>
<p>
If given, <b>picocom</b> 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
serial port before opening it. Normally, depending on how
it's compiled, picocom attempts to get a UUCP-style
lock-file (e.g. "/var/lock/LCK..ttyS0") before opening the
port, or attempts to lock the port device-node using <manref
name="flock" section="2"/>. 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.
possible that your picocom binary is compiled without
support for locking. In this case the <opt>--nolock</opt>
option is accepted, but has no effect.
</p>
</optdesc>
</option>
@ -378,8 +430,9 @@
<optdesc>
<p>
Specifies the external program (and any arguments to it)
that will be used for transmitting files. (Default: "sz
-vv")
that will be used for transmitting files. If the argument to
<opt>--send-cmd</opt> is the empty string (''), the
send-file command is disabled. (Default: "sz -vv")
</p>
</optdesc>
</option>
@ -389,7 +442,9 @@
<optdesc>
<p>
Specifies the external program (and any arguments to it)
that will be used for receiving files. (Default: "rz -vv")
that will be used for receiving files. If the argument to
<opt>--receive-cmd</opt> is the empty string (''), the
receive-file command is disabled. (Default: "rz -vv")
</p>
</optdesc>
</option>
@ -433,7 +488,8 @@
<optdesc>
<p>
Print a short help message describing the command-line
options.
options. picocom's version, compile-time options, and enabled
features are also shown.
</p>
</optdesc>
</option>
@ -445,8 +501,8 @@
</section>
<section name="AVAILABILITY">
<p>The latest version of "picocom" can be downloaded from: <url
href="https://github.com/npat-efault/picocom/releases" />
<p>The latest release of "picocom" can be downloaded from: <url
href="https://github.com/npat-efault/picocom/releases" />
</p>
</section>

885
picocom.c

File diff suppressed because it is too large Load Diff

236
split.c Normal file
View File

@ -0,0 +1,236 @@
/* vi: set sw=4 ts=4:
*
* split.c
*
* Function that splits a string intro arguments with quoting.
*
* 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 <stdlib.h>
#include <string.h>
#include <assert.h>
#include "split.h"
/* Lexer error end-codes */
enum err_codes {
ERR_OK = 0, /* no error, string lexed ok */
ERR_BS_AT_EOS, /* backslash at the end of string */
ERR_SQ_OPEN_AT_EOS, /* single-quote left open */
ERR_DQ_OPEN_AT_EOS /* double-quote left open */
};
/* Lexer states */
enum states {
ST_DELIM,
ST_QUOTE,
ST_ARG,
ST_END
};
/* Special characters */
#define BS '\\'
#define SQ '\''
#define DQ '\"'
#define NL '\n'
#define EOS '\0'
#define is_delim(c) \
( (c) == ' ' || (c) == '\t' || (c) == '\n' )
#define is_dq_escapable(c) \
( (c) == '\\' || (c) == '\"' || (c) == '`' || (c) == '$' )
/* Short-hands used in split_quoted() */
#define push() \
do { \
char *arg; \
if ( *argc < argv_sz ) { \
*ap = '\0'; \
arg = strdup(arg_buff); \
/* !! out of mem !! */ \
if ( ! arg ) return -1; \
argv[*argc] = arg; \
(*argc)++; \
} else { \
flags |= SPLIT_DROP; \
} \
ap = &arg_buff[0]; \
} while(0)
#define save() \
do { \
if (ap != ae) { \
*ap++ = *c; \
} else { \
flags |= SPLIT_TRUNC; \
} \
} while (0)
int
split_quoted (const char *s, int *argc, char *argv[], int argv_sz)
{
char arg_buff[MAX_ARG_LEN]; /* current argument buffer */
char *ap, *ae; /* arg_buff current ptr & end-guard */
const char *c; /* current input charcter ptr */
char qc; /* current quote character */
enum states state; /* current state */
enum err_codes err; /* error end-code */
int flags; /* warning flags */
ap = &arg_buff[0];
ae = &arg_buff[MAX_ARG_LEN - 1];
c = &s[0];
state = ST_DELIM;
err = ERR_OK;
flags = 0;
qc = SQ; /* silence compiler waring */
while ( state != ST_END ) {
switch (state) {
case ST_DELIM:
while ( is_delim(*c) ) c++;
if ( *c == SQ || *c == DQ ) {
qc = *c; c++; state = ST_QUOTE;
break;
}
if ( *c == EOS ) {
state = ST_END;
break;
}
if ( *c == BS ) {
c++;
if ( *c == NL ) {
c++;
break;
}
if ( *c == EOS ) {
state = ST_END; err = ERR_BS_AT_EOS;
break;
}
}
/* All other cases incl. character after BS */
save(); c++; state = ST_ARG;
break;
case ST_QUOTE:
while ( *c != qc && ( *c != BS || qc == SQ ) && *c != EOS ) {
save(); c++;
}
if ( *c == qc ) {
c++; state = ST_ARG;
break;
}
if ( *c == BS ) {
assert (qc == DQ);
c++;
if ( *c == NL) {
c++;
break;
}
if (*c == EOS) {
state = ST_END; err = ERR_BS_AT_EOS;
break;
}
if ( ! is_dq_escapable(*c) ) {
c--; save(); c++;
}
save(); c++;
break;
}
if ( *c == EOS ) {
state = ST_END; err = ERR_SQ_OPEN_AT_EOS;
break;
}
assert(0);
case ST_ARG:
if ( *c == SQ || *c == DQ ) {
qc = *c; c++; state = ST_QUOTE;
break;
}
if ( is_delim(*c) || *c == EOS ) {
push();
state = (*c == EOS) ? ST_END : ST_DELIM;
c++;
break;
}
if ( *c == BS ) {
c++;
if ( *c == NL ) {
c++;
break;
}
if ( *c == EOS ) {
state = ST_END; err = ERR_BS_AT_EOS;
break;
}
}
/* All other cases, incl. character after BS */
save(); c++;
break;
default:
assert(0);
}
}
return ( err != ERR_OK ) ? -1 : flags;
}
/**********************************************************************/
#if 0
int
main (int argc, char *argv[])
{
char *my_argv[12];
int my_argc, i, r;
if ( argc != 2 ) {
printf("Usage is: %s: <string to split>\n", argv[0]);
exit(EXIT_FAILURE);
}
printf("String to split is: [%s]\n", argv[1]);
r = split_quoted(argv[1], &my_argc, my_argv, 12);
if ( r < 0 ) {
printf("Spliting failed!\n");
exit(EXIT_FAILURE);
}
printf("Split ok. SPLIT_DROP is %s, SPLIT_TRUNC is %s\n",
(r & SPLIT_DROP) ? "ON" : "off",
(r & SPLIT_TRUNC) ? "ON" : "off");
for (i = 0; i < my_argc; i++)
printf("%02d : [%s]\n", i, my_argv[i]);
return EXIT_SUCCESS;
}
#endif
/**********************************************************************/
/*
* Local Variables:
* mode:c
* tab-width: 4
* c-basic-offset: 4
* indent-tabs-mode: nil
* End:
*/

123
split.h Normal file
View File

@ -0,0 +1,123 @@
/* vi: set sw=4 ts=4:
*
* split.h
*
* Function that splits a string intro arguments with quoting.
*
* 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
*/
#ifndef SPLIT_H
#define SPLIT_H
/* Maximum single-argument length that can be dealt-with by function
* split_quoted(). Longer arguments are truncated. See below.
*/
#define MAX_ARG_LEN 512
/* Warning flags, set by split_quoted() to its return value. */
#define SPLIT_DROP (1 << 0) /* argument had to be dropped */
#define SPLIT_TRUNC (1 << 1) /* argument had to be truncated */
/* F split_quoted
*
* Splits string "s" into arguments and places them in "argv". Every
* argument is a heap-allocated null-terminated string that must be
* freed with free(3) when no longer needed. The first argument is
* placed in "argv[*argc]", the following at subsequent "argv" slots,
* and "*argc" is incremented accordingly. As a result, this function
* can be called multiple times to add arguments to the same argument
* vector. The argument "argv_sz" is the allocated size (in number of
* slots) of the supplied argument vector ("argv"). The function takes
* care not to overrun it. If more arguments are present in the
* input string "s", they are dropped.
*
* When spliting the input string intro arguments, quoting rules
* very similar to the ones used by the Unix shell are used.
*
* The following caracters are considered special: ' ' (space), '\t'
* (tab), '\n' (newline), '\' (backslash), ''' (single quote), and '"'
* (double quote). All other caracters are considered normal and can
* become part of an argument without escaping.
*
* Arguments are separated by runs of the characters: ' ' (space),
* '\t', and '\n', which are considered delimiters.
*
* All characters beetween single quotes (')---without
* exceptions---are considered normal and become part of the current
* argument (but not the single quotes themselves).
*
* All characters between double quotes (") are considered normal and
* become part of the current argument (but not the double quotes
* themselves). Exception to this is the backslash character, when
* followed by one of the characters '"', '\', '$', and '`'. In this
* case, the backslash is removed, and the next caracter is considered
* normal and becomes part of the current argument. When the backslash
* is followed by newline, both the backslash and the newline are
* removed. In all other cases a backslash, within double quotes, is
* considered a normal character (and becomes part of the current
* argument). We treat the sequences '\$' and '\`' specially (while
* there is no real reason), for better unix-shell compatibility.
*
* Outside of single or double quotes, every backslash caracter is
* removed, and the following character (with the exception of
* <newline>, see below) is considered normal and becomes part of the
* current argument. If, outside of quotes, a backslash precedes a
* <newline>, then both the backslash and the newline are removed.
*
* Examples:
*
* a b c d --> [a] [b] [c] [d]
* 'a b' c d --> [a b] [c] [d]
* 'a "b"' c d --> [a "b"] [c] [d]
* "a 'b'" c d --> [a 'b'] [c] [d]
* a"b c" d --> [ab c] [d]
* a\ b c d --> [a b] [c] [d]
* \a\b c d --> [ab] [c] [d]
* \a\\b \\ c d --> [a\b] [\] [c] [d]
* "a\$\b" c d --> [a$\b] [c] [d]
* "\a\`\"\b" c d --> [\a`"\b] [c] [d]
*
* Limitation: This function cannot deal with individual arguments
* longer than MAX_ARG_LEN. If such an argument is encountered, it is
* truncated accordingly.
*
* This function returns a non-negative on success, and a negative on
* failure. The only causes for failure is a malformed command string
* (e.g. un-balanced quotes), or the inability to allocate an argument
* string. On success the value returned can be checked against the
* warning flags SPLIT_DROP, and SPLIT_TRUNC. If SPLIT_DROP is set,
* then a least one argument was dropped as there was no available
* slot in "argv" to store it in. If SPLIT_TRUNC is set, then at least
* one argument was truncated (see limitation, above).
*/
int split_quoted(const char *s, int *argc, char *argv[], int argv_sz);
#endif /* of SPLIT_H */
/**********************************************************************/
/*
* Local Variables:
* mode:c
* tab-width: 4
* c-basic-offset: 4
* indent-tabs-mode: nil
* End:
*/

262
term.c
View File

@ -68,8 +68,10 @@ static const char * const term_err_str[] = {
[TERM_EBAUD] = "Invalid baud rate",
[TERM_ESETOSPEED] = "Cannot set the output speed",
[TERM_ESETISPEED] = "Cannot set the input speed",
[TERM_EGETSPEED] = "Cannot decode speed",
[TERM_EPARITY] = "Invalid parity mode",
[TERM_EDATABITS] = "Invalid number of databits",
[TERM_ESTOPBITS] = "Invalid number of stopbits",
[TERM_EFLOW] = "Invalid flowcontrol mode",
[TERM_EDTRDOWN] = "Cannot lower DTR",
[TERM_EDTRUP] = "Cannot raise DTR",
@ -106,6 +108,7 @@ term_strerror (int terrnum, int errnum)
case TERM_EBAUD:
case TERM_EPARITY:
case TERM_EDATABITS:
case TERM_ESTOPBITS:
case TERM_EFLOW:
case TERM_EDTRDOWN:
case TERM_EDTRUP:
@ -192,7 +195,7 @@ struct baud_codes {
{ 3500000, B3500000 },
#endif
#ifdef B4000000
{ 4000000, 4000000 },
{ 4000000, B4000000 },
#endif
#endif /* of HIGH_BAUD */
};
@ -248,6 +251,20 @@ Bcode(int speed)
return code;
}
static int
Bspeed(speed_t code)
{
int speed = -1, i;
for (i = 0; i < BAUD_TABLE_SZ; i++) {
if ( baud_table[i].code == code ) {
speed = baud_table[i].speed;
break;
}
}
return speed;
}
/**************************************************************************/
static int
@ -320,12 +337,10 @@ term_exitfunc (void)
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;
tcflush(term.fd[i], TCIOFLUSH);
do {
r = tcsetattr(term.fd[i], TCSAFLUSH, &term.origtermios[i]);
if ( r < 0 ) break;
} while (0);
} while ( r < 0 && errno == EINTR );
if ( r < 0 ) {
char *tname;
@ -354,12 +369,10 @@ term_lib_init (void)
for (i = 0; i < MAX_TERMS; i++) {
if (term.fd[i] == -1)
continue;
tcflush(term.fd[i], TCIOFLUSH);
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);
} while ( r < 0 && errno == EINTR );
if ( r < 0 ) {
char *tname;
@ -513,6 +526,12 @@ term_replace (int oldfd, int newfd)
rval = -1;
break;
}
r = tcgetattr(newfd, &term.currtermios[i]);
if ( r < 0 ) {
term_errno = TERM_EGETATTR;
rval = -1;
break;
}
term.fd[i] = newfd;
@ -550,9 +569,14 @@ term_reset (int fd)
rval = -1;
break;
}
r = tcgetattr(term.fd[i], &term.currtermios[i]);
if ( r < 0 ) {
term_errno = TERM_EGETATTR;
rval = -1;
break;
}
term.currtermios[i] = term.origtermios[i];
term.nexttermios[i] = term.origtermios[i];
term.nexttermios[i] = term.currtermios[i];
} while (0);
return rval;
@ -634,7 +658,13 @@ term_apply (int fd)
rval = -1;
break;
}
r = tcgetattr(term.fd[i], &term.nexttermios[i]);
if ( r < 0 ) {
term_errno = TERM_EGETATTR;
rval = -1;
break;
}
term.currtermios[i] = term.nexttermios[i];
} while (0);
@ -718,6 +748,34 @@ term_set_baudrate (int fd, int baudrate)
return rval;
}
int
term_get_baudrate (int fd, int *ispeed)
{
speed_t code;
int i, ospeed;
do { /* dummy */
i = term_find(fd);
if ( i < 0 ) {
ospeed = -1;
break;
}
if ( ispeed ) {
code = cfgetispeed(&term.currtermios[i]);
*ispeed = Bspeed(code);
}
code = cfgetospeed(&term.currtermios[i]);
ospeed = Bspeed(code);
if ( ospeed < 0 )
term_errno = TERM_EGETSPEED;
} while (0);
return ospeed;
}
/***************************************************************************/
int
@ -740,14 +798,22 @@ term_set_parity (int fd, enum parity_e parity)
switch (parity) {
case P_EVEN:
tiop->c_cflag &= ~PARODD;
tiop->c_cflag &= ~(PARODD | CMSPAR);
tiop->c_cflag |= PARENB;
break;
case P_ODD:
tiop->c_cflag &= ~CMSPAR;
tiop->c_cflag |= PARENB | PARODD;
break;
case P_MARK:
tiop->c_cflag |= PARENB | PARODD | CMSPAR;
break;
case P_SPACE:
tiop->c_cflag &= ~PARODD;
tiop->c_cflag |= PARENB | CMSPAR;
break;
case P_NONE:
tiop->c_cflag &= ~(PARENB | PARODD);
tiop->c_cflag &= ~(PARENB | PARODD | CMSPAR);
break;
default:
term_errno = TERM_EPARITY;
@ -761,6 +827,34 @@ term_set_parity (int fd, enum parity_e parity)
return rval;
}
enum parity_e
term_get_parity (int fd)
{
tcflag_t flg;
int i, parity;
do { /* dummy */
i = term_find(fd);
if ( i < 0 ) {
parity = -1;
break;
}
flg = term.currtermios[i].c_cflag;
if ( ! (flg & PARENB) ) {
parity = P_NONE;
} else if ( flg & CMSPAR ) {
parity = (flg & PARODD) ? P_MARK : P_SPACE;
} else {
parity = (flg & PARODD) ? P_ODD : P_EVEN;
}
} while (0);
return parity;
}
/***************************************************************************/
int
@ -806,6 +900,101 @@ term_set_databits (int fd, int databits)
return rval;
}
int
term_get_databits (int fd)
{
tcflag_t flg;
int i, bits;
do { /* dummy */
i = term_find(fd);
if ( i < 0 ) {
bits = -1;
break;
}
flg = term.currtermios[i].c_cflag & CSIZE;
switch (flg) {
case CS5:
bits = 5;
break;
case CS6:
bits = 6;
break;
case CS7:
bits = 7;
break;
case CS8:
default:
bits = 8;
break;
}
} while (0);
return bits;
}
/***************************************************************************/
int
term_set_stopbits (int fd, int stopbits)
{
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 (stopbits) {
case 1:
tiop->c_cflag &= ~CSTOPB;
break;
case 2:
tiop->c_cflag |= CSTOPB;
break;
default:
term_errno = TERM_ESTOPBITS;
rval = -1;
break;
}
if ( rval < 0 ) break;
} while (0);
return rval;
}
int
term_get_stopbits (int fd)
{
int i, bits;
do { /* dummy */
i = term_find(fd);
if ( i < 0 ) {
bits = -1;
break;
}
bits = (term.currtermios[i].c_cflag & CSTOPB) ? 2 : 1;
} while (0);
return bits;
}
/***************************************************************************/
int
@ -851,6 +1040,39 @@ term_set_flowcntrl (int fd, enum flowcntrl_e flowcntl)
return rval;
}
enum flowcntrl_e
term_get_flowcntrl (int fd)
{
int i, flow;
int rtscts, xoff, xon;
do { /* dummy */
i = term_find(fd);
if ( i < 0 ) {
flow = -1;
break;
}
rtscts = (term.currtermios[i].c_cflag & CRTSCTS) ? 1 : 0;
xoff = (term.currtermios[i].c_iflag & IXOFF) ? 1 : 0;
xon = (term.currtermios[i].c_iflag & (IXON | IXANY)) ? 1 : 0;
if ( rtscts && ! xoff && ! xon ) {
flow = FC_RTSCTS;
} else if ( ! rtscts && xoff && xon ) {
flow = FC_XONXOFF;
} else if ( ! rtscts && ! xoff && ! xon ) {
flow = FC_NONE;
} else {
flow = FC_OTHER;
}
} while (0);
return flow;
}
/***************************************************************************/
int
@ -916,7 +1138,10 @@ term_set_hupcl (int fd, int on)
int
term_set(int fd,
int raw,
int baud, enum parity_e parity, int bits, enum flowcntrl_e fc,
int baud,
enum parity_e parity,
int databits, int stopbits,
enum flowcntrl_e fc,
int local, int hup_close)
{
int rval, r, i, ni;
@ -952,7 +1177,10 @@ term_set(int fd,
r = term_set_parity(fd, parity);
if ( r < 0 ) { rval = -1; break; }
r = term_set_databits(fd, bits);
r = term_set_databits(fd, databits);
if ( r < 0 ) { rval = -1; break; }
r = term_set_stopbits(fd, stopbits);
if ( r < 0 ) { rval = -1; break; }
r = term_set_flowcntrl(fd, fc);

171
term.h
View File

@ -8,30 +8,30 @@
*
* Principles of operation:
*
* After the library is initialized one or more file-descriptors, can
* 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).
* it. 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:
*
@ -48,10 +48,15 @@
* 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_stopbits - set the stopbits 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_get_baudrate - return the baudrate set in "currtermios"
* F term_get_parity - return the parity setting in "currtermios"
* F term_get_databits - return the data-bits setting in "currtermios"
* F term_get_flowcntrl - return the flow-control setting in "currtermios"
* 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
@ -126,8 +131,10 @@ enum term_errno_e {
TERM_EBAUD,
TERM_ESETOSPEED,
TERM_ESETISPEED,
TERM_EGETSPEED,
TERM_EPARITY,
TERM_EDATABITS,
TERM_ESTOPBITS,
TERM_EFLOW,
TERM_EDTRDOWN,
TERM_EDTRUP,
@ -139,14 +146,18 @@ enum term_errno_e {
*
* Parity modes supported by the library:
*
* P_NONE - no patiry
* P_EVEN - even parity
* P_ODD - odd parity
* P_NONE - no patiry
* P_EVEN - even parity
* P_ODD - odd parity
* P_MARK - mark parity (parity bit always 1)
* P_SPACE - space parity (parity bit always 0)
*/
enum parity_e {
P_NONE,
P_NONE = 0,
P_EVEN,
P_ODD
P_ODD,
P_MARK,
P_SPACE
};
/*
@ -160,9 +171,10 @@ enum parity_e {
* FC_XONXOFF - xon/xoff flow control.
*/
enum flowcntrl_e {
FC_NONE,
FC_NONE = 0,
FC_RTSCTS,
FC_XONXOFF
FC_XONXOFF,
FC_OTHER
};
/***************************************************************************/
@ -265,7 +277,10 @@ int term_erase (int fd);
* 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.
* configured with "oldfd"s current settings (stored in the
* "currtermios" structure). After applying the settings to "newfd",
* the "currtermios" structure is re-read from the device, so that it
* corresponds to the actual device settings.
*
* Returns negative on failure, non-negative on success. In case of
* failure "oldfd" is not removed from the framework, and no
@ -276,21 +291,24 @@ int term_erase (int fd);
* 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.
* the device reverts to system-default settings. By calling
* term_replace, 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.
* Applies the settings stored in the "nexttermios" structure
* associated with the managed filedes "fd", to the respective
* terminal device. It then re-reads the settings form the device and
* stores them in "nexttermios". Finally it copies "nexttermios" to
* "currtermios".
*
* Returns negative on failure, non negative on success. In case of
* failure the currtermios structure is not affected.
* failure the "nexttermios" and "currtermios" structures are not
* affected.
*/
int term_apply (int fd);
@ -311,9 +329,9 @@ int term_revert (int fd);
*
* 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".
* the "origtermios" structure to the actual device. It then reads the
* settings from the device and stores them in both the "currtermios"
* and "nexttermios" stuctures.
*
* Returns negative on failure, non-negative of success. On failure
* the the "origtermios", "currtermios", and "nexttermios" stuctures
@ -397,6 +415,20 @@ int term_set_parity (int fd, enum parity_e parity);
*/
int term_set_databits (int fd, int databits);
/* F term_set_stopbits
*
* Sets the stopbits number in the "nexttermios" structure associated
* with the managed filedes "fd" to "stopbits". The effective settings
* of the device are not affected by this function.
*
* 1 and 2 stopbits 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_stopbits (int fd, int stopbits);
/* F term_set_flowcntrl
*
* Sets the folwcontrol mode in the "nexttermios" structure associated
@ -466,9 +498,64 @@ int term_set_local (int fd, int local);
int term_set (int fd,
int raw,
int baud,
enum parity_e parity, int bits, enum flowcntrl_e fc,
enum parity_e parity,
int databits, int stopbits,
enum flowcntrl_e fc,
int local, int hupcl);
/* F term_get_baudrate
*
* Reads and decodes the current baudrate settings in the
* "currtermios" structure of the managed filedes "fd".
*
* Returns the decoded output baudrate (as bits-per-second), or -1 if
* the output baudrate cannot be decoded, or if "fd" does not
* correspond to a managed filedes. If "ispeed" is not NULL, it writes
* the decoded input baudrate to the integer pointed-to by "ispeed";
* if the input baudrate cannot be decoded in writes -1 instead.
*/
int term_get_baudrate (int fd, int *ispeed);
/* F term_get_parity
*
* Reads and decodes the current parity settings in the
* "currtermios" structure of the managed filedes "fd".
*
* Returns one of the "enum parity_e" members, or -1 if "fd" does not
* correspond to a managed filedes.
*/
enum parity_e term_get_parity (int fd);
/* F term_get_databits
*
* Reads and decodes the current databits settings in the
* "currtermios" structure of the managed filedes "fd".
*
* Returns the number of databits (5..8), or -1 if "fd" does not
* correspond to a managed filedes.
*/
int term_get_databits (int fd);
/* F term_get_stopbits
*
* Reads and decodes the current stopbits settings in the
* "currtermios" structure of the managed filedes "fd".
*
* Returns the number of databits (1 or 2), or -1 if "fd" does not
* correspond to a managed filedes.
*/
int term_get_stopbits (int fd);
/* F term_get_flowcntrl
*
* Reads and decodes the current flow-control settings in the
* "currtermios" structure of the managed filedes "fd".
*
* Returns one of the "enum flowcntrl_e" members, or -1 if "fd" does
* not correspond to a managed filedes.
*/
enum flowcntrl_e term_get_flowcntrl (int fd);
/* F term_pulse_dtr
*
* Pulses the DTR line of the device associated with the managed