dashel: Dashel

dashel 1.3.3

- Main Page
- Namespaces
- Classes
- Files

Dashel

github.com/aseba-community/dashel

# Introduction

Dashel is a cross-platform data stream helper encapsulation library. It provides a unified access to TCP/UDP sockets, serial ports, console, and files streams. It also allows a server application to wait for any activity on any combination of these streams.

Dashel was originally designed by Stéphane Magnenat and Sebastian Gerlach. A full list of contributors is available in the README file. Dashel is licensed under a modified BSD open-source license. Source code, compilation instructions, authors and license information are available on github. Feel free to report bugs, fork Dashel and submit pull requests.

# Usage

To use Dashel, you have to instantiate a Dashel::Hub. The Hub is your connection with the data streams. It is the place where you create, destroy, and synchronize them.

The `example` directory in Dashel distribution provides several working examples that you can read to learn to use Dashel.

# Targets naming

In Dashel, streams connect to targets. A target is a string that describes a file, a TCP/UDP address/port, or a serial port. This string consists of the type of the target, a colon, followed by a semicolon separated list of parameters. This list contains key-values pairs, with a predifined order such that keys can be omitted (but if a key is present, all subsequent entries must have an explicit key). Its general syntax is thus `"protocol:[param1key=]param1value;...;[paramNkey=]paramNvalue"`.

The following protocols are available:

- `file` : local files
- `tcp` : TCP/IP client
- `tcpin` : TCP/IP server
- `tcppoll` : TCP/IP polling
- `udp` : UDP/IP
- `ser` : serial port
- `stdin` : standard input
- `stdout` : standard output

The file protocol accepts the following parameters, in this implicit order:

- `name` : name of the file, including the path
- `mode` : mode (read, write)

The tcp protocol accepts the following parameters, in this implicit order:

- `host` : remote host
- `port` : remote port
- `socket` : local socket; if a nonegative value is given, host and port are ignored

The tcpin protocol accepts the following parameters, in this implicit order:

- `port` : port
- `address` : if the computer possesses multiple network addresses, the one to listen on, default 0.0.0.0 (any)

The tcppoll protocol accepts the following parameters, in this implicit order:

- `host` : remote host
- `port` : remote port
- `socket` : local socket; if a nonegative value is given, host and port are ignored

The udp protocol accepts the following parameters, in this implicit order:

- `port` : port
- `address` : if the computer possesses multiple network addresses, the one to connect to, default 0.0.0.0 (any)

The ser protocol accepts the following parameters, in this implicit order:

- `device` : serial port device name, system specific; either port or device must be given, device has priority if both are given.
- `name` : select the port by matching part of the serial port "user-friendly" description. The match is case-sensitive. Works on Linux and Windows (note: on Linux, this feature requires libudev).
- `port` : serial port number, starting from 1, default 1
- `baud` : baud rate, default 115200
- `stop` : stop bits count (1 or 2), default 1
- `parity` : parity type (none, even, odd), default none
- `fc` : flow control type, (none, hard), default none
- `bits` : number of bits per character, default 8
- `dtr` : whether DTR line is enabled, default true Note that either device, name (on supported platforms), or port must be given. If more than one is given, device has priority, then name, and port has the lowest priority.

Protocols `stdin` and `stdout` do not take any parameter.