make r0ket lib do wait_ok for config commands.

This commit is contained in:
Stefan `Sec` Zehl 2012-05-06 23:33:14 +02:00
parent 0fccf9dd26
commit 5b7e0a38ce
2 changed files with 19 additions and 7 deletions

View File

@ -346,30 +346,44 @@ sub send_pkt_num {
sub send_pkt {
send_pkt_num(shift,1);
wait_ok(1);
};
sub set_txmac {
send_pkt_num(shift,3);
wait_ok(1);
};
sub set_rxmac {
send_pkt_num(shift,4);
wait_ok(1);
};
sub set_channel {
send_pkt_num(pack("C",shift),5);
wait_ok(1);
};
sub set_rxlen {
$rxlen=$_[0];
send_pkt_num(pack("C",shift),6);
wait_ok(1);
};
sub get_id {
send_pkt_num("",7);
my $id=get_data(7);
wait_ok(1);
return $id;
};
sub wait_ok {
my ($type,$pkt);
while(1){
($type,$pkt)=get_data();
while($type ne "2"){
print "pkt[$type]=[",length($pkt),"]",(sprint $pkt),"\n";
($type,$pkt)=get_data();
last if ($type == 2);
die "wait_ok ran into timeout!\n" if($type == 0);
print "wait_ok: pkt[$type]=[",length($pkt),"]",(sprint $pkt),"\n";
};
print "ok!\n";
print "ok!\n" unless ($quiet || $_[0]);
return 1;
};
1;

View File

@ -169,13 +169,11 @@ if($cmd =~ /^r/){
}elsif ($set =~ /^len/){
r0ket::set_rxlen(shift);
}elsif ($set =~ /^id/){
r0ket::send_pkt_num("",7);
my $id=r0ket::get_data(7);
my $id=r0ket::get_id();
print "r0ket id: ",r0ket::hprint($id),"\n";
}else{
die "Unknown config argument $set\n";
};
r0ket::wait_ok();
}elsif ($cmd =~ /^s/){
$cmd=~s/^//;