Allow easy selection of the serial device

This commit is contained in:
Stefan `Sec` Zehl 2012-04-05 15:00:27 +02:00
parent b7155bbb71
commit 6ccd447870
2 changed files with 12 additions and 7 deletions

View File

@ -22,6 +22,7 @@ my $verbose = 0;
my $fast = 0;
my $channel = 81;
my $mac = "0102030201";
my $ser = undef;
my $help = 0;
my $intvl = 2;
my $lintvl = 60;
@ -29,6 +30,7 @@ GetOptions (
"server=s" => \$server,
"port=n" => \$port,
"id=n" => \$id,
"dev=s" => \$ser,
"fast" => \$fast,
"verbose" => \$verbose,
"channel=n" => \$channel,
@ -40,7 +42,7 @@ if($help){
die "Currently no help. Please check the source\n";
};
r0ket::r0ket_init();
$ser=r0ket::r0ket_init($ser);
# Default openbeacon settings.
r0ket::set_txmac(pack("H*",$mac)); # Not really needed.
@ -73,7 +75,13 @@ my $errors=0;
my $ctr=0;
my($lcrcerr,$lctr,$lerrors)=(0,0,0);
if($verbose){
print "OpenBeacon Reader $id sending to [$server:$port]\n";
my($dev)=$ser;
if(!defined $dev){
$dev="<undef>";
}else{
$dev=~s!/dev/!!;
};
print "OpenBeacon Reader $id sending [$dev] to [$server:$port]\n";
print "\n";
};
my $lasttime=time;

View File

@ -288,11 +288,7 @@ sub nice_beacon{
};
sub r0ket_init{
my $ser;
if ($ARGV[0] eq "-s"){
shift;
$ser=shift;
};
my $ser=shift;
if(!defined $ser){
if (defined $ENV{R0KETBRIDGE} && -e $ENV{R0KETBRIDGE}){
$ser=$ENV{R0KETBRIDGE}
@ -305,6 +301,7 @@ sub r0ket_init{
if($verbose){
print "using: $ser\n";
};
return $ser;
};
sub send_raw {