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

51 Commits

Author SHA1 Message Date
ee23af0cb9 Disable custom baudrate support at runtime (Linux)
If picocom is compiled *with* custom-baudrate support (USE_CUSTOM_BAUD)
for Linux, then it uses a new set of ioctl's (TCGETS2 vs TCGETS, etc) to
access the serial ports. This patch allows the custom baudrate support
to be disabled at runtime (without recompiling), and picocom to switch
to using the old ioctl's.

To disable custom baudrate support (and switch back to the "old" ioctls)
simply define the environment variable NO_CUSTOM_BAUD, before starting
picocom.

This applies only to Linux and, obviously, only when picocom has been
compiled with custom baudrate support (USE_CUSTOM_BAUD).
2018-02-20 10:29:45 +02:00
8814974ac7 More enum type fixes
Try not to use lose enum type information through ints.
2018-02-11 10:04:58 +10:00
a412f6583a Type consistency tweaks
Better type consistency when returning enums flowcntrl_e and
parity_e. See also PR #92.
2018-02-10 10:04:14 +02:00
6d8bf34e9f Silence compiler warnings
- Comparisons between signed and unsigned
- Unused parameter

produced by gcc -Wall -Wextra
2018-02-09 19:00:56 +02:00
399d7f9480 Const correct some pointers 2018-02-09 18:52:08 +02:00
8eab62945d Close tty_fd after resetting and before exiting 2018-01-20 16:45:48 +02:00
2a120ef1df Comments 2018-01-20 16:44:43 +02:00
dabb708a8c Explicitly unlock tty_fd before exiting
Call flock(fd, LOCK_UN) explicitly for managed file at term_exitfunc().

This should, normally, not be necessary. Normally, exiting the program
should take care of unlocking the file. Unfortuntelly, it has been
observed that, on some systems, exiting or closing an flock(2)'ed tty fd
has peculiar side effects (like not reseting the modem-control lines,
even if HUPCL is set).
2018-01-20 13:19:51 +02:00
0ad57a2142 Comments 2018-01-17 20:44:48 +02:00
58e55a835f Updated email (comments) 2018-01-17 20:38:27 +02:00
8ca2e5a10f Better build support for custom baudrates
For some systems (OSes, versions, architectures) custom-baudrate
support is enabled by default.

For others, support may work, but must be enabled by defining
USE_CUSTOM_BAUD in the Makefile

You can also disable custom baudrate support altogether (even for
systems where it's enabled by default), by defining NO_CUSTOM_BAUD in
the Makefile
2018-01-16 03:46:09 +02:00
13904345f5 Reverted #84 initial refactoring, removing #define HAS_CUSTOM_BAUD 2018-01-16 00:49:35 +01:00
6ebb8c56fc #84: custom baudrate support for OpenBsd, and Dragonfly (but not NetBsd) 2018-01-15 23:30:30 +01:00
249cf8ea3c #84, added missing #endif 2018-01-15 20:35:00 +01:00
4776a5c781 #84, as suggested by Nick, surrounded platform specific headers by appropriated #ifdef 2018-01-15 20:33:05 +01:00
7a14651b93 #84: Manual control of handshake lines for OpenBsd, NetBsd and Dragonfly 2018-01-15 20:23:07 +01:00
f9e0b4c8a2 Small refactoring in term.c for bsd improvements
Introduced `#define HAS_CUSTOM_BAUD` for platforms which have appropriate implementation.

Moving that `#if defined(__linux__) && defined(USE_CUSTOM_BAUD)` ... stuff out of `term.c`and put it to `termios2.h` / `custbaud_bsd.h` headers.
Moving that platform specific `#ifdefs` to the platform specific headers helps removing duplicate complex `#ifdef` constructs.
The both platform specific headers then do `#define HAS_CUSTOM_BAUD` to signal that custom baudrate support is implemented for the target platform.
I'd tested all above mentioned platforms with both USE_CUSTOM_BAUD unset and set to check if that refactoring don't raises unexpected issues.
2018-01-15 19:47:46 +01:00
59fc43ef68 Raise / lower / pulse DTR related fixes
- Made functions term_[raise/lower]_dtr() work *only* by using the
  respective ioctl, not by setting the baudrate to 0. In case the ioctl
  is not supported for a system, the functions fail. Function
  term_pulse_dtr() still works by setting the baudrate to zero, if the
  ioctl is not supported. As a result, for systems without support for
  ioctls that set / clear the modem-control lines, DTR can only be
  pulsed, not toggled.

- When using tcsetattr() to pulse the DTR line (i.e. on systems where
  ioctls for setting / clearing the modem control lines are not
  supported), set only the output speed to B0, not both input and output
  speed.
2018-01-11 19:43:31 +02:00
cc8d142e2c Fixed #81, FreeBSD rts / dtr control 2018-01-02 15:19:42 +01:00
b78410aa04 #77: added custom baudrate support for FreeBSD 2017-12-31 07:32:23 +01:00
89be292023 Workaround for drivers with broken flush
term_flush() does not work with some drivers. If we try to drain or even
close the port while there are still data in it's output buffers *and*
flow-control is enabled, we may block forever. So we "fake" a flush, by
temporarily setting f/c to none, waiting for any data in the output
buffer to drain, and then reseting f/c to it's original setting.
2017-12-20 09:48:00 +02:00
82d69071c3 Fix HUPCL handling
Picocom will always set the HUPCL control bit of the serial port,
according to the --noreset option. If --noreset is given, then
HUPCL for the port is cleared, and will remain so after exiting
picocom. If --noreset is *not* given, then HUPCL is set for the
port, and will remain so after exiting picocom. This is true, regardless
of the way picocom terminates (command, read zero-bytes from standard
input, killed by signal, etc), and regardless of the --noinit
option. If picocom exits with the "Quit" command, then --noreset is
assumed given. Almost always this is the most DWIM behavior.

Fixes #72
2017-12-20 05:59:55 +02:00
33c2332c18 Set correct term_errno when tcflush fails. 2017-12-20 01:31:08 +02:00
d1f439b38d Moved drain delay into term.c 2017-12-17 22:14:08 +02:00
a502f76e5d OSX custom baudrates: fixed and refactored 2016-12-16 16:04:20 +01:00
13fd331d41 detabbing (by tab with 4) 2016-12-16 10:41:23 +01:00
b601136f56 stripped trailing whitespace 2016-12-16 10:29:20 +01:00
74e0245fb0 Extra OSX bauds only if HIGH_BAUD + comments
Define the extra (above 230K) baudate constants for OSX only if
HIGH_BAUD is defined.
2016-12-07 01:42:03 +02:00
4ef3280e6a added custom baudrate support for OSX 2016-12-06 21:59:59 +01:00
f5fbab2505 added high baudrate constants for OSX 2016-12-06 18:06:28 +01:00
3239ffb8a4 fixed manual rts & dtr control for OSX 2016-12-04 12:09:11 +01:00
2fe242cfb6 Only support toggle RTS command in Linux; fix a few spelling errors and typos in man page. 2016-10-15 10:13:00 -06:00
a30867c366 Add command to toggle RTS 2016-10-14 19:06:26 -06:00
72cab71ebd Define dummy CMSPAR (=0) if undefined
Some BSDs (and possibly other systems too) have no mark / space parity
support, and they don't define CMSPAR. Define a dummy (zero) CMSPAR in
these cases. If the user tries to set P_MARK or P_SPACE he will get
P_EVEN or P_ODD instead.
2015-10-15 23:42:43 +03:00
44fe603663 Define a standard CMSPAR, if undefined, only on Linux. 2015-10-08 12:10:26 +03:00
2c4c231759 term.c: define CMSPAR when a specific termios.h doesn't do it
CMSPAR is defined by bits/termios.h, and glibc has two flavours of it: a
generic one and an architecture-specific one. glibc will install the
architecture-specific one if it exists, otherwise it will install the
generic one. Only Alpha, MIPS, PPC and Sparc have their own
bits/termios.h.

The generic bits/termios.h, as well as the Alpha, PPC and Sparc flavours
do define CMSPAR. However, the MIPS flavour does not define it.

Define CMSPAR to the value from the generic value, which is also the
value known to the Linux kernel for MIPS.

Patch inspired by:

  http://git.buildroot.net/buildroot/commit/?id=78cd32631e959e04b1a2f18be7b0757e21482438

Signed-off-by: Vicente Olivert Riera <Vincent.Riera@imgtec.com>
2015-10-07 17:48:59 +01:00
3f627d5cff term.[ch]: Added term_get_mctl() function
Returns the status of modem-control lines (DTR, DSR, DCD, etc...).
2015-08-25 16:19:26 +03:00
d21c94eb75 Changed TCSAFLUSH to TCSANOW
In all cases the pattern was tcflush(fd, TCIOFLUSH) followed by
tcsetattr(fd, TCSAFLUSH, ...). The problem was that, for some drivers,
tcflush() was apparently doing nothing, so tcsetattr() might hang
forever waiting for the output buffers to drain (possible if flow
control is enabled). Replaced tcflush(fd, TCSAFLUSH), with tcsetattr(fd,
TCSANOW) which, after a tcflush() should anyway be equivalent.
2015-08-25 15:00:18 +03:00
5916997d40 Added term_baud_ok(). Check if baudrate is valid. 2015-08-22 16:49:57 +03:00
fd306077d6 Added support for setting custom baud rates.
If the requested baudrate is not a custom one (i.e. does not match one
of the Bxxx macros), then the cfsetospeed_custom() and
cfsetispeed_custom() are called to configure the "nexttermios" structure
with the requested non-standard baudrate. Same thing for reading the
baudrate: If cfgetospeed() and / or cfgetispeed() return a value that is
not among the Bxxx macros, cfgetospeed_custom() and cfgetispeed_custom()
are called, to read (and decode) the non-standard baudrate from the
"nexttermios" structure.

Currently the cf[set|get][i|o]speed_custom functions are only
implemented for Linux, and work only with non-ancient kernels (>2.6). So
in effect, custom baud-rate support is currently only supported for
Linux.
2015-08-20 12:40:28 +03:00
c24a3bcf41 Added support for setting and changing stopbits. 2015-08-19 00:15:19 +03:00
70971db6c1 Retry tcsetattr() on EINTR, for term_lib_init() and term_exitfunc()
In term_exitfunc() (which is called via atexit(3)) and
term_lib_init() (which resets ALL managed terminals to their original
attributes), if tcsetattr(3) fails with EINTR, try again.
2015-08-16 06:49:06 +03:00
e936f5bfe2 term_get_xxx functions and CMSPAR support.
Added functions to read and decode settings (baudrate, databits, parity,
flow-control) from the "currtermios" structure of a managed port.

Added support for "mark" and "space" parity (CMSPAR bit).
2015-08-14 20:14:54 +03:00
8135bbdd5f Re-read terminal attributes after applying them.
After applying settings to a terminal device, in functions term_reset(),
term_replace(), and term_apply(), re-read the setting from the device in
order to update "currtermios", "nexttermios", and "origtermios" as
required. Do not assume that the settings applied are the ones
effectively set to the device (some of them may be ignored, or changed
by the kernel or the driver).
2015-08-13 23:35:15 +03:00
801003c90e Fixed mis-typed constant for 4000000 bps baudrate 2015-08-13 19:39:25 +03:00
fabafeda48 Better baud-selection code. 2015-08-10 00:18:49 +03:00
efb45545c1 Clean-compile with Bionic libc (Android)
Added conditional since Bionic libc has no tcdrain.

Fixes #22
2015-08-07 04:15:04 +03:00
aa0bccf948 Added support for more high baud rates. See issue:
http://code.google.com/p/picocom/issues/detail?id=25

This should also fix issue:
  http://code.google.com/p/picocom/issues/detail?id=17

The following baud-rates are now supported:

Standard:

  0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600,
  19200, 38400, 57600, 115200,

HIGH_BAUD:

  230400, 460800, 500000, 576000, 921600, 1000000, 1152000, 1500000,
  2000000, 2500000, 3000000, 3500000, 4000000,

Now every baudrate above 115200 is compiled-in only if the respective
macros are defined in the system header files. This should allow
picocom with HIGH_BAUD support to compile cleanly for more systems.
2015-08-06 23:42:49 +00:00
3f81e9aca4 Fixed misconception that prevented the correct setting
of the odd-parity mode
2010-05-28 22:41:19 +00:00
8a48fc24aa Enabled support for higher baudrates up to 921600. Support is
compiled-in conditionally on the HIGH_BAUD macro.

Thanks to Pavel Vymetalek
2010-05-28 01:12:12 +00:00