Commit graph

282 commits

Author SHA1 Message Date
Steve Marple
f47467271f Add "epoch" timestamp option
Add an option that prints the timestamp as the number of seconds since
the Unix epoch.
2024-08-24 12:35:30 +02:00
Martin Lund
ef12ed62df Remove unnecessary sync in line input mode
This caused a problem for some highly timing sensitive modem read-eval-print
loops because the input line and line termination characters (cr/nl) would be
shifted out on the UART with too big delay inbetween because of two
syncs.
2024-08-06 20:48:43 +02:00
Martin Lund
e1fe232254 Fix shadow variable 2024-07-13 18:36:03 +02:00
Heinrich Schuchardt
68a64ac554 Print correct 'Done' timestamp for X- and Y-modem transfers
Closes: #268

Call tio_printf() after completing xymodem_send().

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2024-07-13 15:10:39 +02:00
Martin Lund
c3654486c7 Fix hex output mode when using normal input mode
In this combination of modes the input character was not forwarded to
the tty device. This fix makes sure it is forwarded.
2024-07-10 13:11:28 +02:00
Robert Lipe
fc0c6f61d2 Recompute listing_device_name_length_max for MacOS case, too. 2024-07-10 01:46:32 +02:00
Martin Lund
da9f7a6540 Improve warning upon failing connect
Add device path to warning when connect fails.
2024-07-09 21:06:22 +02:00
Martin Lund
2a1dae6336 Fix crashy search_reset() on macOS 2024-07-09 16:44:10 +02:00
Martin Lund
ada2db0739 Clean up shadow variable 2024-07-02 19:20:59 +02:00
Martin Lund
2c700a90b0 Code cleanup 2024-07-02 19:11:40 +02:00
Martin Lund
da04c2c444 Improve listing of long device names 2024-07-02 17:41:49 +02:00
Martin Lund
5f70b75e90 Fix listing of serial devices on macOS 2024-07-01 23:11:58 +02:00
Martin Lund
d34fa1c1ad Rename mapping flag MSB2LSB to IMSB2LSB
This is the correct naming since we are changing the input bit order on
input from the serial device.
2024-06-29 12:14:34 +02:00
Martin Lund
4723cc3f4e Add OIGNCR mapping flag
Ignores CR on output to serial device.
2024-06-27 20:09:25 +02:00
Martin Lund
8c471105fe Fix line input mode ignoring characters ABCD 2024-06-27 18:54:19 +02:00
Jakob Haufe
c5afd86b9a Fix typos 2024-06-15 17:16:23 +02:00
Martin Lund
053ae53f19 Update configuration output 2024-06-15 16:00:58 +02:00
Martin Lund
8f77ad5830 Clean up script run interaction text 2024-06-15 15:58:08 +02:00
Martin Lund
6ec2ac19d0 Add history and editing feature to line input mode
Use up and down arrow keys to navigate history.

Use left and right arrow keys to move cursor back and forth.

We try mimic the behaviour of GNU readline which we can not use because
we also need to react to key commands.
2024-06-15 14:31:23 +02:00
Martin Lund
134038c1ce Fix line input mode
Fix so that ABCD are no longer ignored.
2024-06-09 13:03:59 +02:00
Martin Lund
003b2e37d4 Make sure ICRNL, IGNCR, INLCR take effect 2024-06-02 23:35:36 +02:00
Martin Lund
8014ef68c0 Cleanup parsing of mapping flags 2024-06-02 14:26:39 +02:00
Vyacheslav Patkov
563c4fa6ea Show current mappings in the configuration printout 2024-06-02 13:22:33 +02:00
Vyacheslav Patkov
d1d6b45e8e Use "ctrl-t m" to change mappings interactively 2024-06-02 13:22:33 +02:00
Vyacheslav Patkov
f148a1413c Prompt for Lua script or shell command in interactive session 2024-06-01 16:23:51 +02:00
Eliot Alan Foss
d10e762a7d Added support to receive XMODEM-CRC files from the connected serial port. 2024-05-29 01:23:00 +02:00
Martin Lund
5b5248929e Force destructive backspace when using local echo
Only takes effect in normal output mode.
2024-05-14 23:22:05 +02:00
Martin Lund
86f1b3881d Fix shadow variable 2024-05-08 10:31:32 +02:00
Martin Lund
e75e19eb00 Add option '--exec <command>' for running shell command
Runs shell command with I/O redirected to device.
2024-05-07 14:38:31 +02:00
Martin Lund
ec8f63f06d Improve --list feature on non-linux platform 2024-05-03 14:12:47 +02:00
Martin Lund
60caede5dd Add support for using TID as device in config file 2024-05-03 10:32:33 +02:00
Martin Lund
0e9dbcbc77 Replace use of stat() with fstat()
For better security.
2024-05-02 22:30:47 +02:00
Martin Lund
68c78222e1 Fix hexN output mode 2024-05-02 21:50:48 +02:00
Martin Lund
15ba034ce5 Fix submenu response when invalid key hit 2024-05-02 19:38:14 +02:00
Martin Lund
65c5a068d8 Replace inih with glib key file parser
After including the use of glib we might as well replace inih
with the glib key file parser.

All configuraiton file parsing has been reworked and also the options
parsing has been cleaned up, resulting in better and stricter
configuration file and option value checks.

Compared to old, configuration files now requires any default
configurations to be put in a group/section named [default].

Configuration file keywords such as "enable", "disable", "on",
"off", "yes", "no", "0", "1" have been retired. Now only "true" and
"false" apply to boolean configuration options. This is done to simplify
things and avoid any confusion.

The pattern option feature has been reworked so now the user can now
access the full match string and any matching subexpression using the
%mN syntax.

For example:

[usb devices]
pattern = usb([0-9]*)
device = /dev/ttyUSB%m1

Then when using tio:
$ tio usb12

   %m0 = 'usb12'  // Full match string
   %m1 = 12       // First match subexpression

Which results in device = /dev/ttyUSB12
2024-05-02 18:35:37 +02:00
Martin Lund
6d77201ba0 Simplify lua line manipulation API
Collapses lua high(), low(), toggle(), config_high(), config_low(),
config_apply() into one simple function:

set{<line>=<state>, ...}

Line can be any of DTR, RTS, CTS, DSR, CD, RI.

State is high, low, or toggle.

Example:
script = set{DTR=high, RTS=low}; msleep(100); set{DTR=low, RTS=high}; msleep(100); set{RTS=low}

Notice the use of {} instad of () when calling the set function. This is
required to pass parameters by name in lua.
2024-04-29 15:20:53 +02:00
Martin Lund
eef0a15194 Unshadow variable 2024-04-29 01:49:44 +02:00
Martin Lund
fe2973522e Fix shadow variable 2024-04-27 19:11:37 +02:00
Martin Lund
f5f62ee02d Disable DEC Special Graphics at exit if vt100
If a vt100 terminal receives the Shift In character '\016' it will
enable the 7 bit DEC Special Graphics character set used for line drawing.

For most users this can happen due to line noise from the tty device and
will likely mess up your terminal even after tio exits.

To better handle this we want to make sure that tio disables this mode
by sending the Shift Out character '\017' at exit.

This mechanism will only activate if environment variable TERM assumes
value "vt100".
2024-04-27 17:32:48 +02:00
Martin Lund
42ff234204 Add hexN output mode
Adds support for hexN mode where N is a number in the range 1 to 4096
which defines how many hex values will be printed before a line break.

In short, it defines the width of the hex output.

In this mode, if timestamps are enabled they will be added to each hex
line.
2024-04-27 15:25:34 +02:00
Martin Lund
c61d56935b Fix excludes pattern matching 2024-04-27 01:31:43 +02:00
Martin Lund
d19ba1c492 Add new ways to manage serial devices
* Rename --list-devices to --list

 * Rename --no-autoconnect to --no-reconnect

 * Switch -l and -L options

   * -l now lists available serial devices

   * -L enables log to file

 * Add option --auto-connect <strategy>

   * Supported strategies:

     * "new" - Waits to connect first new appearing serial device

     * "latest" - Connects to latest registered serial device

     * "direct" - Connect directly to specified serial device (default)

 * Add options to exclude serial devices from auto connect strategy by
   pattern

   * Supported exclude options:

     * --exclude-devices <pattern>

       Example: '--exclude-devices "/dev/ttyUSB2,/dev/ttyS?"'

     * --exclude-drivers <pattern>

       Example: '--exclude-drivers "cdc_acm"'

     * --exclude-tids <pattern>

       Example: '--exclude-tids "yW07,bCC2"'

     * Patterns support '*' and '?'

 * Connect to same port/device combination via unique topology ID (TID)

   * Topology ID is a 4 digit base62 encoded hash of a device topology
     string coming from the Linux kernel. This means that whenever you
     plug in the same e.g. USB serial port device to the same USB hub
     port connected via the exact same hub topology all the way to your
     computer, you will get the same unique TID.

   * Useful for stable reconnections when serial device has no serial
     device by ID

   * For now, only tested on Linux.

 * Reworked and improved listing of serial devices to show serial devices:

   * By device

     * Including TID, uptime, driver, and description.

     * Sorted by uptime (newest device listed last)

   * By unique topology ID

   * By ID

   * By path

 * Add script interface 'list = tty_search()' for searching for serial
   devices.
2024-04-26 22:19:22 +02:00
Martin Lund
51bfa68bdd Text cleanup 2024-04-20 14:03:38 +02:00
Martin Lund
6fff4939e4 Add timeout based timestamps in hex output mode
This change reintroduces timestamping in hex output mode but based on
timeout instead of new lines which made no sense. This means that
timestamps will only be printed when timeout time has elapsed with no
output activity from serial device.

Adds option --timestamp-timeout <ms> for setting the timeout value in
milliseconds.

Defaults to 200 ms.
2024-04-18 15:52:45 +02:00
Martin Lund
a8e0d2693d Do not echo CR in line input and hex output mode 2024-04-18 14:44:39 +02:00
Martin Lund
c440da2ea8 Improve switched messages 2024-04-18 13:35:09 +02:00
Martin Lund
f1144ca5cc Cleanup 2024-04-18 13:29:06 +02:00
Martin Lund
a605533213 Fix local echo in line mode 2024-04-17 16:17:20 +02:00
Martin Lund
1e20948d83 Fix line input mode
Do not forward input characters to tty device before a line is input via
carriage return.
2024-04-16 19:38:45 +02:00
Martin Lund
4801816357 Introduce basic line input mode 2024-04-16 17:42:34 +02:00