Skip to content

choco-technologies/dmtty

Repository files navigation

DMTTY - DMOD TTY Line Discipline Driver Module

License

A DMOD (Dynamic Modular System) module that adds terminal behavior - echo and canonical (line-buffered) input - on top of any other stream device dmdevfs can open, without that device's own driver having to implement it.

Why

Every DMOD driver shows up as a stream file under /dev, which is handy: in dmell you can redirect stdin/stdout to a UART device node and use it as a new terminal. The catch is that IO-flag handling (echo, line editing) only exists inside dmlog's own console today - a plain dmuart node just forwards raw bytes, so redirecting to it gives you a terminal with no echo. dmtty implements that line discipline once and lets it be layered on top of any backing file instead of duplicating it in every driver.

Features

  • Standard DMDRVI Interface: Read/write/ioctl device access pattern, like any other DMOD driver
  • Echo & Canonical Mode: Per-node IO flags, configurable via ioctl at runtime
  • One Main Node, Many Extra Nodes: Creates /dev/tty from configuration, then exposes an API to attach any number of additional nodes to other backing files
  • Two Attach Paths: A direct API (dmtty_attach()) and a dmhaman hot-plug event (DMTTY_HANDLER_NAME_DEVICE_AVAILABLE) for drivers that don't want a compile-time dependency on dmtty
  • Architecture-Independent: No MCU/board-specific code - it only forwards to an already-open backing file, so it builds identically everywhere

Quick Start

Installation

Using dmf-get from the DMOD release package:

dmf-get install dmtty

Basic Usage

  1. Create the main /dev/tty node (config.ini, loaded by dmdevfs):
[dmtty]
backing=/dev/dmuart1
echo=on
canonical=on
  1. Or attach additional nodes at runtime:
#include "dmtty.h"

/* Turn /dev/dmuart1 into a new terminal node -> creates /dev/tty1 */
dmtty_attach("/dev/dmuart1", NULL, DMTTY_FLAGS_DEFAULT);
  1. Use it like any other device file, e.g. from dmell:
dmell < /dev/tty1 > /dev/tty1

Building

Prerequisites

  • CMake 3.18 or higher
  • A DMOD-compatible toolchain (automatically fetched via dmod)

Build Commands

cmake -B build
cmake --build build

Documentation

Comprehensive documentation is available in the docs/ directory:

View documentation using dmf-man:

dmf-man dmtty          # Main documentation
dmf-man dmtty api      # API reference
dmf-man dmtty config   # Configuration guide

Development

Project Structure

dmtty/
├── configs/            # Default dmdevfs configuration
├── docs/               # Documentation (markdown format)
├── examples/           # Example configurations
├── include/
│   ├── dmtty.h        # Main API (direct attach/detach + DMDRVI interface)
│   └── dmtty_types.h  # IO flags, ioctl commands, dmhaman event
├── src/
│   └── dmtty.c        # Implementation
├── tools/
│   └── tty/           # CLI tool to manually attach a path via dmtty_attach()
├── CMakeLists.txt     # Build configuration
└── manifest.dmm       # DMOD manifest

Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Submit a pull request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Authors

  • Patryk Kubiak - Initial work

Related Projects

  • DMOD - Dynamic Modular System framework
  • DMDRVI - DMOD Driver Interface
  • DMDEVFS - DMOD Driver File System (manages driver device nodes)
  • DMHAMAN - Handler registry used for hot-plug announcements
  • DMUART - UART driver module (a common dmtty backing device)
  • DMLOG - Logging/monitor console (the original source of IO-flag handling)

Support

For issues, questions, or contributions:

  • Open an issue on GitHub
  • Check the documentation in docs/
  • Use dmf-man dmtty for command-line help

About

Driver for TTY

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors