From 6ccd4478702db46a9a8a1ce288c9cfc73a305540 Mon Sep 17 00:00:00 2001 From: Stefan `Sec` Zehl Date: Thu, 5 Apr 2012 15:00:27 +0200 Subject: [PATCH] Allow easy selection of the serial device --- tools/mesh/beacon-udp.pl | 12 ++++++++++-- tools/mesh/lib/r0ket.pm | 7 ++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/tools/mesh/beacon-udp.pl b/tools/mesh/beacon-udp.pl index f9b3666..8b89189 100755 --- a/tools/mesh/beacon-udp.pl +++ b/tools/mesh/beacon-udp.pl @@ -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=""; + }else{ + $dev=~s!/dev/!!; + }; + print "OpenBeacon Reader $id sending [$dev] to [$server:$port]\n"; print "\n"; }; my $lasttime=time; diff --git a/tools/mesh/lib/r0ket.pm b/tools/mesh/lib/r0ket.pm index d296a45..013457f 100755 --- a/tools/mesh/lib/r0ket.pm +++ b/tools/mesh/lib/r0ket.pm @@ -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 {