2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-08 13:24:56 +00:00

30_LIGHTIFY.pm: preparation for partial messages

git-svn-id: https://svn.fhem.de/fhem/trunk@7963 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
justme-1968 2015-02-13 20:17:35 +00:00
parent a8cc0c85a1
commit 736b4584f5

View File

@ -95,6 +95,7 @@ LIGHTIFY_Connect($)
my @send_queue = ();
$hash->{SEND_QUEUE} = \@send_queue;
$hash->{UNCONFIRMED} = 0;
$hash->{PARTIAL} = "";
my $socket = IO::Socket::INET->new( PeerAddr => $hash->{Host},
PeerPort => 4000, #AttrVal($name, "port", 4000)
@ -356,6 +357,7 @@ LIGHTIFY_Parse($$)
my $name = $hash->{NAME};
$hex = uc($hex);
Log3 $name, 4, "$name: parsing: $hex";
my $length = hex(substr($hex,2*1,2*1).substr($hex,2*0,2*1));
my $response = substr($hex,2*3,2*1);
@ -452,9 +454,21 @@ LIGHTIFY_Read($)
}
my $hex = unpack('H*', $buf);
Log3 $name, 4, "$name: received: $hex";
Log3 $name, 5, "$name: received: $hex";
LIGHTIFY_Parse($hash, $hex);
return undef;
$hash->{PARTIAL} .= $hex;
my $length = hex(substr($hash->{PARTIAL},2*1,2*1).substr($hash->{PARTIAL},2*0,2*1));
while( $length*2 <= length($hash->{PARTIAL}) ) {
$hex = substr($hash->{PARTIAL},0,$length*2);
$hash->{PARTIAL} = substr($hash->{PARTIAL},$length*2);
$length = hex(substr($hash->{PARTIAL},2*1,2*1).substr($hash->{PARTIAL},2*0,2*1));
LIGHTIFY_Parse($hash, $hex);
}
}
1;