Home PageFacebookRSS News Feed
PocketGPS
Web
Read the current newsletter! Weekly
Newsletter
SatNav,GPS,Navigation
Get Speed Camera Warnings For SatNavs Get Speed Camera Warnings For Android Get Speed Camera Warnings For iPhone
Publishing real time TomTom journey information on the internet 19 October 2006

Review by user Richard Thomas

 

Introduction

 

EDITOR'S NOTE:Vehicle tracking is a hot topic nowadays. Most of the solutions are pretty expensive, yet do not exactly deliver the functionality that you as an individual need from them. With some sort of scripting language, the TomTom communications API and a Internet connection you could create your own individual solution, at a fraction of the cost.

 

That's exacly what PocketGPSWorld user Richard Thomas did on his TomTom equipped PDA, and he was kind enough to share the details of his project with the PocketGPSWorld community. So, without much further ado, here he comes:

 

"I was on the way home one evening and it was a journey where TomTom received a traffic problem and then another traffic problem and another and another.  This kept on adding more and more time to my journey, so each time my journey time went up, I stop to text my wife to let her know I would be later and later, which all takes time.

 

Now, as I have TomTom installed on my Pocket PC PDA and that it links to my mobile phone via Bluetooth to get GPRS internet access which it uses to get traffic information, I started to have an idea.  Being alone in a car for hours seems to be a Great Thinking Opportunity.

 

The idea was that if I could somehow write a program that could interrogate TomTom to find out what the remaining journey time is, it could then display this information in the internet, as the PDA already has internet access through my mobile phone.

 

After a number of postings to the PocketGPSWorld forum and with the help of the PocketGPSWorld team, I have achieved this and I am really pleased with it.  The great thing is that it was very cheap to do as well.

 

I use a Pocket PC scheduler called SKSchema to kick off my PERL code. It detects if TomTom is running and then asks the TomTom engine for the current route details. The remaining journey time information is then sent to a place on the internet.  If you want to see how I did this and what you need for that, please read on.

 

Installing and configuring PERL to run on the PDA

 

PERL has been ported and compiled for WinCE devices (Windows Pocket PC PDA’s).

I followed the instructions detailed in http://perlce.sourceforge.net/#obtaining to download and install the pre-complied PERL binary for my PDA.

 

Having installed PERL onto the PDA, a few environment variables need to be set on it.  I used cereg that runs on a Windows PC that has a current ActiveSync connection to the PDA.  Cereg can be obtained from http://www.rainer-keuchel.de/wince/wince-desktop-tools.tar.gz (EDITOR'S NOTE: You can of course also use any of the standard registry editors and do the changes manually).

 

Once you have installed cereg, it needs to be run with a number of parameters in order to make the required registry settings.

 

I wrote a .bat file that calls cereg a number of times to make the registry settings.  It’s shown below and is what I used on my HP iPAQ 2210, I chose to install PERL on my SD card, with the path being \SD Card\PDA\perl58m. Your mileage may vary.

 

set perlpath=\SD Card\PDA\perl58m
set perlexe=%perlpath%\bin\perl.exe
set perllib=%perlpath%\lib

::- PERL5LIB
cereg -k "HKLM\Environment" -n "PERL5LIB" -v "%perllib%"

::- For ShellExecute
cereg -k "HKCR\.pl" -n "" -v "perlfile"
cereg -k "HKCR\perlfile" -n "" -v "Perl Script"
cereg -k "HKCR\perlfile\DefaultIcon" -n "" -v "%perlexe%,-1"
cereg -k "HKCR\perlfile\Shell\open\command" -n "" -v """"%perlexe%""" ""%%1"""

::- Misc
REM Height of 10 is ok, 14 does almost full screen
cereg -k "HKLM\Environment" -n "ROWS" -v "14"
REM MAX Width for PPC is 29 Chars
cereg -k "HKLM\Environment" -n "COLS" -v "29"
cereg -k "HKLM\Environment" -n "PATH" -v "%perlpath%\bin"
cereg -k "HKLM\Environment" -n "UNIXROOTDIR" -v "%perlpath%\unix"

 

 

Finally, I had to make a few tweaks to the FTP module files to get it to work on the PDA and produce some logging as below:

 

In Lib\Net\FTP.pm

 

Changed:

use vars qw($TELNET_IAC $TELNET_IP $TELNET_DM);
($TELNET_IAC,$TELNET_IP,$TELNET_DM) = (255,244,242);

# Name is too long for AutoLoad, it clashes with pasv_xfer
sub pasv_xfer_unique {
    my($sftp,$sfile,$dftp,$dfile) = @_;
    $sftp->pasv_xfer($sfile,$dftp,$dfile,1);
}

 

To:

use vars qw($TELNET_IAC $TELNET_IP $TELNET_DM);
($TELNET_IAC,$TELNET_IP,$TELNET_DM) = (255,244,242);

 

# RDTRDT [BEGIN]
my $logname;
my $srcpath="\\SD Card\\PDA\\perl58m\\scripts";
my $message;

sub getyear{
  # Get number of years since 1900

  my $OFFSET=sprintf("%d",@_);
 
  my $YEAR=(localtime(time+$OFFSET))[5];
 
  # Subtract 100 to turn into yy format
  $YEAR=$YEAR-100;

  # Return year
  $YEAR
} # getyear

 

sub getmonth{
  # Get month as zero based (0 is January)

  my $OFFSET=sprintf("%d",@_);

  my $MONTH=(localtime(time+$OFFSET))[4];
 
  # Add 1 to turn into 'normal' month numbering
  $MONTH=$MONTH+1;

  # Return month
  $MONTH
} # getmonth

 

sub getday{
  # Get day of month (1 is 1st of month)

  my $OFFSET=sprintf("%d",@_);

  my $DAY=(localtime(time+$OFFSET))[3];
 
  # Return day
  $DAY
} # getday

 

sub construct_logname{
  # Contruct filename based on date and type of product that is piping debug
  # to us

  $logname=sprintf("%s\\%02d%02d%02d.tomlog.txt",
                   $srcpath,getyear(0),getmonth(0),getday(0));
} # construct_filename

 

sub log_list{
  # Log the contents of the list that is passed to us

  my @page=@_;

  my $datetime;
  my $line;

  # Open the log file for appending
  open(LOGFILE,">>$logname");
  printf(LOGFILE"Last Update: ");

  $datetime=localtime();
  printf(LOGFILE"%s\n",$datetime);

  foreach $line (@page){
    printf(LOGFILE"%s\n",$line);
    printf("%s\n",$line);
  }

  close(LOGFILE);

} # log_list

# RDTRDT [END]

 

# Name is too long for AutoLoad, it clashes with pasv_xfer
sub pasv_xfer_unique {
    my($sftp,$sfile,$dftp,$dfile) = @_;
    $sftp->pasv_xfer($sfile,$dftp,$dfile,1);
}

 


In Lib\Net\Cmd.pm

 

Commented out all 4 occurrences of the following line:

local $SIG{PIPE} = 'IGNORE' unless $^O eq 'MacOS';

 

In Lib\Net\FTP\A.pm

 

Commented out the 1 occurrenc of the following line:

local $SIG{PIPE} = 'IGNORE' unless $^O eq 'MacOS';

 

The PERL Script itself

 

The script goes into a while(1) loop and the first thing it does inside the loop is to sleep for 10 minutes.  This gives TomTom time to calculate the route, traffic information to be downloaded and recalculate the route, so that the remaining time is accurate.  Each step the script does is listed below

  • Erases the SDK API files that are used to communicate with TomTom.
  • Copies files that have special names and special content to ask TomTom for information about the journey time.  These are the SDK API call files. Here is the hex dump for the SDK.TomTomNavigationServer.1050229.1.message file (1050229 is an arbitrary number)
  • Reads a file that also has a special name with special content that TomTom produced as a result of asking for the journey time.  This is the SDK API result file, in our case TomTomNavigationServer.SDK.1050229.1.message - see how sender and recipient have swapped in the file name.

  • Extracts the estimated remaining journey time from the SDK API result file
  • Creates a small text file to show the estimated remaining journey in a human readable format.

Last Update: Sat Oct 7 20:42:12 2006
Journey time left is 0 hours and 23 minutes

  • Makes an FTP connection to put the text file on an internet visible server.
  • Goes to the top of the loop, where it sleeps for 10 minutes before it asks TomTom for the updated estimated remaining journey time.

 

The Pocket PC scheduler

 

I found this great scheduler for the pocket PC that can be made to launch a program when it detects an application starting, so it’s set up to launch my PERL script when it detects that TomTom has started.

 

It’s called SKSchema, it’s available at http://s-k-tools.com/skschema/ and the full version costs US$9.00 (as of 5th August 2006).

 

Once you have installed SKSchema, you can set up "Watch" to watch for TomTom to start and launch the script.  To do this, go to Tools->Watch->New and apply the following settings:

 

 

Setting

Value

Watch for

Windows

Window title

TomTom

To execute If the Window is Opened
E.G.

<path to PERL executable>\perl.exe
\SD Card\PDA\perl58m\bin\perl.exe

With parameters
E.G.

"<path to perl script>\tomtom_prog.pl" --noconsole
"\SD Card\PDA\perl58m\scripts\tomtom_prog.pl" --noconsole

 

 

I had a slight issue using this in conjunction with iPAQ backup, as I had it set up to automatically make a backup of my PDA to SD card every night.  The default way this behaves is to stop all processes before performing the backup.  SKSchema has a process that if stopped, caused the PDA to soft reset.  So I just configured iPAQ backup not to stop processes before performing the backup and this workaround was fine.

 

Summary

 

I have been using this solution for a number of journeys now and was surprised how well it has worked, I’m very pleased with it.

 

The PERL script could be made to query and populate more information about the journey and it may also be possible to implement PERL and the scripts on the “All-in-one” navigation products, as they are units that run Linux and can be manipulated (EDITOR'S NOTE: Linux shell scripts can achieve the same goal, no need to install Perl on a PND. The unique value of the present article is to show that shell scripting can be done on a PDA too).

 

If anybody has any queries about this, then feel free to email me rich_d_thomas@bigfoot.com . Please put “TomTom API” in the email subject.

 

 

References

Perl Website http://perlce.sourceforge.net/#obtaining
SkSchema Website http://s-k-tools.com/skschema/
Pocket GPS Contributor Richard Thomas
Pocket GPS Editor Lutz Bendlin
   

 

Comments ?

Have any comments about this review ? Post them here.

CamerAlert Apps



iOS QR Code






Android QR Code







Terms & Privacy

GPS Shopping