little improvements
This commit is contained in:
parent
3a20ddf824
commit
ea19c3618b
|
@ -37,8 +37,8 @@ if($cmd =~ /^r/){
|
||||||
$cmd=~s/r//;
|
$cmd=~s/r//;
|
||||||
$cmd+=1;
|
$cmd+=1;
|
||||||
my $fmt=shift;
|
my $fmt=shift;
|
||||||
while($cmd-->0){
|
|
||||||
my $read="";
|
my $read="";
|
||||||
|
while($cmd-->0){
|
||||||
while($read !~ /\\1.*\\0/){
|
while($read !~ /\\1.*\\0/){
|
||||||
my $rr="";
|
my $rr="";
|
||||||
if (@fh = $sel->can_read(100)) {
|
if (@fh = $sel->can_read(100)) {
|
||||||
|
@ -46,20 +46,34 @@ if($cmd =~ /^r/){
|
||||||
$read.=$rr;
|
$read.=$rr;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
print "Read: <"; sprint $read; print ">\n";
|
while ($read =~ s/\\1(.*?)\\0//){
|
||||||
$read =~ s/^\\1//;
|
my $str=$1;
|
||||||
|
my $cs=substr($str,0,30);
|
||||||
|
my $crc=unpack("n",substr($str,30,2));
|
||||||
|
my $crc2= crcccitt($cs),"\n";
|
||||||
if($fmt eq "m"){
|
if($fmt eq "m"){
|
||||||
print "M [",substr($read,0,1),"] ";
|
my $i=substr($str,0,1);
|
||||||
print "g=",unpack("C",substr($read,1,1))," ";
|
print "M [",substr($str,0,1),"] ";
|
||||||
print "t=",unpack("N",substr($read,2,4))," ";
|
print "g=",unpack("C",substr($str,1,1))," ";
|
||||||
print "beacon=",unpack("H*",substr($read,26,4))," ";
|
if($i eq "T"){
|
||||||
|
print "t=",unpack("N",substr($str,2,4))," ";
|
||||||
|
print "(",scalar gmtime unpack("N",substr($str,2,4)),") ";
|
||||||
|
print "beacon=",unpack("H*",substr($str,26,4))," ";
|
||||||
|
}elsif($i eq "B"){
|
||||||
|
print "t=",unpack("N",substr($str,2,4))," ";
|
||||||
|
print "ID=",unpack("c",substr($str,6,1))," ";
|
||||||
|
print "HOP=",unpack("n",substr($str,11,4))," ";
|
||||||
|
};
|
||||||
|
# print "\n";
|
||||||
|
}else{
|
||||||
|
print "Read: <"; sprint $str; print ">\n";
|
||||||
|
};
|
||||||
|
print "CRCFAIL" if ($crc ne $crc2);
|
||||||
print "\n";
|
print "\n";
|
||||||
};
|
};
|
||||||
my $cs=substr($read,0,30);
|
|
||||||
my $crc=substr($read,30,2);
|
|
||||||
print unpack("n",$crc),"<>";
|
|
||||||
print crcccitt($cs),"\n";
|
|
||||||
};
|
};
|
||||||
|
print "rest: <"; sprint $read; print ">\n";
|
||||||
|
exit;
|
||||||
}elsif ($cmd eq "mt"){
|
}elsif ($cmd eq "mt"){
|
||||||
my $par=pack("H*",shift);
|
my $par=pack("H*",shift);
|
||||||
print "Write: <"; sprint $par; print ">\n";
|
print "Write: <"; sprint $par; print ">\n";
|
||||||
|
@ -120,7 +134,7 @@ if($cmd =~ /^r/){
|
||||||
}elsif($scmd eq "b"){
|
}elsif($scmd eq "b"){
|
||||||
$par.="B";
|
$par.="B";
|
||||||
$par.=chr(shift); #gen
|
$par.=chr(shift); #gen
|
||||||
$par.=pack("N",scalar(time)+1*60*60+ 300);
|
$par.=pack("N",scalar(time)+1*60*60+ 600);
|
||||||
|
|
||||||
$par.= pack("C",shift||0);
|
$par.= pack("C",shift||0);
|
||||||
$par.= pack("C",0);
|
$par.= pack("C",0);
|
||||||
|
@ -137,6 +151,7 @@ if($cmd =~ /^r/){
|
||||||
};
|
};
|
||||||
|
|
||||||
$par.=pack("n",crcccitt($par));
|
$par.=pack("n",crcccitt($par));
|
||||||
|
# $par.="00";
|
||||||
print "Write: <"; sprint $par; print ">\n";
|
print "Write: <"; sprint $par; print ">\n";
|
||||||
while($cmd-->0){
|
while($cmd-->0){
|
||||||
syswrite(SER, '\1'.$par.'\0');
|
syswrite(SER, '\1'.$par.'\0');
|
||||||
|
|
Loading…
Reference in New Issue