my @localtime=localtime;
my $hour=strftime ("%d.%m.%Y %H:%M:%S", @localtime);
our $receive_T->insert('end',$hour."\n");
####
$receive_T = $receive_Tk->ROText(-relief=>'groove',-width=>72,-height=>20,-font=>'Courier 8 bold')->pack();
$receive_T->repeat(5000,\&Receive2);
####
#!/usr/bin/perl
use strict;
use Pod::Usage;
use Getopt::Std;
our $RECEIVED;
our $PORT;
my $x;
our $receive_T;
our $ob;
my $timeout;
sub Receive{
while(1){
$RECEIVED = ReadPort($PORT, 5);
if($RECEIVED ne ""){
print "\t$x\tRX>\t$RECEIVED\n";
$receive_T->insert('end',"\t$x\tRX>".$RECEIVED."\n");
$x++;
}
}
}
sub ReadPort{
# Store timeout time in millisecond tic $timeout = $ob->get_tick_count + (1000 * $timeout);
$ob->lookclear; # Clear lookfor buffers
while(1) {
# polls until we have a line of data
# return unless ( defined ($gotit = $ob->streamline) );
if ($RECEIVED ne "") {
my ($found, $end, $obattern, $instead) = $ob->lastlook;
return "$RECEIVED";
}
# or an error
return if ($ob->reset_error);
if ($ob->get_tick_count > $timeout) {
my ($match, $after, $obattern, $instead) = $ob->lastlook;
return ;
}
}
}