2 # USAGE: fgfsscript [host [port]]
3 # Melchior FRANZ, a8603365@unet.univie.ac.at
10 my $host = (shift || 'localhost');
11 my $port = (shift || 5501);
19 $fgfs = &connect($host, $port, 120) || die " can't open socket\n";
22 # wait for random altitude (0--3000 ft.) to be reached
23 my $alt = int(rand(3000));
24 print "disaster begins at $alt ft. AGL\n";
27 $i = &get("/position/altitude-agl-ft");
28 print "\r" . int($i) . " ft.";
29 print "\n" and last if $i > $alt;
32 print "start fuel dumping :-)\n";
33 for ($i = 0; $i < 4; $i++) {
35 &set("/consumables/fuel/tank[$i]/level-gal_us", 0);
36 print "tank $i empty\n";
48 &send("get " . shift);
49 eof $fgfs and die "\nconnection closed by host";
52 /^-ERR (.*)/ and die "\nfgfs error: $1\n";
61 &send("set $prop $value");
67 print $fgfs shift, "\015\012";
75 my $timeout = (shift || 120);
80 if ($socket = IO::Socket::INET->new(
85 $socket->autoflush(1);
96 # vi:ts=8:sw=8:noet:nowrap:cindent