From 3cec4a29a8d276d1a14240fceb8fa14634d9129b Mon Sep 17 00:00:00 2001 From: -cr <105788188+DE-cr@users.noreply.github.com> Date: Thu, 23 Mar 2023 14:45:53 +0100 Subject: [PATCH] Create create_datalog_index.pl --- BSB_LAN/scripts/create_datalog_index.pl | 30 +++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 BSB_LAN/scripts/create_datalog_index.pl diff --git a/BSB_LAN/scripts/create_datalog_index.pl b/BSB_LAN/scripts/create_datalog_index.pl new file mode 100755 index 000000000..00e57d0ba --- /dev/null +++ b/BSB_LAN/scripts/create_datalog_index.pl @@ -0,0 +1,30 @@ +#!/usr/bin/perl -w \ + +## +# bsb-lan utility to re-build datalog.idx from datalog.txt, +# to be used to replace the existing datalog from the Arduino IDE via +# Tools -> ESP32 Sketch Data Upload + +use strict; +use warnings; + +die "Usage: $0 datalog.txt > datalog.idx\n" + if @ARGV > 1 || -t STDOUT; + +binmode STDOUT; +my $pos = 0; +my $prev = ""; +while (<>) { + next unless /(\d+)\.(\d+)\.(\d+)/; + my $date = pack "CCv", $1, $2, $3; + next if $date eq $prev; + print $date, pack "V", $pos; + $prev = $date; +} continue { + $pos += length; +} + +__END__ +Milliseconds;Date;Parameter;Description;Value;Unit +601171;19.03.2023 20:06:27;8700;Aussentemperatur;11.2;°C +601375;19.03.2023 20:06:27;8770;Raumtemperatur-Istwert 2;20.3;°C