Stéphane Magnenat (http://stephane.magnenat.net), Mobots group - Laboratory of Robotics Systems, EPFL, Lausanne (http://mobots.epfl.ch)
Sebastion Gerlach, Kenzan Technologies (http://www.kenzantech.com)
Antoine Beyeler (http://www.ab-ware.com), Laboratory of Intelligent Systems, EPFL, Lausanne (http://lis.epfl.ch)
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 is licensed under a modified BSD license, which is a permissive open source license. Yet, if you find bugs or do some improvements, please let us know.
To use Dashel, you have to instanciate 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.
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 udp
: UDP/IP ser
: serial port stdin
: standard input stdout
: standard outputThe 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
: host port
: portThe 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 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; either port or device must be given, device has priority if both are given (note: on Linux, this feature requires libhal). 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 8Protocols stdin
and stdout
do not take any parameter.