better commandline handling
allow reading of uuid with "c id"
This commit is contained in:
parent
4f859c82a0
commit
e6b3afbab0
|
@ -14,22 +14,26 @@ use r0ket;
|
||||||
|
|
||||||
$|=1;
|
$|=1;
|
||||||
|
|
||||||
my $ser;
|
### Commandline options
|
||||||
if($ARGV[0] eq "-d"){
|
use Getopt::Long;
|
||||||
shift;
|
my $ser = undef;
|
||||||
$ser=shift;
|
my $help = 0;
|
||||||
};
|
my $writend = 0;
|
||||||
r0ket::r0ket_init($ser);
|
GetOptions (
|
||||||
|
"dev=s" => \$ser,
|
||||||
|
"help" => \$help,
|
||||||
|
"write" => \$writend,
|
||||||
|
);
|
||||||
|
|
||||||
my @fh;
|
$help=1 if($ARGV[0] =~ /^[h?]/);
|
||||||
my $read;
|
|
||||||
|
|
||||||
if ($ARGV[0] =~ /^-?-?h/ || $#ARGV == -1){
|
if ($help){
|
||||||
print STDERR "Mini-Help:\n";
|
print STDERR "Mini-Help:\n";
|
||||||
print STDERR "-d <devicename> (or \$R0KETBRIDGE)\n";
|
print STDERR "-d <devicename> (or \$R0KETBRIDGE)\n";
|
||||||
print STDERR "-w write beacon2nick file\n";
|
print STDERR "-w write beacon2nick file\n";
|
||||||
print STDERR "\n";
|
print STDERR "\n";
|
||||||
print STDERR "recv<num>: receive (number) pakets\n";
|
print STDERR "recv<num>: receive (number) pakets\n";
|
||||||
|
print STDERR " - r : try to autodetect packet format\n";
|
||||||
print STDERR " - r hex : hexdump packets\n";
|
print STDERR " - r hex : hexdump packets\n";
|
||||||
print STDERR " - r ascii : asciidump packets\n";
|
print STDERR " - r ascii : asciidump packets\n";
|
||||||
print STDERR " - r beacon : parse as openbeacon\n";
|
print STDERR " - r beacon : parse as openbeacon\n";
|
||||||
|
@ -52,22 +56,23 @@ if ($ARGV[0] =~ /^-?-?h/ || $#ARGV == -1){
|
||||||
print STDERR "- c tx - set txmac\n";
|
print STDERR "- c tx - set txmac\n";
|
||||||
print STDERR "- c len - set rxlength\n";
|
print STDERR "- c len - set rxlength\n";
|
||||||
print STDERR "- c ch - set channel\n";
|
print STDERR "- c ch - set channel\n";
|
||||||
print STDERR "- c <opt>hex - set any option via hex string\n";
|
print STDERR "- c <opt>hex - set any of the previous option via hex string\n";
|
||||||
|
print STDERR "- c id - read beacon id\n";
|
||||||
print STDERR "\n";
|
print STDERR "\n";
|
||||||
print STDERR "etc...\n";
|
print STDERR "etc...\n";
|
||||||
exit(1);
|
exit(1);
|
||||||
};
|
};
|
||||||
|
|
||||||
my $writend=0;
|
|
||||||
if ($ARGV[0] eq "-w"){
|
|
||||||
shift;
|
|
||||||
$writend=1;
|
|
||||||
};
|
|
||||||
|
|
||||||
END{
|
END{
|
||||||
r0ket::writebeacon if($writend);
|
r0ket::writebeacon if($writend);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
r0ket::r0ket_init($ser);
|
||||||
|
$r0ket::verbose=1;
|
||||||
|
|
||||||
|
my @fh;
|
||||||
|
my $read;
|
||||||
|
|
||||||
my $cmd=shift;
|
my $cmd=shift;
|
||||||
|
|
||||||
if($cmd =~ /^r/){
|
if($cmd =~ /^r/){
|
||||||
|
@ -163,6 +168,10 @@ if($cmd =~ /^r/){
|
||||||
r0ket::set_channel(shift);
|
r0ket::set_channel(shift);
|
||||||
}elsif ($set =~ /^len/){
|
}elsif ($set =~ /^len/){
|
||||||
r0ket::set_rxlen(shift);
|
r0ket::set_rxlen(shift);
|
||||||
|
}elsif ($set =~ /^id/){
|
||||||
|
r0ket::send_pkt_num("",7);
|
||||||
|
my $id=r0ket::get_data(7);
|
||||||
|
print "r0ket id: ",r0ket::hprint($id),"\n";
|
||||||
}else{
|
}else{
|
||||||
die "Unknown config argument $set\n";
|
die "Unknown config argument $set\n";
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue