From: Christian Weiske Date: Sat, 5 Feb 2011 16:43:15 +0000 (+0100) Subject: restructure directory layout, add dummy data generator X-Git-Tag: v1.0.0~50 X-Git-Url: https://git.cweiske.de/usb-wde1-tools.git/commitdiff_plain/2dba960b30011397cbb176a6cbf1ee9d745ee933 restructure directory layout, add dummy data generator --- diff --git a/README b/README deleted file mode 100644 index 2cd368c..0000000 --- a/README +++ /dev/null @@ -1,19 +0,0 @@ -usb-wde1 tools --------------- -Tools to collect and analyze data from the USB-WDE1 weather receiver from ELV.de - - -idea ----- -1. pipe each received line to a command -2. command splits up line into variables -3. add variable data to rrdtool -4. repeat - - -idea: cat socat output to "read" - - - -Test it: -$ php lines-to-stdout.php | ./work-with-lines.sh diff --git a/doc/92030_USB_WDE1_V1.0_UM.pdf b/doc/92030_USB_WDE1_V1.0_UM.pdf new file mode 100644 index 0000000..23a2d78 Binary files /dev/null and b/doc/92030_USB_WDE1_V1.0_UM.pdf differ diff --git a/doc/logview-openformat-Formatbeschreibung.htm b/doc/logview-openformat-Formatbeschreibung.htm new file mode 100644 index 0000000..d9d004b --- /dev/null +++ b/doc/logview-openformat-Formatbeschreibung.htm @@ -0,0 +1,336 @@ + + + + +Formatbeschreibung + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + +
+
+ +Home
+
+ + +
+ + + + + + + + +
   + LogView    +    + Downloads    + Doku    + Artikel    + Forum    +   +   +   +   +     + Deutsch   + English + +
+
+ + +
+ + + + + + + + + + + + +
+ + + + + + +
+
+ + +
+
+ + +
+ + + + + + +

1. Format Overview

 

+

 

+

 

+

The OpenFormat is designed to enable developers to inferface their own hardware with LogView via a configurable serial data protocol. To use the OpenFormat (short name: OF) you have to create an INI file and an optional picture for your device. The INI file contains all the needed configuration information for LogView to display your serial data.

+

 

+

The format OF is pure ASCII data where the items are separated by ";".

+

An OF packet starts with "$", then has several values separated by ";" and always ends up with CR + LF (#13#10). An example of a packet your device may produce is:

+

 

+

$1;1;0;1133;318;0;0;0;0;0;20;21;0;16<cr><lf>

+

 

+

We will explain what you can make all the values do in a bit.

2. - - - Device Settings - - -

Name - The name of your device
+Vendor - Your (company) name
+Vendor Link - Company link [optional]
+LogView Link - If we have a special info on our website [optional]
+
+TimeStep - Time difference between two packets within one channel. This is a global setting for all channels.
+Time given from device - If set, the time must be included in the packet and will be used by LogView. If not set, the time is calculated from TimeStep and counting your packets.
+We will go into more detail later, see chapter 4c.
+
+
Value format - At the moment LogView only supports ASCII format.
+Checksum - If you can make your device generate a checksum, LogView can check it. Again more detail later, see chapter 4e
+
none - Checksum isn't used. Checksum = 0 !
+xor - Your device must use the XOR method for checksum calculations.

3. - - - Port Settings - - -

+

 

+

+

Baudrate - Device baud rate 
+Databits - Device data bits (7 / 8 / 9)
+Stopbits - Device stop bits (1 / 1,5 / 2)
+Flowcontrol - Flowcontrol (None / Xon,Xoff / Hardware)
+State DTR - Controls the state of the DTR line 
+State RTS - Controls the state of the RTS line 
+Clustersize - Defines the size of the packet in Bytes. 
+Don´t change this value if you don´t know the exact value.
+Negative values tell LogView that the size is variable. 
+
+DelayTime - These values control the receiving and sending of serial data and are related to the used baudrate.
+Increase the values for RTOCharDelay if you have problems receiving your data correctly. 
+Useable values for xxxCharDelay are 200-2000. 
+WTOxxxx controls the timeouts for sending. Normally you don´t have to change this.

4. Packet parts

An average packet may look like the one shown below. Have a quick look as in the next few chapters we will explain it in detail.

+

$1;1;0;1133;318;0;0;0;0;0;20;21;0;16<cr><lf>
+....................................-------- > End Sign #13#10
+..................................-- > Checksum (see chapter 4e)
+.......-------------------------- > Data Stream (see chapter 4d)
+.....- > Time Stamp (see chapter 4c)
+...- > States (see chapter 4b)
+.- > Channel Number (see chapter 4a)
+- > Start Sign "$"

4a. Channel Number

+

The OF can handle up to 8 separated channels with 40 data streams each. We class data streams as the values you want to display, such as voltage, current, etc. Channels are something most devices don't make use of. To explain say for instance you built a changer that can independantly change 3 batteries at once but you still only wanted one serial connection to your PC. Logview can cope with all of them at once by using channels and assigning each individual charger to a seperate channel.

+

 

+

In our example from chapter 1. the bold entry is the channel number. +

 

+

$1;1;0;1133;318;0;0;0;0;0;20;21;0;16<cr><lf>

+

+

4b. States

+

[Stati]
+StatiAnzahl = 1
+
+001 = Flight logging

+ +

 

+

So in state 1 Logview will name the data set "Flight logging".

+
+

 

+

+

You have to define at least one state within your INI file. The states are used in LogView to build useful dataset names.

+

Some example state names might be : charging, discharging, balancing, Charging in Lipo Mode, ... etc.

+

 

+

States are only labels which can contain any ASCII character.

+

 

+

Again in our example the bold entry is the state.

+

 

+

$1;1;0;1133;318;0;0;0;0;0;20;21;0;16<cr><lf>

+

 

+

And in the INI file

+

 

+

4c. Time Stamp

 

+

 

+

$1;1;;1133;318;0;0;0;0;0;20;21;0;16<cr><lf>
+....^^

+

 

+

The Timestamp (if given by your device) should be given in seconds. You can use fractions, for instance 200ms = 0.2

+

 

+

Always start at 0 !

+

 

+

Again in our example the bold entry is the timestamp.

+

 

+

$1;1;0;1133;318;0;0;0;0;0;20;21;0;16<cr><lf>

+

 

+

If you don't want your device to give a timestamp you have to set "Time given from device" in "- - - Device Settings - - -" to off, then logview will use the "TimeStep" value in "- - - Device Settings - - -" multiplied by the packet count to work out the passage of time.

+

 

+

If no timestamp is sent you have to send ;; !

+

 

+

 

4d. Data Stream

 

+

 

+

 

+

You have to let LogView know how to interpret each of the data items which are part of your packet. To explain this let's use the example from above:

+

 

+

$1;1;0;1133;318;0;0;0;0;0;20;21;0;16<cr><lf>

+

 

+

The items in bold are the data items, this example has 10 seperate data items.

+

 

+

Each of the data items must be specified in the INI file. These are the settings used:

+

 

+

Name (Messgröße) - name of the value (for example Voltage)
+Unit (Einheit) - unit (U for voltage)
+Symbol - symbol (V for voltage)
+Factor (Faktor) - floating value for the value calculation (see explanation) - default : 1,0
+Pre Factor Offset (OffsetWert) - floating value for the value calculation (see explanation) - default : 0,0
+Post Factor Offset (OffsetSumme) - floating value for the value calculation (see explanation) - default : 0,0

+

 

+

 

+

 

+

If you want LogView to display the values from your device verbatim you don´t have to change the last 3 settings.

+

 

+

If you want to add an offset or a scaling factor to the sent value you can specify it with "Factor", "Pre Factor Offset" and "Post Factor Offset".

+

LogView calculates the resulting value with this formula:

+

 

+

y =  ( x  +  [Pre Factor Offset] )  *  [Factor]   +   [Post Factor Offset]

+

 

+

y:                            displayed value

+

x:                            input value, sent in data packet

+

Pre Factor Offset:   OffsetWert

+

Factor:                    Faktor

+

Post Factor Offset: OffsetSumme 

+

 

4e. Checksum

 Example code for XOR Calculation (Pascal / Delphi Code !!):
+
+
CheckCalc := 0;
+Data := '$1;1;0;1133;318;0;0;0;0;0;20;21;0;' // see Example above !
+For _i := 1 to Length(Data) do begin
+  CheckCalc := CheckCalc XOR Byte(Data[_i]);
+end;
+
+
This means LogView takes the data bytes until the last ";" for the checksum calculation.
+
+$1;1;0;1133;318;0;0;0;0;0;20;21;0;16<cr><lf> 
+
Data used for the checksum calculation

+

 

+


+

+
+
+
+
+Aktualisierung: 2008/10/22 - Dominik Schmidt
+
+ + +
+ +zum Seitenanfang | + +eine Seite zurück
+ +
+
+ +
+ + +
+ + + + + +
+
+ + + + + + \ No newline at end of file diff --git a/dummy-data-generator.php b/dummy-data-generator.php new file mode 100755 index 0000000..505d133 --- /dev/null +++ b/dummy-data-generator.php @@ -0,0 +1,37 @@ +#!/usr/bin/env php + 1, + 'state' => 1, + 'timestamp' => '' +); +foreach (array('t', 'h') as $type) { + for ($n = 0; $n < 8; $n++) { + $data[$type . $n] = ''; + } +} +$data = array_merge( + $data, + array( + 'tc' => '', + 'fc' => '', + 'wg' => '', + 'ns' => '', + 'rain' => '', + 'checksum' => 0 + ) +); + +$n = 0; +while (true) { + foreach ($arChannels as $nChanNum) { + $data['t' . $nChanNum] = str_replace('.', ',', rand(160, 260) / 10); + $data['h' . $nChanNum] = rand(30, 80); + } + echo '$' . implode(';', $data) . "\r\n"; + sleep(1); +} + +?> \ No newline at end of file diff --git a/lines-to-stdout.php b/lines-to-stdout.php deleted file mode 100644 index eb6b39d..0000000 --- a/lines-to-stdout.php +++ /dev/null @@ -1,9 +0,0 @@ - \ No newline at end of file diff --git a/multilinefile b/multilinefile deleted file mode 100644 index 00c077e..0000000 --- a/multilinefile +++ /dev/null @@ -1,6 +0,0 @@ -line1 -line2 -line3 -a -b -c diff --git a/munin/log-single-line.sh b/munin/log-single-line.sh new file mode 100755 index 0000000..50c6f43 --- /dev/null +++ b/munin/log-single-line.sh @@ -0,0 +1,19 @@ +#!/bin/sh +#Logs a single line into the log file passed as script parameter + + +#split words by semicolons +IFS=";" + +#Beispielausgabe USB-WDE1: +# $1;1;;13,8;22,7;22,6;17,8;22,2;21,2;22,9;;59;35;38;49;38;40;35;;;;;;;0 +# Doku des Formats in 92030_USB_WDE1_V1.0_UM.pdf bei elv.de verfügbar +# Format ist "Logview openformat" +# http://www.logview.info/cms/d_formatbeschreibung.phtml + +while read -r line +do + timestamp = `date +%s` + echo $line sed "s/$1;1;;/$1;1;$timestamp;/" +done +echo "done with everything" diff --git a/own/lines-to-stdout.php b/own/lines-to-stdout.php deleted file mode 100644 index eb6b39d..0000000 --- a/own/lines-to-stdout.php +++ /dev/null @@ -1,9 +0,0 @@ - \ No newline at end of file diff --git a/work-with-lines.sh b/work-with-lines.sh deleted file mode 100755 index 9e52c9d..0000000 --- a/work-with-lines.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh - -#split words by semicolons -IFS=";" - -#Beispielausgabe USB-WDE1: -# $1;1;;13,8;22,7;22,6;17,8;22,2;21,2;22,9;;59;35;38;49;38;40;35;;;;;;;0 -# Doku des Formats in 92030_USB_WDE1_V1.0_UM.pdf bei elv.de verfügbar - -#Variablenamen: -# t1-t8: Temperatur in °C der Sensoren 1-8 -# f1-f8: Feuchtegrad in % der Sensoren 1-8 -# tc: Temperatur Kombinsensor in °C -# fc: Feuchtegrad Kombinsensor in % -# wg: Windgeschwindigkeit in km/h -# ns: Niederschlag (Wippenschläge) -# regen: Regen 1=ja, 0=nein -while read -r startzeichen zustand zeitstempel\ - t1 t2 t3 t4 t5 t6 t7 t8\ - f1 f2 f3 f4 f5 f6 f7 f8\ - tc fc wg ns regen -do - echo "line:" - echo 1: $one , 2: $two, 3: $three, 4: $four -done -echo "done with everything"