Trimble Inc. 10950 Benutzerhandbuch
Alloy GNSS reference receiver User Guide
115
Using Perl
Perl is a powerful scripting language. The language comes with numerous library packages which
allow it to be used to automate many complex tasks. It is also available on most operating systems,
which makes it good for cross-platform applications.
allow it to be used to automate many complex tasks. It is also available on most operating systems,
which makes it good for cross-platform applications.
Perl can easily be used to control a GNSS Receiver using the Programmatic Interface commands. A
simple method uses LWP - a Library for WWW access in Perl. On Linux, use man LWP for overview
documentation. This is a powerful and complex package, which cannot be documented here. Some
sample programs show the basic techniques needed. The first shows how to encode basic URL
requests:
simple method uses LWP - a Library for WWW access in Perl. On Linux, use man LWP for overview
documentation. This is a powerful and complex package, which cannot be documented here. Some
sample programs show the basic techniques needed. The first shows how to encode basic URL
requests:
#!/usr/bin/perl -w
use strict;
use LWP::Simple;
use strict;
use LWP::Simple;
print get( "http://fbtc/prog/show?systemname" ) ;
print get( "http://fbtc/prog/show?gpstime" ) ;
print get( "http://fbtc/prog/badCommand?abc" ) ;
print get( "http://fbtc/prog/set?elevationMask&mask=10" ) ;
print get( "http://fbtc/prog/show?position" ) ;
print get( "http://fbtc/prog/show?gpstime" ) ;
print get( "http://fbtc/prog/badCommand?abc" ) ;
print get( "http://fbtc/prog/set?elevationMask&mask=10" ) ;
print get( "http://fbtc/prog/show?position" ) ;
Running that program produces the following output:
SystemName name=NewName
GpsTime gpsweek=1244 weekseconds=498371
ERROR: Invalid verb 'badCommand'
OK: ElevationMask mask=10
<Show Position>
GpsWeek 1244
WeekSeconds 498373.2
Latitude 37.3891241306 deg
Longitude -122.0368464236 deg
Altitude -4.078 meters
....
<end of Show Position>
GpsTime gpsweek=1244 weekseconds=498371
ERROR: Invalid verb 'badCommand'
OK: ElevationMask mask=10
<Show Position>
GpsWeek 1244
WeekSeconds 498373.2
Latitude 37.3891241306 deg
Longitude -122.0368464236 deg
Altitude -4.078 meters
....
<end of Show Position>
File Downloads are a bit more complex than just redirecting a get() request to a file, mainly due to
the fact that the files can be arbitrarily large. A more complex syntax allows Perl to download and
put the results directly into a file.
the fact that the files can be arbitrarily large. A more complex syntax allows Perl to download and
put the results directly into a file.
#!/usr/bin/perl -w
use LWP::UserAgent;
my $f = '60350239BF200906181935.T01' ;
my $path = '/Internal' ;
my $path = '/Internal' ;
my $ua = LWP::UserAgent->new ;
my $req = HTTP::Request->new(GET=>
"http://Alloy/prog/download?file&path=$path/$f" ) ;
my $res = $ua->request( $req, $f ) ;
When this is run, the logged file on the GNSS Receiver is copied to an identically named file in the
local computer. Note that no text comes to standard output.
local computer. Note that no text comes to standard output.