mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 09:27:59 +00:00
Patch from Alan Clucas (somewhat polished) providing command-line
options to select and configure serial port mode. [originally from svn r8617]
This commit is contained in:
parent
1e81efc2db
commit
f3ac927d33
103
cmdline.c
103
cmdline.c
@ -192,6 +192,16 @@ int cmdline_process_param(char *p, char *value, int need_save, Config *cfg)
|
||||
SAVEABLE(0);
|
||||
default_protocol = cfg->protocol = PROT_RAW;
|
||||
}
|
||||
if (!strcmp(p, "-serial")) {
|
||||
RETURN(1);
|
||||
/* Serial is not NONNETWORK in an odd sense of the word */
|
||||
UNAVAILABLE_IN(TOOLTYPE_FILETRANSFER | TOOLTYPE_NONNETWORK);
|
||||
SAVEABLE(0);
|
||||
default_protocol = cfg->protocol = PROT_SERIAL;
|
||||
/* The host parameter will already be loaded into cfg->host, so copy it across */
|
||||
strncpy(cfg->serline, cfg->host, sizeof(cfg->serline) - 1);
|
||||
cfg->serline[sizeof(cfg->serline) - 1] = '\0';
|
||||
}
|
||||
if (!strcmp(p, "-v")) {
|
||||
RETURN(1);
|
||||
flags |= FLAG_VERBOSE;
|
||||
@ -435,7 +445,100 @@ int cmdline_process_param(char *p, char *value, int need_save, Config *cfg)
|
||||
SAVEABLE(1);
|
||||
cfg->addressfamily = ADDRTYPE_IPV6;
|
||||
}
|
||||
if (!strcmp(p, "-sercfg")) {
|
||||
char* nextitem;
|
||||
RETURN(2);
|
||||
UNAVAILABLE_IN(TOOLTYPE_FILETRANSFER | TOOLTYPE_NONNETWORK);
|
||||
SAVEABLE(1);
|
||||
if (cfg->protocol != PROT_SERIAL)
|
||||
cmdline_error("the -sercfg option can only be used with the "
|
||||
"serial protocol");
|
||||
/* Value[0] contains one or more , separated values, like 19200,8,n,1,X */
|
||||
nextitem = value;
|
||||
while (nextitem[0] != '\0') {
|
||||
int length, skip;
|
||||
char *end = strchr(nextitem, ',');
|
||||
if (!end) {
|
||||
length = strlen(nextitem);
|
||||
skip = 0;
|
||||
} else {
|
||||
length = end - nextitem;
|
||||
nextitem[length] = '\0';
|
||||
skip = 1;
|
||||
}
|
||||
if (length == 1) {
|
||||
switch (*nextitem) {
|
||||
case '1':
|
||||
cfg->serstopbits = 2;
|
||||
break;
|
||||
case '2':
|
||||
cfg->serstopbits = 4;
|
||||
break;
|
||||
|
||||
case '5':
|
||||
cfg->serdatabits = 5;
|
||||
break;
|
||||
case '6':
|
||||
cfg->serdatabits = 6;
|
||||
break;
|
||||
case '7':
|
||||
cfg->serdatabits = 7;
|
||||
break;
|
||||
case '8':
|
||||
cfg->serdatabits = 8;
|
||||
break;
|
||||
case '9':
|
||||
cfg->serdatabits = 9;
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
cfg->serparity = SER_PAR_NONE;
|
||||
break;
|
||||
case 'o':
|
||||
cfg->serparity = SER_PAR_ODD;
|
||||
break;
|
||||
case 'e':
|
||||
cfg->serparity = SER_PAR_EVEN;
|
||||
break;
|
||||
case 'm':
|
||||
cfg->serparity = SER_PAR_MARK;
|
||||
break;
|
||||
case 's':
|
||||
cfg->serparity = SER_PAR_SPACE;
|
||||
break;
|
||||
|
||||
case 'N':
|
||||
cfg->serflow = SER_FLOW_NONE;
|
||||
break;
|
||||
case 'X':
|
||||
cfg->serflow = SER_FLOW_XONXOFF;
|
||||
break;
|
||||
case 'R':
|
||||
cfg->serflow = SER_FLOW_RTSCTS;
|
||||
break;
|
||||
case 'D':
|
||||
cfg->serflow = SER_FLOW_DSRDTR;
|
||||
break;
|
||||
|
||||
default:
|
||||
cmdline_error("Unrecognised suboption \"-sercfg %c\"",
|
||||
*nextitem);
|
||||
}
|
||||
} else if (length == 3 && !strncmp(nextitem,"1.5",3)) {
|
||||
/* Messy special case */
|
||||
cfg->serstopbits = 3;
|
||||
} else {
|
||||
int serspeed = atoi(nextitem);
|
||||
if (serspeed != 0) {
|
||||
cfg->serspeed = serspeed;
|
||||
} else {
|
||||
cmdline_error("Unrecognised suboption \"-sercfg %s\"",
|
||||
nextitem);
|
||||
}
|
||||
}
|
||||
nextitem += length + skip;
|
||||
}
|
||||
}
|
||||
return ret; /* unrecognised */
|
||||
}
|
||||
|
||||
|
@ -206,6 +206,7 @@ saved sessions from
|
||||
\IM{-raw} \c{-raw} command-line option
|
||||
\IM{-rlogin} \c{-rlogin} command-line option
|
||||
\IM{-ssh} \c{-ssh} command-line option
|
||||
\IM{-serial} \c{-serial} command-line option
|
||||
\IM{-cleanup} \c{-cleanup} command-line option
|
||||
\IM{-load} \c{-load} command-line option
|
||||
\IM{-v} \c{-v} command-line option
|
||||
@ -228,6 +229,7 @@ saved sessions from
|
||||
\IM{-2} \c{-2} command-line option
|
||||
\IM{-i} \c{-i} command-line option
|
||||
\IM{-pgpfp} \c{-pgpfp} command-line option
|
||||
\IM{-sercfg} \c{-sercfg} command-line option
|
||||
|
||||
\IM{removing registry entries} removing registry entries
|
||||
\IM{removing registry entries} registry entries, removing
|
||||
|
@ -52,6 +52,10 @@ to aid in verifying new files released by the PuTTY team.
|
||||
|
||||
\dd Force raw mode.
|
||||
|
||||
\dt \cw{-serial}
|
||||
|
||||
\dd Force serial mode.
|
||||
|
||||
\dt \cw{-P} \e{port}
|
||||
|
||||
\dd Connect to port \e{port}.
|
||||
@ -145,6 +149,29 @@ tunnel all their connections. Only works in SSH.
|
||||
|
||||
\dd Don't start a remote command or shell at all (SSH-2 only).
|
||||
|
||||
\dt \cw{\-sercfg} \e{configuration-string}
|
||||
|
||||
\dd Specify the configuration parameters for the serial port, in
|
||||
\cw{-serial} mode. \e{configuration-string} should be a
|
||||
comma-separated list of configuration parameters as follows:
|
||||
|
||||
\lcont{
|
||||
|
||||
\b Any single digit from 5 to 9 sets the number of data bits.
|
||||
|
||||
\b \cq{1}, \cq{1.5} or \cq{2} sets the number of stop bits.
|
||||
|
||||
\b Any other numeric string is interpreted as a baud rate.
|
||||
|
||||
\b A single lower-case letter specifies the parity: \cq{n} for none,
|
||||
\cq{o} for odd, \cq{e} for even, \cq{m} for mark and \cq{s} for space.
|
||||
|
||||
\b A single upper-case letter specifies the flow control: \cq{N} for
|
||||
none, \cq{X} for XON/XOFF, \cq{R} for RTS/CTS and \cq{D} for
|
||||
DSR/DTR.
|
||||
|
||||
}
|
||||
|
||||
\S{plink-manpage-more-information} MORE INFORMATION
|
||||
|
||||
For more information on plink, it's probably best to go and look at
|
||||
|
@ -160,7 +160,7 @@ in verifying new files released by the PuTTY team.
|
||||
straight from the command line without having to go through the
|
||||
configuration box first.
|
||||
|
||||
\dt \cw{\-ssh}, \cw{\-telnet}, \cw{\-rlogin}, \cw{\-raw}
|
||||
\dt \cw{\-ssh}, \cw{\-telnet}, \cw{\-rlogin}, \cw{\-raw}, \cw{\-serial}
|
||||
|
||||
\dd Select the protocol \cw{putty} will use to make the connection.
|
||||
|
||||
@ -223,6 +223,29 @@ pseudo-terminal at the server end.
|
||||
keys, this key file must be in PuTTY's format, not OpenSSH's or
|
||||
anyone else's.
|
||||
|
||||
\dt \cw{\-sercfg} \e{configuration-string}
|
||||
|
||||
\dd Specify the configuration parameters for the serial port, in
|
||||
\cw{-serial} mode. \e{configuration-string} should be a
|
||||
comma-separated list of configuration parameters as follows:
|
||||
|
||||
\lcont{
|
||||
|
||||
\b Any single digit from 5 to 9 sets the number of data bits.
|
||||
|
||||
\b \cq{1}, \cq{1.5} or \cq{2} sets the number of stop bits.
|
||||
|
||||
\b Any other numeric string is interpreted as a baud rate.
|
||||
|
||||
\b A single lower-case letter specifies the parity: \cq{n} for none,
|
||||
\cq{o} for odd, \cq{e} for even, \cq{m} for mark and \cq{s} for space.
|
||||
|
||||
\b A single upper-case letter specifies the flow control: \cq{N} for
|
||||
none, \cq{X} for XON/XOFF, \cq{R} for RTS/CTS and \cq{D} for
|
||||
DSR/DTR.
|
||||
|
||||
}
|
||||
|
||||
\S{putty-manpage-saved-sessions} SAVED SESSIONS
|
||||
|
||||
Saved sessions are stored in a \cw{.putty/sessions} subdirectory in
|
||||
|
@ -51,7 +51,7 @@ use Plink:
|
||||
\c -pgpfp print PGP key fingerprints and exit
|
||||
\c -v show verbose messages
|
||||
\c -load sessname Load settings from saved session
|
||||
\c -ssh -telnet -rlogin -raw
|
||||
\c -ssh -telnet -rlogin -raw -serial
|
||||
\c force use of a particular protocol
|
||||
\c -P port connect to specified port
|
||||
\c -l user connect with specified username
|
||||
@ -78,6 +78,8 @@ use Plink:
|
||||
\c -N don't start a shell/command (SSH-2 only)
|
||||
\c -nc host:port
|
||||
\c open tunnel in place of session (SSH-2 only)
|
||||
\c -sercfg configuration-string (e.g. 19200,8,n,1,X)
|
||||
\c Specify the serial configuration (serial only)
|
||||
|
||||
Once this works, you are ready to use Plink.
|
||||
|
||||
|
@ -550,9 +550,9 @@ window}, or a \i{Windows shortcut}).
|
||||
|
||||
\S{using-cmdline-session} Starting a session from the command line
|
||||
|
||||
\I\c{-ssh}\I\c{-telnet}\I\c{-rlogin}\I\c{-raw}These options allow
|
||||
you to bypass the configuration window and launch straight into a
|
||||
session.
|
||||
\I\c{-ssh}\I\c{-telnet}\I\c{-rlogin}\I\c{-raw}\I\c{-serial}These
|
||||
options allow you to bypass the configuration window and launch
|
||||
straight into a session.
|
||||
|
||||
To start a connection to a server called \c{host}:
|
||||
|
||||
@ -569,6 +569,10 @@ URLs} in web browsers):
|
||||
|
||||
\c putty.exe telnet://host[:port]/
|
||||
|
||||
To start a connection to a serial port, e.g. COM1:
|
||||
|
||||
\c putty.exe -serial com1
|
||||
|
||||
In order to start an existing saved session called \c{sessionname},
|
||||
use the \c{-load} option (described in \k{using-cmdline-load}).
|
||||
|
||||
@ -618,7 +622,7 @@ must be the very first thing on the command line. This form of the
|
||||
option is deprecated.)
|
||||
|
||||
\S2{using-cmdline-protocol} Selecting a protocol: \c{-ssh},
|
||||
\c{-telnet}, \c{-rlogin}, \c{-raw}
|
||||
\c{-telnet}, \c{-rlogin}, \c{-raw} \c{-serial}
|
||||
|
||||
To choose which protocol you want to connect with, you can use one
|
||||
of these options:
|
||||
@ -631,6 +635,8 @@ of these options:
|
||||
|
||||
\b \i\c{-raw} selects the raw protocol.
|
||||
|
||||
\b \i\c{-serial} selects a serial connection.
|
||||
|
||||
These options are not available in the file transfer tools PSCP and
|
||||
PSFTP (which only work with the SSH protocol).
|
||||
|
||||
@ -915,3 +921,27 @@ on this.
|
||||
This option causes the PuTTY tools not to run as normal, but instead
|
||||
to display the fingerprints of the PuTTY PGP Master Keys, in order to
|
||||
aid with \i{verifying new versions}. See \k{pgpkeys} for more information.
|
||||
|
||||
\S2{using-cmdline-sercfg} \i\c{-sercfg}: specify serial port
|
||||
\i{configuration}
|
||||
|
||||
This option specifies the configuration parameters for the serial
|
||||
port (baud rate, stop bits etc). Its argument is interpreted as a
|
||||
comma-separated list of configuration options, which can be as
|
||||
follows:
|
||||
|
||||
\b Any single digit from 5 to 9 sets the number of data bits.
|
||||
|
||||
\b \cq{1}, \cq{1.5} or \cq{2} sets the number of stop bits.
|
||||
|
||||
\b Any other numeric string is interpreted as a baud rate.
|
||||
|
||||
\b A single lower-case letter specifies the parity: \cq{n} for none,
|
||||
\cq{o} for odd, \cq{e} for even, \cq{m} for mark and \cq{s} for space.
|
||||
|
||||
\b A single upper-case letter specifies the flow control: \cq{N} for
|
||||
none, \cq{X} for XON/XOFF, \cq{R} for RTS/CTS and \cq{D} for
|
||||
DSR/DTR.
|
||||
|
||||
For example, \cq{-sercfg 19200,8,n,1,N} denotes a baud rate of
|
||||
19200, 8 data bits, no parity, 1 stop bit and no flow control.
|
||||
|
@ -565,6 +565,8 @@ static void usage(void)
|
||||
printf(" -N don't start a shell/command (SSH-2 only)\n");
|
||||
printf(" -nc host:port\n");
|
||||
printf(" open tunnel in place of session (SSH-2 only)\n");
|
||||
printf(" -sercfg configuration-string (e.g. 19200,8,n,1,X)\n");
|
||||
printf(" Specify the serial configuration (serial only)\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -193,6 +193,8 @@ static void usage(void)
|
||||
printf(" -N don't start a shell/command (SSH-2 only)\n");
|
||||
printf(" -nc host:port\n");
|
||||
printf(" open tunnel in place of session (SSH-2 only)\n");
|
||||
printf(" -sercfg configuration-string (e.g. 19200,8,n,1,X)\n");
|
||||
printf(" Specify the serial configuration (serial only)\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user