--- /dev/null
+#!/usr/bin/perl -w
+
+use strict;
+
+use Getopt::Std;
+use FileHandle;
+use Time::HiRes qw(time usleep);
+
+my %opt;
+if (!getopts('b:e:fp', \%opt) || !$ARGV[0]) {
+ die "Usage: $0 [-b starttime] [-e endtime] [-f] [-p] logfile\n"
+ . "-f ... replay as fast as possible, without pausing\n"
+ . "-p ... at the end, want for a keypress\n";
+}
+
+my $logfile = shift @ARGV;
+
+open my $logfh, '<', $logfile
+ or die "Can't open $logfile: $!";
+
+my $start_prog_time = time;
+my $start_log_time;
+
+while (my $line = <$logfh>) {
+ chomp $line;
+ $line =~ s/\A\s+//xms;
+ my ($l_time, @data) = split(/\s+/, $line);
+
+ next if ($opt{b} && $opt{b} > $l_time);
+ next if ($opt{e} && $opt{e} < $l_time);
+
+ print pack("C*", map { hex $_ } @data);
+ flush STDOUT;
+
+ if (!$opt{f}) {
+ $start_log_time ||= $l_time;
+
+ my $log_delay = $l_time - $start_log_time;
+ my $real_delay = time - $start_prog_time;
+ if ($real_delay < $log_delay) {
+ print STDERR "usleep for ", $log_delay - $real_delay, "\n";
+ usleep(1000_000 * ($log_delay - $real_delay));
+ }
+ }
+}
+
+if ($opt{p}) {
+ print STDERR "Replay log finished - press a key: ";
+ flush STDERR;
+ $_ = <STDIN>;
+}
+