From 93da6b1d525944aa35ddd615076f24ba71254064 Mon Sep 17 00:00:00 2001 From: Michal Sojka Date: Tue, 2 Dec 2014 15:50:24 +0100 Subject: [PATCH] Always use bi-direction target communication I don't remember what was the reason for setting up bi-directional interaction only when on terminal. It seems, it is useful to have also when not on terminal - for example when running under socat. With this change, I'm able to use novaboot with socat to load u-boot to the target using X-modem protocol: socat EXEC:"novaboot -t mytarget --no-uboot --no-reset /dev/null" EXEC:"sx -kbvv -t 10 ./images/u-boot-spl.bin" --- novaboot | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/novaboot b/novaboot index 90b7096..9cc5e1b 100755 --- a/novaboot +++ b/novaboot @@ -1107,28 +1107,25 @@ if ($interaction && defined $exp) { if ($interactive && !@exiton) { $interrupt = '"~~."'; } - my $note = (-t STDIN) ? '' : '- only target->host '; - print STDERR "novaboot: Serial line interaction $note(press $interrupt to interrupt)...\n"; + print STDERR "novaboot: Serial line interaction (press $interrupt to interrupt)...\n"; $exp->log_stdout(1); if (@exiton) { $exp->expect($exiton_timeout, @expect_raw, @exiton) || die("exiton timeout"); print STDERR "\n"; } else { my @inputs = ($exp); - if (-t STDIN) { # Set up bi-directional communication if we run on terminal - my $infile = new IO::File; - $infile->IO::File::fdopen(*STDIN,'r'); - my $in_object = Expect->exp_init($infile); - $in_object->set_group($exp); - - if ($interactive) { - $in_object->set_seq('~~\.', sub { print STDERR "novaboot: Escape sequence detected\r\n"; undef; }); - $in_object->manual_stty(0); # Use raw terminal mode - } else { - $in_object->manual_stty(1); # Do not modify terminal settings - } - push(@inputs, $in_object); + my $infile = new IO::File; + $infile->IO::File::fdopen(*STDIN,'r'); + my $in_object = Expect->exp_init($infile); + $in_object->set_group($exp); + + if ($interactive) { + $in_object->set_seq('~~\.', sub { print STDERR "novaboot: Escape sequence detected\r\n"; undef; }); + $in_object->manual_stty(0); # Use raw terminal mode + } else { + $in_object->manual_stty(1); # Do not modify terminal settings } + push(@inputs, $in_object); #use Data::Dumper; #print Dumper(\@expect_raw); $exp->expect(undef, @expect_raw) if @expect_raw; -- 2.39.2