#!/usr/bin/env perl use strict; use warnings; use Path::Tiny; use IO::Termios; my $makefile = path(__FILE__)->parent(2)->child('Makefile'); my ($port) = $makefile->slurp() =~ /^UPLOAD_PORT\s*=\s*(\S+)/sm; my $fh = IO::Termios->open($port, '115200,8,n,1') or die "Can't open $port: $!\n"; $fh->cfmakeraw(); print $fh "xx logcat\n" or die "Can't write: $!"; my $in_log=0; while (<$fh>) { if (/^xx end\b/) { last; } elsif ($in_log) { print; } elsif (/^xx begin\b/) { $in_log=1; } }