Commit 8786a253 authored by Renaud Pacalet's avatar Renaud Pacalet
Browse files

Prepare for distribution

parent 6548b03d
Copyright Telecom ParisTech
Copyright Renaud Pacalet <renaud.pacalet@telecom-paristech.fr>.
Licensed uder the CeCILL license, Version 2.1 of
2013-06-21 (the "License"). You should have
received a copy of the License. Else, you may
obtain a copy of the License at:
http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
This diff is collapsed.
###########################################################
# COPYRIGHT #
# --------- #
# #
# See Copyright Notice in COPYING and license in LICENSE. #
###########################################################
#!/usr/bin/env perl
package MSG;
......
COPYRIGHT
---------
See Copyright Notice in LICENSE. Comments and suggestions of improvements are
welcome. Please report bugs to renaud@pacalet.fr.
DESCRIPTION
-----------
pegp (Perl-Ethernet-Perl-Gnuplot) is a very basic example that shows how an
acquisition device can send acquired samples to a visualization device through
UDP packets. This application is largely inspired by the driveGnuPlots.pl perl
script by Thanassis Tsiodras (thanks Thanassis) with several improvements and
some important differences.
----
MSG.pm is a perl module that handles messages. The messages comprise a 16-bits
identifier ID, and an array of 1 to 255 32-bits integer values. The
module uses pack to convert messages between perl hashes to network strings. The
network strings are the concatenation of:
- ID (2-bytes unsigned integer), the identifier
- N (1-byte unsigned integer), the number of 32-bits integer values
- N 4-bytes integer values
The ID and the integer values are in network (big) endianness. Conversions
between perl hashes and regular strings are also handled. The regular strings
are in format: "id:n:v1:...:vn" where id, n and the vi are the decimal
representations of the identifier, the number of 32-bits integer values and the
32-bits integer values, respectively.
----
server.pl plays the role of the acquisition device. It can be used to generate
several streams of data samples (sines of various frequencies) and send them
through a UDP socket. Each sent UDP packet is in the MSG.pm network string
format and carries a 16-bits unsigned ID and a single 32-bits integer value. The
ID is used to differentiate several streams.
# Table of content
1. [License](#license)
1. [Description](#Description)
# <a name="License"></a>License
Copyright Renaud Pacalet (renaud.pacalet@telecom-paristech.fr)
Licensed uder the CeCILL license, Version 2.1 of 2013-06-21 (the "License"). You should have received a copy of the License. Else, you may obtain a copy of the License at:
http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
# <a name="Description"></a>Description
**pegp** (Perl-Ethernet-Perl-Gnuplot) is a very basic example that shows how an acquisition device can send acquired samples to a visualization device through UDP packets. This application is largely inspired by the `driveGnuPlots.pl` perl script by Thanassis Tsiodras (thanks Thanassis) with several improvements and some important differences.
`MSG.pm` is a perl module that handles messages. The messages comprise a 16-bits identifier ID, and an array of 1 to 255 32-bits integer values. The module uses `pack` to convert messages between perl hashes to network strings. The network strings are the concatenation of:
* ID (2-bytes unsigned integer), the identifier
* N (1-byte unsigned integer), the number of 32-bits integer values
* N 4-bytes integer values
The ID and the integer values are in network (big) endianness. Conversions between perl hashes and regular strings are also handled. The regular strings are in format: `id:n:v1:...:vn` where `id`, `n` and the `vi` are the decimal representations of the identifier, the number of 32-bits integer values and the 32-bits integer values, respectively.
`server.pl` plays the role of the acquisition device. It can be used to generate several streams of data samples (sines of various frequencies) and send them through a UDP socket. Each sent UDP packet is in the `MSG.pm` network string format and carries a 16-bits unsigned ID and a single 32-bits integer value. The ID is used to differentiate several streams.
```
Usage: ./server.pl [OPTION]...
Send sine samples to a UDP socket. Samples are in the MSG form where the id
field is a stream index and the parameters field is a 32 bits integer encoding
the sine value: parameters = int32_t(sine(X)*2^30). The --offset=OFFSET option
specifies the X increment between two consecutive sine samples.
Send sine samples to a UDP socket. Samples are in the MSG form where the
id field is a stream index and the parameters field is a 32 bits integer
encoding the sine value: `parameters = int32_t(sine(X)*2^30)`. The
`--offset=OFFSET` option specifies the X increment between two
consecutive sine samples.
--address=ADDRESS destination address (default 127.0.0.1)
--port=PORT destination UDP port (default 56780)
......@@ -52,32 +42,31 @@ specifies the X increment between two consecutive sine samples.
--end send a sample with id 0xffff at the end (if duration != 0)
--help print this help
ADDRESS is a IP address or a hostname. PORT, RATE and INDEX are natural integers.
DURATION and OFFSET are reals. Several --index=INDEX options can be specified;
one stream is generated for each specified stream index (if a stream index is
specified several times only the last one is taken into account). Several
--offset=OFFSET options can thus also be specified. They are associated
one-to-one to the different streams in their respective order of appearence. The
last specified --offset=OFFSET option, if any, overrides the default value. If
more options are specified than the number of streams, the extraneous are
ignored. The --address=ADDRESS, --port=PORT, --rate=RATE and --duration=DURATION
ADDRESS is a IP address or a hostname. PORT, RATE and INDEX are natural
integers. DURATION and OFFSET are reals. Several --index=INDEX options
can be specified; one stream is generated for each specified stream
index (if a stream index is specified several times only the last one is
taken into account). Several --offset=OFFSET options can thus also be
specified. They are associated one-to-one to the different streams in
their respective order of appearence. The last specified --offset=OFFSET
option, if any, overrides the default value. If more options are
specified than the number of streams, the extraneous are ignored. The
--address=ADDRESS, --port=PORT, --rate=RATE and --duration=DURATION
options are common to all streams.
Exit status:
0 if OK,
1 if minor problems (e.g., invalid options),
2 if serious trouble (e.g., cannot open socket).
```
----
client.pl plays the role of the visualization device. It receives data samples
in UDP packets, selects some of them based on their stream indices and
continuously plots the selected streams in different Gnuplot windows.
`client.pl` plays the role of the visualization device. It receives data samples in UDP packets, selects some of them based on their stream indices and continuously plots the selected streams in different Gnuplot windows.
```
Usage: ./client.pl [OPTION]...
Listen to a UDP socket for data samples and plot them. Samples are in the MSG
form where the id field is a stream index and the parameter field is a 32 bits
integer value to plot.
Listen to a UDP socket for data samples and plot them. Samples are in
the MSG form where the id field is a stream index and the parameter
field is a 32 bits integer value to plot.
--port=PORT UDP port to listen to (default 56780)
--index=INDEX index of stream to plot (default 0)
......@@ -92,31 +81,29 @@ integer value to plot.
--end interprets any sample with id=0xffff as a request to stop and exit
--help print this help
GEOMETRY format is the X11 one: [<width>{xX}<height>][{+-}<xoffset>{+-}<yoffset>].
PORT, INDEX, and SAMPLES are natural integers. YMIN, YMAX and THRESHOLD are
integers. Several --index=INDEX options can be specified; one plotting window is
created for each specified stream index (if a stream index is specified several
times only the last one is considered). Several --samples=SAMPLES options can
thus also be specified. They are associated one-to-one to the different streams
in their respective order of appearence. The last specified --samples=SAMPLES
option, if any, overrides the default value. If more options are specified than
the number of streams, the extraneous are ignored. The same holds for the
GEOMETRY format is the X11 one:
[<width>{xX}<height>][{+-}<xoffset>{+-}<yoffset>]. PORT, INDEX, and
SAMPLES are natural integers. YMIN, YMAX and THRESHOLD are integers.
Several --index=INDEX options can be specified; one plotting window is
created for each specified stream index (if a stream index is specified
several times only the last one is considered). Several
--samples=SAMPLES options can thus also be specified. They are
associated one-to-one to the different streams in their respective order
of appearence. The last specified --samples=SAMPLES option, if any,
overrides the default value. If more options are specified than the
number of streams, the extraneous are ignored. The same holds for the
--ymin=YMIN, --ymax=YMAX, --threshold=THRESHOLD, --title=TITLE and
--geometry=GEOMETRY options. The --port=PORT, --persist and --end options are
common to all streams.
--geometry=GEOMETRY options. The --port=PORT, --persist and --end
options are common to all streams.
Exit status:
0 if OK,
1 if minor problems (e.g., invalid options),
2 if serious trouble (e.g., cannot open socket or pipe to gnuplot).
```
----
test.sh simply launches the client and the server for testing, first using UDP
packets and then using a pipe. Of course, for testing, the client and the server
both run on the same computer but it is very easy to deploy this example on two
different nodes by changing the --address option of the server.
To run the test:
`test.sh` simply launches the client and the server for testing, first using UDP packets and then using a pipe. Of course, for testing, the client and the server both run on the same computer but it is very easy to deploy this example on two different nodes by changing the `--address` option of the server. To run the test:
```
./test.sh
```
###########################################################
# COPYRIGHT #
# --------- #
# #
# See Copyright Notice in COPYING and license in LICENSE. #
###########################################################
#!/usr/bin/env perl
use IO::Socket::INET;
......@@ -58,7 +65,7 @@ Exit status:
1 if minor problems (e.g., invalid options),
2 if serious trouble (e.g., cannot open socket or pipe to gnuplot).
Please report bugs to renaud\@pacalet.fr
Please report bugs to renaud.pacalet\@telecom-paristech.fr
EOS
# Parse common options
......
###########################################################
# COPYRIGHT #
# --------- #
# #
# See Copyright Notice in COPYING and license in LICENSE. #
###########################################################
#!/usr/bin/env perl
use IO::Socket::INET;
......@@ -53,7 +60,7 @@ Exit status:
1 if minor problems (e.g., invalid options),
2 if serious trouble (e.g., cannot open socket).
Report bugs to renaud\@pacalet.fr
Report bugs to renaud.pacalet\@telecom-paristech.fr
EOS
if(defined($options{"help"})) {
print $usage;
......
###########################################################
# COPYRIGHT #
# --------- #
# #
# See Copyright Notice in COPYING and license in LICENSE. #
###########################################################
#!/usr/bin/env bash
echo "Testing UDP packets..."
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment