Skip to content

Commit

Permalink
Create create_datalog_index.pl
Browse files Browse the repository at this point in the history
  • Loading branch information
DE-cr committed Mar 23, 2023
1 parent 1d94822 commit 3cec4a2
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions BSB_LAN/scripts/create_datalog_index.pl
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 3cec4a2

Please sign in to comment.