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

117 Commits

Author SHA1 Message Date
481404e0f9 Add timestamping 2019-09-06 14:15:19 +03:00
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
8707801496 Allow multiple non-option argunments, use last
Allow more than one non-option arguments. Use the last one as the port
name, ignore others.

Rationale. Allow easily setting a default port using an alias or
script. The port can then be overriden by a subsequent argument. E.g.

  alias picocom='picocom -b 115200 /dev/ttyS0'

  picocom               <-- call with default port
  picocom /dev/ttyUSB0  <-- override default
2018-02-08 17:01:23 +02:00
9d5cc80c47 Minor command-line args memory leak
Free previous ones if string arguments (log_filename and initstring) are
given multiple times
2018-02-08 15:38:47 +02:00
849532b261 Replaced strcpy in init_history()
Mostly to avoid compiler warnings on some systems
2018-01-21 21:16:26 +02:00
e2be81fcf7 Replaced strcpy & strcat in file_completion_cb()
Mostly to silence warnings (against using strcat / strcpy) that some
compilers produce
2018-01-21 17:44:10 +02:00
8eab62945d Close tty_fd after resetting and before exiting 2018-01-20 16:45:48 +02:00
7bf7b5d491 Explicitly unlock tty_fd when exiting with noreset 2018-01-20 14:36:11 +02:00
007072bd57 Better --lower/raise-dtr/rts handling
Set the levels of DTR and RTS modem-control lines (according to the
--lower/raise-dtr/rts command-line options) *twice*: Once
immediatelly (as quickly as possible) after opening the port (before
actually configuring it), and once after configuring it. On some systems
configuring the port (i.e. calling tcsetattr) has the effect of reseting
the DTR and RTS signals.
2018-01-20 11:38:43 +02:00
7bc133c8f9 Added missing options in help string 2018-01-18 10:30:11 +02:00
a36bc69ee1 Smaller standard input read buffer (16 bytes) 2018-01-16 04:26:07 +02:00
d4bf3502d5 Merge branch 'read-stdin' of https://github.com/JoeMerten/picocom into JoeMerten-read-stdin 2018-01-16 04:16:26 +02:00
a020a12f7a #73: for read stdin, changed naming to the same as for port read 2018-01-16 03:02:59 +01:00
4845b66d99 #73: read multiple bytes from stdin with a single read() call 2018-01-16 02:58:51 +01: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
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
681ff11114 Added the --raise-rts and --raise-dtr options
Fixes #86
2018-01-13 16:11:07 +02:00
eaf579f644 Correct printing of string-length
Added the cast, as without it, it may fail on systems where size_t is not
long (e.g is long long)

Fixes #85
2018-01-09 13:47:00 +02:00
6af9fe5633 Check for settings mismatch at startup
Check for port-settings mismatch ate startup, and print a warning
message if found

Closes #78
2018-01-09 01:44:22 +02:00
de631d4c58 FreeBSD: Fixed initial sw-side state of RTS and DTR 2018-01-02 15:58:58 +01:00
ddffca71d4 Comments 2018-01-01 23:46:48 +02:00
bf491c558b Fixed #63, initial sw-side state of RTS and DTR 2017-12-31 17:06:46 +01:00
521803ae4b Added the missing --quiet option to the help msg 2017-12-28 01:15:38 +02:00
50b8e6962c Added "to hex" character mappings.
Closes #75
2017-12-25 21:05:05 +02:00
77e684f5ce Added C-w (write hex) command
Pompts the user for a sting of hexadecimal values to be converted to
binary and sent to the port.
2017-12-23 13:19:21 +02:00
1b8a19f10e Cleanup error and info messages
Also moved fd_pinfof to picocom.c and renamed it to pinfo
2017-12-21 15:58:47 +02:00
26522309a3 Added the --hangup command-line option
If given together with **--noreset**, picocom will not reset the serial
port to it's original settings on exit, but it *will* clear the modem
control lines (typically DTR and RTS) to signal a modem hangup. Without
the **--noreset** option (explicitly given, or implied by extiting with
the "Quit" command) **--hangup** has no effect (without **--noreset**
picocom always clears the modem control lines on exit, anyway).
2017-12-21 15:21:08 +02:00
637f7b375e Cleanup / refactor fd_printf and similar functions 2017-12-21 12:56:26 +02: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
e6653b45b5 Do not drain the port when exiting by command
If picocom exits due to an "Exit" or "Quit" command, the contents of the
output queue (data read from the terminal but not written to the port)
are, anyway, discarded. Because of this, there is no reason to wait for
the O/S output buffer (data already written to the port but not
transmitted) to drain before exiting. The output port (output buffer) is
instead flushed (data discarded) before exiting due to a command.
2017-12-20 06:42:14 +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
69e16a3a70 Factor-out cleanup code from fatal() and main() 2017-12-19 22:05:42 +02:00
cb4e363fe1 Show message "Ignoring init-string..." 2017-12-19 17:30:30 +02:00
977cc7e084 Minor refactoring of KEY_QUIT handling
Now more similar with KEY_EXIT handling
2017-12-19 14:24:53 +02:00
c48f6aa78e Suppress help message if escape char is disabled 2017-12-17 22:43:54 +02:00
d1f439b38d Moved drain delay into term.c 2017-12-17 22:14:08 +02:00
2503f0ecfa Clean up error, signal, and exit handling
- Exit with failure if killed by signal
- Write fatal error messages to standard error
- Minor fixes on signal handling for children processes
2017-12-17 22:12:32 +02:00
9fbf4d1c11 Show initstring length 2017-12-16 22:29:56 +02:00
49041a2ef6 Added the --no-escape command-line option
Disables the escape character so that picocom can never enter command
mode.
2017-12-16 18:11:33 +02:00
12d46e056c Made tty output queue dynamically growable.
Closes #33
2017-12-16 17:36:43 +02:00
2ff1431827 Improved termination handling
Drain tty output buffer before exiting.
Exit whith the INT signal.
2017-12-16 14:49:46 +02:00
e9385b0ece Added the --exit command-line option
Exit picocom immediatelly after opening and configuring the serial
port. Do *not* read *anything* from the standard input or from the
serial port. If an init string is also given, picocom exits imediatelly
after sending (writing) the init string to the serial port. Again,
nothing is read from the standard input, or from the serial port. The
ouput map, the local echo option, and the local-echo map are observed
when sending the init string. The **--exit** option, overrides
the **--exit-after** option.
2017-12-16 10:51:34 +02:00
5ccc25ad94 Standard input handling
- Allow stdin to be a non-tty (print a warning, though). Some things may
  not work as expected in this case, but most will, and it's useful in
  several occasions.

- If picocom reads zero bytes from stdin, then:

  - If --exit-after is set, then keep operating (without reading from
    stdin) until the idle timeout expires, or we are killed by a signal

  - Otherwise, exit picocm, but only after transmitting the contens of
    the output queue.
2017-12-15 00:13:40 +02:00
6fdd2a3084 Added commandline option --quiet
Suppress picocom from printing initial greetings banners and other
messages not explicitly requested by the user. Command responses and
errors or warnings are still printed.
2017-12-14 18:44:44 +02:00