2 # USAGE: fgfsscript [host [port]]
9 my $host = (shift || 'localhost');
10 my $port = (shift || 5501);
18 $fgfs = &connect($host, $port, 120) || die " can't open socket\n";
21 # wait for random altitude (0--3000 ft.) to be reached
22 my $alt = int(rand(3000));
23 print "disaster begins at $alt ft. AGL\n";
26 $i = &get("/position/altitude-agl-ft");
27 print "\r" . int($i) . " ft.";
28 print "\n" and last if $i > $alt;
31 print "start fuel dumping :-)\n";
32 for ($i = 0; $i < 4; $i++) {
34 &set("/consumables/fuel/tank[$i]/level-gal_us", 0);
35 print "tank $i empty\n";
47 &send("get " . shift);
48 eof $fgfs and die "\nconnection closed by host";
51 /^-ERR (.*)/ and die "\nfgfs error: $1\n";
60 &send("set $prop $value");
66 print $fgfs shift, "\015\012";
74 my $timeout = (shift || 120);
79 if ($socket = IO::Socket::INET->new(
84 $socket->autoflush(1);
95 # vi:ts=8:sw=8:noet:nowrap:cindent