package tcpip

  1. Overview
  2. Docs

Text console input/output operations.

type error = [
  1. | `Invalid_console of string
]

The type representing possible errors when attaching a console.

include V1.DEVICE with type error := error with type 'a io = 'a Lwt.t
type 'a io = 'a Lwt.t

A potentially blocking I/O operation

type t

The type representing the internal state of the device

type id

Type defining an identifier for this device that uniquely identifies it among a device tree.

val id : t -> id

Return the identifier that was used to construct this device

val connect : id -> [ `Error of error | `Ok of t ] io

Connect to the device identified by id

val disconnect : t -> unit io

Disconnect from the device. While this might take some time to complete, it can never result in an error.

val write : t -> string -> int -> int -> int

write t buf off len writes up to len chars of String.sub buf off len to the console t and returns the number of bytes written. Raises Invalid_argument if len > buf - off.

val write_all : t -> string -> int -> int -> unit io

write_all t buf off len is a thread that writes String.sub buf off len to the console t and returns when done. Raises Invalid_argument if len > buf - off.

val log : t -> string -> unit

log str writes as much characters of str that can be written in one write operation to the console t, then writes "\r\n" to it.

val log_s : t -> string -> unit io

log_s str is a thread that writes str ^ "\r\n" in the console t.