tty0tty
所属分类:Telnet客户端/Shell
开发工具:Elixir
文件大小:28KB
下载次数:0
上传日期:2023-02-25 06:20:58
上 传 者:
sh-1993
说明: tty0tty空调制解调器模拟器的Elixir端口
(Elixir port for tty0tty null modem emulator)
文件列表:
.formatter.exs (97, 2023-02-25)
.reuse (0, 2023-02-25)
.reuse\dep5 (399, 2023-02-25)
CHANGELOG.md (421, 2023-02-25)
LICENSES (0, 2023-02-25)
LICENSES\Apache-2.0.txt (10280, 2023-02-25)
LICENSES\CC-BY-4.0.txt (17023, 2023-02-25)
LICENSES\CC0-1.0.txt (7048, 2023-02-25)
LICENSES\GPL-2.0-or-later.txt (17337, 2023-02-25)
Makefile (987, 2023-02-25)
c_src (0, 2023-02-25)
c_src\tty0tty.c (4646, 2023-02-25)
lib (0, 2023-02-25)
lib\tty0tty.ex (3314, 2023-02-25)
lib\tty0tty (0, 2023-02-25)
lib\tty0tty\application.ex (406, 2023-02-25)
mix.exs (1449, 2023-02-25)
mix.lock (2816, 2023-02-25)
test (0, 2023-02-25)
test\test_helper.exs (100, 2023-02-25)
test\tty0tty_test.exs (357, 2023-02-25)
# TTY0TTY
[![REUSE status](https://api.reuse.software/badge/github.com/jjcarstens/tty0tty)](https://api.reuse.software/info/github.com/jjcarstens/tty0tty)
Elixir port for [`tty0tty` null modem emulator](https://github.com/freemed/tty0tty)
## Use
This library is almost exclusively for testing purposes. `tty0tty` creates 2
pseudo-ttys that are connected together allowing you to run unit tests which
use serial ports (like [`Circuits.UART`](https://github.com/elixir-circuits/circuits_uart))
without the need for external hardware of adapters.
```elixir
defmodule SerialTest do
use ExUnit.Case, async: true
test "can open a serial port" do
{:ok, uart} = Circuits.UART.start_link()
port_name = "/tmp/dummy1"
# Open serial port before use
{:ok, _port_sup} = TTY0TTY.open(port_name)
assert :ok = Cicuits.UART.open(uart, port_name)
end
end
```
Under the hood, `TTY0TTY.open/2` opens 2 devices (`
`, and
`-twin`) and connects their TX <-> RX to emulate the serial
connection. This allows you to also verifying reading serial data by sending
data to the connected twin port:
```elixir
defmodule SerialTest do
use ExUnit.Case, async: true
test "can read a serial port" do
{:ok, uart} = Circuits.UART.start_link()
port_name = "/tmp/dummy1"
# Open serial port before use
{:ok, _port_sup} = TTY0TTY.open(port_name)
assert :ok = Cicuits.UART.open(uart, port_name)
File.write!([port_name, "-twin"], "howdy!")
assert_receive {:circuits_uart, ^port_name, "howdy!"}
end
end
```
近期下载者:
相关文件:
收藏者: