Conversation

Jarkko Sakkinen

Edited 1 year ago
Writing my own serial port tool in Rust that plays well with #tmux. I like #tio but I'm looking into later expanding mine with built-in #zmodem support. Also, this should give portability across all major operating systems (#Linux, #Windows, #macOS).

#rustlang
1
0
4

Jarkko Sakkinen

Edited 1 year ago

Very cool, started yesterday and I can already talk to my #FPGA :-)

sudo target/debug/tior open /dev/ttyUSB0
Hello World!
init SPI
status: 0x0000000000000025
status: 0x0000000000000025
SPI initialized!
initializing SD...
SD command cmd0 	response : 01
SD command cmd55 	response : 01
SD command cmd41 	response : 01
SD command cmd55 	response : 01
SD command cmd41 	response : 01
SD command cmd55 	response : 01
SD command cmd41 	response : 01
SD command cmd55 	response : 01
SD command cmd41 	response : 01
SD command cmd55 	response : 01
SD command cmd41 	response : 01
SD command cmd55 	response : 01

Most of the time went to learning #clap, #serde and #tokio.

1
0
2

Jarkko Sakkinen

Edited 1 year ago

Serial TTY sessions are working now. The next stop is #zmodem:

 target/debug/tior
Connect to serial port

Usage: tior [OPTIONS] <COMMAND>

Commands:
  open  Open TTY
  list  List available devices
  help  Print this message or the help of the given subcommand(s)

Options:
  -s, --speed <SPEED>                Line speed [default: 115200]
  -d, --data-bits <DATA_BITS>        Line data bits [default: 8]
  -f, --flow-control <FLOW_CONTROL>  Flow control [default: none] [possible values: none, software, hardware]
  -p, --parity <PARITY>              Parity [default: none] [possible values: none, odd, even]
  -h, --help                         Print help
  -V, --version                      Print version

The binary is about 5.8 MiB after the strip, not too bad.

2
0
0

Jarkko Sakkinen

Edited 1 year ago

This feels a glitch but works:

impl Drop for Main {
    fn drop(&mut self) {
        eprintln!("end\n");
        terminal::disable_raw_mode().expect("terminal::disable_raw_mode()");
    }
}

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let _main = Main;

I wonder if there is a leaner pattern. This is pretty good Rust exercise/refresher project as you have input handling, command-line arguments, streaming, interactive i/o and file transfer later on. All basics of most system software. And nothing too fancy so that the project does not blow up out of proportions. #rustlang

1
0
0

@jarkko Seems reasonable to me. I use similar patterns in both and . I hate little more than console apps / TUIs that don't restore the screen buffer on terminal exit.

0
0
0

Jarkko Sakkinen

Edited 1 year ago
For zmodem built-in transmit workflows allows much less involved experience when a single program has control of the serial port traffic... easier to prevent trashing the session transcript and implement canceling of the file transfer.

i was thinking also that it would nice to have a line input/editor mode (perhaps for larger quantities of text) later on. i guess the point is to make more reliable and robust console when logging into a home router, FPGA board, SBC etc. and not make feature-wise a general purpose tool.
0
0
0