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

383 Commits

Author SHA1 Message Date
1c8e238022 Debugging tweaks 2018-03-03 08:39:55 +02:00
1dc4f04718 Do not allow --telnet and --noreset / --hangup 2018-03-01 22:43:02 +02:00
cbcf13133d Moved native tty term_ops to ttylocal.c
Also, for better separation, the modem_XXX operations now communicate
using term.[ch] pin names (MCTL_xxx), not system pin names (TIOCM_xxx).
2018-03-01 17:51:34 +02:00
3e1a610acb Corrected, cleaned-up error reporting & handling 2018-03-01 16:40:55 +02:00
31127a5ea7 Fixed debugging output bug / typo 2018-03-01 16:04:58 +02:00
048863b362 Make term_fake_flush() a term_ops
No all types of devices need implement it.
2018-03-01 06:07:58 +02:00
ae1a8e291c Updated manual and rebuild docs 2018-02-28 11:13:10 +02:00
2b73bb95fa Updated version to 4.0a 2018-02-28 10:58:32 +02:00
45a49c8bbe Moved msec2tv() to fdio.c/h 2018-02-28 10:36:44 +02:00
dceef28776 tc2217 function renaming
Rationalized function naming in tn2217.c:

- Prefix tn2217_: functions called from outside tn2217.c. Either
  directly (exported) or through the ops table.
- No prefix: all functions related with the handling of the telnet
  protocol.
- Prefix comport_: All functions related with the COMPORT option
2018-02-28 10:30:26 +02:00
0c464859c3 Added TERM_EDEVINIT error
Device initialization failed
2018-02-28 10:12:21 +02:00
6062aec171 Corrected writen_ni() usage + error propagation 2018-02-28 10:10:54 +02:00
df9b2e3a62 Replaced ETIME with ETIMEDOUT
ETIME may not be defined on all systems
2018-02-27 20:16:19 +02:00
faed52cd2e Changed wrinetn_ni to work with non-blocking fds
Code in tn2217.c is using writen_ni() with the non-blocking socket
fd. This will not work. Instead of making the fd blocking (which is also
a solution), I made writen_ni work with both, blocking and non-blocking
fds.

Also added a time-out version of writen_ni(), called writento_ni() for
future use (we way want to protect writes with timeouts). Currently
commented out.
2018-02-27 17:26:29 +02:00
96201b778c Minor renaming 2018-02-27 05:36:54 +02:00
d9a619b405 Disable debugging in commited code 2018-02-27 03:58:03 +02:00
ce7ad1910f Debugging + negotiations + wait_cond refactor
Combined commit. No time and too messy to split it up.

- Cleaned up, improved debugging output
- Correct options negotiations
- Refactored wait_cond(), waid_cmd(), not to repeat code from read()

See also discussion in issue #95
2018-02-27 03:51:54 +02:00
afcbbc746b Don't wait for negotations if run with --noinit
Don't wait for negotiations to finish and for port configuration to be
completed if picocom is run with --noinit (in which case s->set_termios
will not be set).
2018-02-25 17:05:53 +02:00
fe89a14892 Removed unused macro 2018-02-24 23:11:07 +02:00
b4b8f01eab Comments 2018-02-24 23:08:12 +02:00
bcc753167a Better RFC2217 socket shutdown / close
When an RFC2217 socket is closed, optionally, try to drain the
buffered data allowing the remote server to read and process
them. First the socket is shutdown only in the transmit (write)
direction. Then data are read from it (and discarded) until the server
closes the other direction (read(2) returns zero).

Also, don't bother trying to reset the port to its original settings
before exiting, since closing the connection to the remote server will
do this anyway (as per RFC2217).
2018-02-24 16:04:44 +02:00
91916afc14 Debugging output cleanup 2018-02-24 11:02:12 +02:00
0f2194d6a8 Wait for port to be configed before write / read
Before picocom enters it's main loop and data are written to serial
port, and also before the first data are read from the port, the port
must first be configured. That is: The first data read from picocom's
standard input (or the initstring) must be written to the port, *after*
the port has been configured to the settings specified by picocom's
command-line arguments; also, the first data must be read from the port,
after the port has been configured (as any data read before, will most
likely be garbage).

When tn2217_write() is called it checks that the initial negotiations
have completed, and that the RFC2217 port-configuration commands have
been transmitted. If this is not true, then the function waits by
reading from the port and processing commands until the condition
becomes true or a timeout expires.

When tn2217_read() is called it checks that the initial negotiations
have completed, that the RFC2217 port-configuration commands have been
transmitted *AND* that their replies have been received. Any user-data
read by picocom before the replies to the commands are received will
most likely be data read by the server using the old port configuration
and therefore useless (garbage). To make the test easier, we actually
check that an equal number of replies-to-configuration-commands has been
received as configuration-commands have been sent (a misbehaving server
can confuse us by sending multiple replies to commands, but this is
always the case). Again, then the function waits by reading from the
port and processing commands until the condition becomes true or a
timeout expires.

See also discussion in issue #95
2018-02-24 10:21:21 +02:00
6b15b80846 Comments 2018-02-23 22:30:55 +02:00
7755c256e8 Minor usage string tweak 2018-02-22 13:58:31 +02:00
16ce65aef7 Tweaked debugging output 2018-02-22 13:57:38 +02:00
68bd1cf757 Better termios parsing/setting for RFC2217 ports
Use the same code to parse options (parity, databits, stopbits, etc)
from a termios structure and to write options to a termios structure for
both: native and RFC2217 ports.

Seems to work ok, but more thorough testing is needed.

Also fixed some minor bugs (typos) when setting stopbits, and when
setting modem-control lines.

Cleaned up debuging output a bit.
2018-02-21 11:19:38 +02:00
ec3cde7e64 Some refactoring between term_xxx and local ops 2018-02-20 23:55:37 +02:00
f74c3ad0a4 Merge branch 'master' into rfc2217
(Disable custom-baudrate support at runtime for Linux)
2018-02-20 16:14:32 +02:00
007811c337 Minor rewording 2018-02-20 15:26:40 +02:00
3eae4b37c9 Typos 2018-02-20 13:47:02 +02: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
eacaa8b6d8 Better baudrate parsing/setting for RFC2217 ports
Use the same code to parse the baudrate from a termios structure and to
write the baudrate to a termios structure for both: native
and RFC2217 ports. Also use the same code to translate between
speeds (expressed in bits-per-second) and budrate-codes.

Seems to work ok, but more testing is needed, especially around some
corner-cases.
2018-02-19 10:46:09 +02:00
16d60030c3 Show telnet setting 2018-02-19 09:50:47 +02:00
88a6cb03ab Refactor USE_IOCTL conditional
USE_IOCTL should affect only native ports, not RFC2217 ports
2018-02-19 07:42:22 +02:00
1cc6787a3a Removed left-over debugging printfs 2018-02-19 01:17:16 +02:00
df6b4a6d8a Better flowcntrl parsing/setting for RFC2217 ports
Use the same code to parse the flow-control setting from a termios
structure and to write the flow-control settings to a termios structure
for both: native and RFC2217 ports.
2018-02-19 01:04:08 +02:00
35b992a344 Avoid spurious term_apply() if --noinit is given 2018-02-19 00:58:18 +02:00
48104d48e1 Disable send-/receive-file cmds for RFC2217 ports
Send and receive file commands pass the port filedes to a newly exec'ed
binary, as its stdin/stdout. This obviously will not work for RFC2217
ports (as the data-stream contains inline signaling that must be removed
by the term framework).

In order to support send- and receive- file commands for RFC2217 ports,
the execed binary must be connected (probably through pipes) to a newly
forked process that monitors the pipes and forwards the data to the
RFC2217 port using the term_read() / term_write() functions that do the
necessary filtering. This may still not work if the execed binary
expects to find a tty connected to its stdin/stdout. In this case
there's nothing we can do...

Anyway, this is too much work so, for now, so I just disable the
commands.
2018-02-18 22:25:05 +02:00
b1d7557020 Added field "name" to term struct 2018-02-18 22:13:16 +02:00
e5f718aa38 Don't UUCP-lock rfc2217 ports 2018-02-18 22:05:12 +02:00
1a74d8bdd5 Missing dependencies 2018-02-18 21:17:45 +02:00
fdedde3a14 Added drain to term ops 2018-02-18 20:06:19 +02:00
dff052e303 Updated CONTRIBUTORS 2018-02-18 18:54:06 +02:00
84e5edce34 Added std headers and footers 2018-02-18 18:47:03 +02:00
718ed6d4f4 Comments 2018-02-18 18:31:18 +02:00
d68a9067f1 Remove unnecessary forward declaration 2018-02-18 18:03:17 +02:00
c1df466099 Mention RFC2217 ports in the intro 2018-02-18 18:01:20 +02:00
9790e9c01f Conditional compilation for RFC2217 support 2018-02-18 17:54:32 +02:00
5017addb62 Add -T option for RFC 2217 telnet devices
Add support for connecting to remote COM-PORT servers using RFC 2217.

This commit adds a term_ops provider that translates all termios
and modem ioctls into TELNET operations.

It supports:
 - IPv4 and IPv6 hosts and ports numbers, per getaddrinfo()
 - baud rate changes up to 115200
 - data bit size, parity, stop bits
 - sending BREAK
 - control over remote hardware flow control mode
 - control over remote signals: RTS, DTR
 - visibility of remote signals: CD, RI, DSR, CTS
 - flushing remote rx/tx buffers

Limitations
 - There will be some delay between some operations (eg DTR toggle)
   so rapid toggling can result in a temporarily inconsistent local
   state.  However, it will eventually synchronise with the remote
   state if allowed to settle.
 - The terminal's FD is the raw TCP connection, so sx/rx likely won't
   work.
 - More baud rates could be supported.
 - Remote parity modes SPACE and MARK are not supported.
 - Stop bit size 1.5 is not supported.
 - In-protocol flow control is not supported.
 - BREAK is implemented with a local usleep of 250ms, which may be
   eaten up or extended by the network.
2018-02-18 17:00:12 +02:00