1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/perl
use strict;
our @send;
fillbuffer();
my $buf;
foreach (@send)
{
$buf=$buf.pack("c",$_);
}
my $len=@send;
print "<$buf> <$len>";
# $ok=$client_socket->syswrite($buf,$len);
sub fillbuffer
{
my $a=STX();my $b=0x11;my $c=0x12;my $d=ETX();
@send=($a,$b,$c,$d);
}
sub STX() { "\002" };
sub ETX() { "\003" };
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#!/usr/bin/perl use strict; use warnings; my @send= fillbuffer(); my $buf=pack('s*',@send); my $len=@send; print "<$buf> <$len>"; # $ok=$client_socket->syswrite($buf,$len); sub fillbuffer { return ( STX(),0x11,0x12,ETX() ); } sub STX() { "\002" }; sub ETX() { "\003" };
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; $Data::Dumper::Useqq=1; my @send= fillbuffer(); my $buf=pack('s*',@send); print Dumper($buf,length $buf); # $ok=$client_socket->syswrite($buf,length $buf); sub fillbuffer { return ( STX(),0x11,0x12,ETX() ); } sub STX() { unpack('C',"\002") }; sub ETX() { 3 };
my $buf=pack('c*',@send);