mirror of
https://github.com/UzixLS/picocom.git
synced 2025-07-19 07:21:18 +03:00
Merge branch 'Joe-Merten-whitespace-cleanup'
This commit is contained in:
14
LICENSE.txt
14
LICENSE.txt
@ -1,12 +1,12 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
@ -56,7 +56,7 @@ patent must be licensed for everyone's free use or not licensed at all.
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
@ -255,7 +255,7 @@ make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
@ -277,9 +277,9 @@ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
|
86
README.md
86
README.md
@ -57,8 +57,8 @@ man-page, to wherever you put your binaries and man-pages. For
|
||||
example:
|
||||
|
||||
|
||||
cp picocom ~/bin
|
||||
cp picocom.1 ~/man/man1
|
||||
cp picocom ~/bin
|
||||
cp picocom.1 ~/man/man1
|
||||
|
||||
Again, this is not strictly necessary. You can run picocom and read
|
||||
its man-page directly from the source directory.
|
||||
@ -71,15 +71,15 @@ by commenting in or out the respective lines. Once you edit the
|
||||
Makefile, to recompile say:
|
||||
|
||||
|
||||
make clean
|
||||
make
|
||||
make clean
|
||||
make
|
||||
|
||||
If your system's default make(1) command is not GNU Make (or
|
||||
compatible enough), find out how you can run GNU Make on your
|
||||
system. For example:
|
||||
|
||||
gmake clean
|
||||
gmake
|
||||
gmake clean
|
||||
gmake
|
||||
|
||||
Alternatively, you might have to make some trivial edits to the
|
||||
Makefile for it to work with your system's make(1) command.
|
||||
@ -102,22 +102,22 @@ 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
|
||||
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
|
||||
./picocom /dev/ttyS0
|
||||
|
||||
If this fails with a message like:
|
||||
|
||||
FATAL: cannot open /dev/ttyS0: Permission denied
|
||||
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
|
||||
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
|
||||
@ -125,7 +125,7 @@ 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
|
||||
sudo usermod -a -G dialout username
|
||||
|
||||
You will need to log-out and then log-in back again for this change to
|
||||
take effect.
|
||||
@ -135,20 +135,20 @@ 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
|
||||
picocom -b 115200 -f h /dev/ttyS0
|
||||
|
||||
or:
|
||||
|
||||
picocom --baud 115200 --flow h /dev/ttyS0
|
||||
picocom --baud 115200 --flow h /dev/ttyS0
|
||||
|
||||
To see all available options run picocom like this:
|
||||
|
||||
picocom --help
|
||||
picocom --help
|
||||
|
||||
Once picocom starts, it initializes the serial port and prints the
|
||||
message:
|
||||
|
||||
Terminal is ready
|
||||
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
|
||||
@ -160,7 +160,7 @@ terminal. This is normal.
|
||||
|
||||
To exit picocom you have to type:
|
||||
|
||||
C-a, C-x
|
||||
C-a, C-x
|
||||
|
||||
Which means you have to type [Control-A] followed by [Control-X]. You
|
||||
can do this by pressing and holding down the [Control] key, then
|
||||
@ -177,11 +177,11 @@ 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.1
|
||||
man ./picocom.1
|
||||
|
||||
or (assuming you have installed the manual page to a suitable place):
|
||||
|
||||
man picocom
|
||||
man picocom
|
||||
|
||||
Thanks for using picocom
|
||||
|
||||
@ -198,7 +198,7 @@ access these console ports remotely.
|
||||
If you provide shell-access to termbox for your users, then it's as
|
||||
simple as having the users say (from their remote workstations):
|
||||
|
||||
$ ssh -t user@termbox picocom -b 115200 /dev/ttyS0
|
||||
$ ssh -t user@termbox picocom -b 115200 /dev/ttyS0
|
||||
|
||||
Or make a convenient script/alias for this. Remember the `-t` switch
|
||||
which instructs ssh to create a pseudo-tty, otherwise picocom won't
|
||||
@ -213,7 +213,7 @@ go from Linux to other Unix-like systems.
|
||||
|
||||
Login to termbox and create a user called _termbox_:
|
||||
|
||||
$ sudo useradd -r -m termbox
|
||||
$ sudo useradd -r -m termbox
|
||||
|
||||
The `-r` means "system account", and the `-m` means *do* make the
|
||||
home-directory. Mostly we need this account's home-directory as a
|
||||
@ -223,48 +223,48 @@ password.
|
||||
Switch to the _termbox_ account and create a `bin` directory in its
|
||||
home-dir.
|
||||
|
||||
$ sudo su termbox
|
||||
$ cd ~
|
||||
$ mkdir bin
|
||||
$ sudo su termbox
|
||||
$ cd ~
|
||||
$ mkdir bin
|
||||
|
||||
Copy the picocom binary in `~termbox/bin` (if you don't have it
|
||||
globally installed):
|
||||
|
||||
$ cp /path/to/picocom ./bin
|
||||
$ cp /path/to/picocom ./bin
|
||||
|
||||
For every serial port you want to provide access to, create a file
|
||||
named after the port and put it in `~termbox/bin`. It should look like
|
||||
this:
|
||||
|
||||
$ cat ./bin/ttyS0
|
||||
#!/bin/sh
|
||||
exec /home/termbox/bin/picocom \
|
||||
--send-cmd '' \
|
||||
--receive-cmd '' \
|
||||
-b 115200 \
|
||||
/dev/ttyS0
|
||||
$ cat ./bin/ttyS0
|
||||
#!/bin/sh
|
||||
exec /home/termbox/bin/picocom \
|
||||
--send-cmd '' \
|
||||
--receive-cmd '' \
|
||||
-b 115200 \
|
||||
/dev/ttyS0
|
||||
|
||||
And make it executable:
|
||||
|
||||
$ chmod +x ./bin/ttyS0
|
||||
$ chmod +x ./bin/ttyS0
|
||||
|
||||
Repeat accordingly for every other port. Now the contents of
|
||||
`~termbox/bin` should look like this:
|
||||
|
||||
$ ls -l ./bin
|
||||
-rwxrwxr-x 1 termbox termbox 102128 Aug 29 13:56 picocom*
|
||||
-rwxrwxr-x 1 termbox termbox 108 Aug 29 14:07 ttyS0*
|
||||
-rwxrwxr-x 1 termbox termbox 108 Aug 29 14:07 ttyS1*
|
||||
... and so on ...
|
||||
$ ls -l ./bin
|
||||
-rwxrwxr-x 1 termbox termbox 102128 Aug 29 13:56 picocom*
|
||||
-rwxrwxr-x 1 termbox termbox 108 Aug 29 14:07 ttyS0*
|
||||
-rwxrwxr-x 1 termbox termbox 108 Aug 29 14:07 ttyS1*
|
||||
... and so on ...
|
||||
|
||||
Exit the _termbox_ account:
|
||||
|
||||
$ exit
|
||||
$ exit
|
||||
|
||||
Now, for every serial port, create a user account named after the
|
||||
port, like this:
|
||||
|
||||
$ sudo useradd -r -g dialout -d ~termbox -M -s ~termbox/bin/ttyS0 ttyS0
|
||||
$ sudo useradd -r -g dialout -d ~termbox -M -s ~termbox/bin/ttyS0 ttyS0
|
||||
|
||||
Observe that we make `dialout` the default group for this account, so
|
||||
the account has access to the serial ports. Also observe that we make
|
||||
@ -280,9 +280,9 @@ useradd create the usual `/home/ttyS0`.
|
||||
|
||||
Then set a password for the newly created account:
|
||||
|
||||
$ sudo passwd ttyS0
|
||||
Enter new UNIX password: ******
|
||||
Retype new UNIX password: ******
|
||||
$ sudo passwd ttyS0
|
||||
Enter new UNIX password: ******
|
||||
Retype new UNIX password: ******
|
||||
|
||||
Repeat (create user account, set password) for every port you want to
|
||||
give access to.
|
||||
@ -290,7 +290,7 @@ give access to.
|
||||
You 're set. All a user has to do to remotely access the console
|
||||
connected to termbox's `/dev/ttyS0` port, is:
|
||||
|
||||
ssh ttyS0@termbox
|
||||
ssh ttyS0@termbox
|
||||
|
||||
Some interesting points:
|
||||
|
||||
|
@ -150,25 +150,25 @@ struct linenoiseState {
|
||||
};
|
||||
|
||||
enum KEY_ACTION{
|
||||
KEY_NULL = 0, /* NULL */
|
||||
CTRL_A = 1, /* Ctrl+a */
|
||||
CTRL_B = 2, /* Ctrl-b */
|
||||
CTRL_C = 3, /* Ctrl-c */
|
||||
CTRL_D = 4, /* Ctrl-d */
|
||||
CTRL_E = 5, /* Ctrl-e */
|
||||
CTRL_F = 6, /* Ctrl-f */
|
||||
CTRL_H = 8, /* Ctrl-h */
|
||||
TAB = 9, /* Tab */
|
||||
CTRL_K = 11, /* Ctrl+k */
|
||||
CTRL_L = 12, /* Ctrl+l */
|
||||
ENTER = 13, /* Enter */
|
||||
CTRL_N = 14, /* Ctrl-n */
|
||||
CTRL_P = 16, /* Ctrl-p */
|
||||
CTRL_T = 20, /* Ctrl-t */
|
||||
CTRL_U = 21, /* Ctrl+u */
|
||||
CTRL_W = 23, /* Ctrl+w */
|
||||
ESC = 27, /* Escape */
|
||||
BACKSPACE = 127 /* Backspace */
|
||||
KEY_NULL = 0, /* NULL */
|
||||
CTRL_A = 1, /* Ctrl+a */
|
||||
CTRL_B = 2, /* Ctrl-b */
|
||||
CTRL_C = 3, /* Ctrl-c */
|
||||
CTRL_D = 4, /* Ctrl-d */
|
||||
CTRL_E = 5, /* Ctrl-e */
|
||||
CTRL_F = 6, /* Ctrl-f */
|
||||
CTRL_H = 8, /* Ctrl-h */
|
||||
TAB = 9, /* Tab */
|
||||
CTRL_K = 11, /* Ctrl+k */
|
||||
CTRL_L = 12, /* Ctrl+l */
|
||||
ENTER = 13, /* Enter */
|
||||
CTRL_N = 14, /* Ctrl-n */
|
||||
CTRL_P = 16, /* Ctrl-p */
|
||||
CTRL_T = 20, /* Ctrl-t */
|
||||
CTRL_U = 21, /* Ctrl+u */
|
||||
CTRL_W = 23, /* Ctrl+w */
|
||||
ESC = 27, /* Escape */
|
||||
BACKSPACE = 127 /* Backspace */
|
||||
};
|
||||
|
||||
static void linenoiseAtExit(void);
|
||||
|
64
term.h
64
term.h
@ -122,31 +122,31 @@
|
||||
* See the error strings in "term.c" for a description of each.
|
||||
*/
|
||||
enum term_errno_e {
|
||||
TERM_EOK = 0,
|
||||
TERM_ENOINIT,
|
||||
TERM_EFULL,
|
||||
TERM_EOK = 0,
|
||||
TERM_ENOINIT,
|
||||
TERM_EFULL,
|
||||
TERM_ENOTFOUND,
|
||||
TERM_EEXISTS,
|
||||
TERM_EATEXIT,
|
||||
TERM_EISATTY,
|
||||
TERM_EFLUSH, /* see errno */
|
||||
TERM_EGETATTR, /* see errno */
|
||||
TERM_ESETATTR, /* see errno */
|
||||
TERM_EBAUD,
|
||||
TERM_ESETOSPEED,
|
||||
TERM_ESETISPEED,
|
||||
TERM_EGETSPEED,
|
||||
TERM_EPARITY,
|
||||
TERM_EDATABITS,
|
||||
TERM_ESTOPBITS,
|
||||
TERM_EFLOW,
|
||||
TERM_EDTRDOWN,
|
||||
TERM_EDTRUP,
|
||||
TERM_EMCTL,
|
||||
TERM_EDRAIN, /* see errno */
|
||||
TERM_EBREAK,
|
||||
TERM_ERTSDOWN,
|
||||
TERM_ERTSUP
|
||||
TERM_EGETATTR, /* see errno */
|
||||
TERM_ESETATTR, /* see errno */
|
||||
TERM_EBAUD,
|
||||
TERM_ESETOSPEED,
|
||||
TERM_ESETISPEED,
|
||||
TERM_EGETSPEED,
|
||||
TERM_EPARITY,
|
||||
TERM_EDATABITS,
|
||||
TERM_ESTOPBITS,
|
||||
TERM_EFLOW,
|
||||
TERM_EDTRDOWN,
|
||||
TERM_EDTRUP,
|
||||
TERM_EMCTL,
|
||||
TERM_EDRAIN, /* see errno */
|
||||
TERM_EBREAK,
|
||||
TERM_ERTSDOWN,
|
||||
TERM_ERTSUP
|
||||
};
|
||||
|
||||
/* E parity_e
|
||||
@ -160,11 +160,11 @@ enum term_errno_e {
|
||||
* P_SPACE - space parity (parity bit always 0)
|
||||
*/
|
||||
enum parity_e {
|
||||
P_NONE = 0,
|
||||
P_EVEN,
|
||||
P_ODD,
|
||||
P_MARK,
|
||||
P_SPACE
|
||||
P_NONE = 0,
|
||||
P_EVEN,
|
||||
P_ODD,
|
||||
P_MARK,
|
||||
P_SPACE
|
||||
};
|
||||
|
||||
/*
|
||||
@ -178,10 +178,10 @@ enum parity_e {
|
||||
* FC_XONXOFF - xon/xoff flow control.
|
||||
*/
|
||||
enum flowcntrl_e {
|
||||
FC_NONE = 0,
|
||||
FC_RTSCTS,
|
||||
FC_XONXOFF,
|
||||
FC_OTHER
|
||||
FC_NONE = 0,
|
||||
FC_RTSCTS,
|
||||
FC_XONXOFF,
|
||||
FC_OTHER
|
||||
};
|
||||
|
||||
/*
|
||||
@ -524,9 +524,9 @@ int term_set (int fd,
|
||||
int raw,
|
||||
int baud,
|
||||
enum parity_e parity,
|
||||
int databits, int stopbits,
|
||||
enum flowcntrl_e fc,
|
||||
int local, int hupcl);
|
||||
int databits, int stopbits,
|
||||
enum flowcntrl_e fc,
|
||||
int local, int hupcl);
|
||||
|
||||
/* F term_get_baudrate
|
||||
*
|
||||
|
150
termios2.c
150
termios2.c
@ -54,59 +54,59 @@
|
||||
int
|
||||
tc2setattr(int fd, int optional_actions, const struct termios *tios)
|
||||
{
|
||||
struct termios2 t2;
|
||||
int cmd;
|
||||
struct termios2 t2;
|
||||
int cmd;
|
||||
|
||||
switch (optional_actions) {
|
||||
case TCSANOW:
|
||||
cmd = IOCTL_SETS;
|
||||
break;
|
||||
case TCSADRAIN:
|
||||
cmd = IOCTL_SETSW;
|
||||
break;
|
||||
case TCSAFLUSH:
|
||||
cmd = IOCTL_SETSF;
|
||||
break;
|
||||
default:
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
switch (optional_actions) {
|
||||
case TCSANOW:
|
||||
cmd = IOCTL_SETS;
|
||||
break;
|
||||
case TCSADRAIN:
|
||||
cmd = IOCTL_SETSW;
|
||||
break;
|
||||
case TCSAFLUSH:
|
||||
cmd = IOCTL_SETSF;
|
||||
break;
|
||||
default:
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
t2.c_iflag = tios->c_iflag & ~IBAUD0;
|
||||
t2.c_oflag = tios->c_oflag;
|
||||
t2.c_cflag = tios->c_cflag;
|
||||
t2.c_lflag = tios->c_lflag;
|
||||
t2.c_line = tios->c_line;
|
||||
t2.c_ispeed = tios->c_ispeed;
|
||||
t2.c_ospeed = tios->c_ospeed;
|
||||
memcpy(&t2.c_cc[0], &tios->c_cc[0], K_NCCS * sizeof (cc_t));
|
||||
t2.c_iflag = tios->c_iflag & ~IBAUD0;
|
||||
t2.c_oflag = tios->c_oflag;
|
||||
t2.c_cflag = tios->c_cflag;
|
||||
t2.c_lflag = tios->c_lflag;
|
||||
t2.c_line = tios->c_line;
|
||||
t2.c_ispeed = tios->c_ispeed;
|
||||
t2.c_ospeed = tios->c_ospeed;
|
||||
memcpy(&t2.c_cc[0], &tios->c_cc[0], K_NCCS * sizeof (cc_t));
|
||||
|
||||
return ioctl(fd, cmd, &t2);
|
||||
return ioctl(fd, cmd, &t2);
|
||||
}
|
||||
|
||||
int
|
||||
tc2getattr(int fd, struct termios *tios)
|
||||
{
|
||||
struct termios2 t2;
|
||||
size_t i;
|
||||
int r;
|
||||
struct termios2 t2;
|
||||
size_t i;
|
||||
int r;
|
||||
|
||||
r = ioctl(fd, IOCTL_GETS, &t2);
|
||||
if (r < 0) return r;
|
||||
r = ioctl(fd, IOCTL_GETS, &t2);
|
||||
if (r < 0) return r;
|
||||
|
||||
tios->c_iflag = t2.c_iflag;
|
||||
tios->c_oflag = t2.c_oflag;
|
||||
tios->c_cflag = t2.c_cflag;
|
||||
tios->c_lflag = t2.c_lflag;
|
||||
tios->c_line = t2.c_line;
|
||||
tios->c_ispeed = t2.c_ispeed;
|
||||
tios->c_ospeed = t2.c_ospeed;
|
||||
memcpy(&tios->c_cc[0], &t2.c_cc[0], K_NCCS * sizeof (cc_t));
|
||||
tios->c_iflag = t2.c_iflag;
|
||||
tios->c_oflag = t2.c_oflag;
|
||||
tios->c_cflag = t2.c_cflag;
|
||||
tios->c_lflag = t2.c_lflag;
|
||||
tios->c_line = t2.c_line;
|
||||
tios->c_ispeed = t2.c_ispeed;
|
||||
tios->c_ospeed = t2.c_ospeed;
|
||||
memcpy(&tios->c_cc[0], &t2.c_cc[0], K_NCCS * sizeof (cc_t));
|
||||
|
||||
for (i = K_NCCS; i < NCCS; i++)
|
||||
tios->c_cc[i] = _POSIX_VDISABLE;
|
||||
for (i = K_NCCS; i < NCCS; i++)
|
||||
tios->c_cc[i] = _POSIX_VDISABLE;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* The termios2 interface supports separate input and output
|
||||
@ -124,22 +124,22 @@ tc2getattr(int fd, struct termios *tios)
|
||||
int
|
||||
cf2setispeed(struct termios *tios, speed_t speed)
|
||||
{
|
||||
if ( (speed & ~CBAUD) != 0
|
||||
&& (speed < B57600 || speed > __MAX_BAUD) ) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
tios->c_ispeed = speed;
|
||||
tios->c_cflag &= ~((CBAUD | CBAUDEX) << IBSHIFT);
|
||||
tios->c_cflag |= (speed << IBSHIFT);
|
||||
if ( (speed & ~CBAUD) != 0
|
||||
&& (speed < B57600 || speed > __MAX_BAUD) ) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
tios->c_ispeed = speed;
|
||||
tios->c_cflag &= ~((CBAUD | CBAUDEX) << IBSHIFT);
|
||||
tios->c_cflag |= (speed << IBSHIFT);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
speed_t
|
||||
cf2getispeed(struct termios *tios)
|
||||
{
|
||||
return (tios->c_cflag >> IBSHIFT) & (CBAUD | CBAUDEX);
|
||||
return (tios->c_cflag >> IBSHIFT) & (CBAUD | CBAUDEX);
|
||||
}
|
||||
|
||||
/* Use these to set custom input or output speeds (i.e. speeds that do
|
||||
@ -148,37 +148,37 @@ cf2getispeed(struct termios *tios)
|
||||
int
|
||||
cf2setospeed_custom(struct termios *tios, int speed)
|
||||
{
|
||||
if ( speed <= 0 ) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
tios->c_cflag &= ~(CBAUD | CBAUDEX);
|
||||
tios->c_cflag |= BOTHER;
|
||||
tios->c_ospeed = speed;
|
||||
if ( speed <= 0 ) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
tios->c_cflag &= ~(CBAUD | CBAUDEX);
|
||||
tios->c_cflag |= BOTHER;
|
||||
tios->c_ospeed = speed;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
cf2setispeed_custom(struct termios *tios, int speed)
|
||||
{
|
||||
if ( speed < 0 ) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if ( speed == 0 ) {
|
||||
/* Special case: ispeed == 0 means "same as ospeed". Kernel
|
||||
does this if it sees B0 in the "CIBAUD" field (i.e. in
|
||||
CBAUD << IBSHIFT) */
|
||||
tios->c_cflag &= ~((CBAUD | CBAUDEX) << IBSHIFT);
|
||||
tios->c_cflag |= (B0 << IBSHIFT);
|
||||
} else {
|
||||
tios->c_cflag &= ~((CBAUD | CBAUDEX) << IBSHIFT);
|
||||
tios->c_cflag |= (BOTHER << IBSHIFT);
|
||||
tios->c_ispeed = speed;
|
||||
}
|
||||
if ( speed < 0 ) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if ( speed == 0 ) {
|
||||
/* Special case: ispeed == 0 means "same as ospeed". Kernel
|
||||
does this if it sees B0 in the "CIBAUD" field (i.e. in
|
||||
CBAUD << IBSHIFT) */
|
||||
tios->c_cflag &= ~((CBAUD | CBAUDEX) << IBSHIFT);
|
||||
tios->c_cflag |= (B0 << IBSHIFT);
|
||||
} else {
|
||||
tios->c_cflag &= ~((CBAUD | CBAUDEX) << IBSHIFT);
|
||||
tios->c_cflag |= (BOTHER << IBSHIFT);
|
||||
tios->c_ispeed = speed;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
Reference in New Issue
Block a user