The program stops here: $tele_client->recv($test, 100000000); The only way I have thought to fix it is by increasing the size of the received data. Is there a better way to do this?#! perl -slw use strict; use IO::Socket; use XML::Simple; $SIG{PIPE} = "IGNORE"; $\="\n"; my $img = '"http://updraft.unl.edu/~uas/uas/uas.png"'; my $post_time; my $test; my $xs = XML::Simple->new( RootName=>'Telemetry', XMLDecl => 1); my $check = 0; for (;;){ my $tele_client = IO::Socket::INET->new( 'localhost:12345' ) or pr +int $!; if ($tele_client){ while( <$tele_client>) { ################################# print "@@@ started @@@"; if ($tele_client){ print "*** Recv UA ***"; $tele_client->recv($test, 100000000); print $test; #UAS Functions: print "Reading in XML"; my $uasdata = $xs->XMLin($test); print "--- XML ---"; print Dumper($uasdata); if ("$uasdata->{VehicleID}" eq 'Velocity'){ #Open Placefile open UASPF,'>',"/home/uas/public_html/uas/uaspf.tx +t.bak" or die "Cannot Open File uavpf.txt.bak!"; #open UASPF,'>',"uaspf.txt.bak" or die "Cannot Ope +n File uavpf.txt.bak!"; &time; #print placefile elements print UASPF "Title: UAS GPS Position"; print UASPF "Threshold: 999"; print UASPF "RefreshSeconds: 2"; print UASPF "Iconfile: 1, 22, 21, 10, 14, $img\n"; print UASPF "Icon: $uasdata->{GPS}->{Latitude}, $u +asdata->{GPS}->{Longitude}, $uasdata->{GPS}->{Heading}, 1, 1, $post_t +ime Latitude: $uasdata->{GPS}->{Latitude} Longitude: $uasdata->{GPS}- +>{Longitude} Heading: $uasdata->{GPS}->{Heading} Speed: $uasdata->{Ai +rData}->{TrueAirSpeed} cm/s"; close UASPF; rename("/home/uas/public_html/uas/uaspf.txt.bak", +"/home/uas/public_html/uas/uaspf.txt") or die"Unable to replace: $!"; #rename("uaspf.txt.bak", "uaspf.txt") or die"Unabl +e to replace: $!"; print "*** UA Done ***"; } } } } print "SLEEP"; sleep 5; }
In reply to Receiving an XML packet using IO::Socket by deadpickle
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |