Command line interface to BT747 implemented

  • Mario De Weerd

    Mario De Weerd - 2008-09-30

    I've implemented a command line interface to BT747 inspired on the mtkbabel command line interface.

    It is currently available in the debug releases (V1.57.6).

    The BT747 command line interface allows converting 'csv' to 'gmap' too (and other conversions).

    I implemented the 'batch' file to do this on windows.  For other systems, you should take the 'j2se' startup file and change the classpath slightly + change the call to java & add the command line parameters in the call.  If you did so and it works, post the script here or send it to me by email.

    Example of usage on windows:

    BT747cmd.bat -p COM4 -l on -d0 -t -w -r 0:0:10 -a -o-VALID_ONLY,RCR -outtype GMAP

    Connects to serial port COM4, activates logging, no debug information (currently there is some that I'll deactivate later), get a gpx track file, a gpx way point file, set time logging to 0, speed logging to 0 and distance logging to 10, download the log from the device, disable the 'VALID_ONLY' field and activate the RCR field (keeping the other fields as they are) and also converting the downloaded log to a Google Maps HTML file.

    The help text as returned by the application is this:

    Option                                  Description                           
    ------                                  -----------                           
    -E                                      Erase data log memory                 
    -R                                      Recover from disabled log: erase data 
                                              and reset recording criteria        
    --UTC <Integer: UTCoffset>              Define UTC offset to apply to output  
    -a                                      Read all the log memory (overlapped   
    -b <File: filename.bin>                 Do not read device, read a previously 
                                              saved file.The file type is selected
                                              according to the filename extension.
                                              Recognized file extensions are .csv,
                                              .trl,.nmea, .nme, .nma, .txt, .log, .
                                              sr .                                
    -d <Integer: DEBUG_LEVEL>               Debug level: 0..2                     
    -f <File: filename>                     Base name for saved files (.bin and   
    -h                                      Displays help                         
    -l <(on|off)>                           Turn logging ON/OFF                   
    -m <(stop|overlap)>                     Set STOP/OVERLAP recording method on  
                                              memory full                         
    -o <log_format>                         Enable or disable log fields (FIELD1,-
                                              FIELD2,...), available fields: UTC, 
    --outtype <OUTPUTTYPE>                  Create a gpx file of type GPX, GMAP,  
                                              KML, CSV, PLT, TRK                  
    -p <port>                               Communication port, default:          
    -r <Integer: time:distance:speed>       Set logging criteria (zero to disable)
    -s <Integer: speed>                     Serial port speed, default 115200 baud
    -t                                      Create a gpx file with tracks         
    -v                                      Print BT747 version and exit          
    -w                                      Create a gpx file with waypoints      

    • Mario De Weerd

      Mario De Weerd - 2008-10-20

      Either everything works well or this command line interface is unused - I have very little feedback.

      • Joern Weber

        Joern Weber - 2008-10-21

        Hello Mario,

        i don't use it, the i have not time and brain space to learn it. Or in other words, i to indolent for it. The current generation of young people think, the command line interface is a feature only for programmers. In reality, the command line interface is a nice feature for few freaks.

        greetings Joern Weber

        • Mario De Weerd

          Mario De Weerd - 2008-10-21

          Hi Joern

          Thanks for your feedback - I was looking to hear from those that requested a command line interface in the past (I got a few) and those that claim on their website that they prefer 'gpsbabel' because it has a command line interface.

          Kind regards


    • Fernando Herrero Peletero

      I'm interesting in this feature... perhaps because I am a programmer ;D

      I have not been able to test for lack of time (work and family).

      For me the most important thing is to be able to download the log automatically via a script to let me binary data in a folder / file specific.

      Gpsbabel can download binary log, but always generates another target (csv, kml ...) and does not specify the name of the binary file.

      Thanks Mario


    • Fernando Herrero Peletero

      I'm testing the following command:

      BT747_1.60.6_es>BT747cmd.bat -a -f 20081026.bin -p COM3

      but BT747_log.bin is created!

      • Mario De Weerd

        Mario De Weerd - 2008-10-26


        You are right.  That is a side effect of -b and -f referring to the same thing and hence an implementation error.  Corrected in 1.60.8.

        You should not specify the '.bin' however as '-f' defines the 'basename'.

        Give 'run_j2se.bat' a try too - the Desktop interface is close to a release.

    • Fernando Herrero Peletero

      I test to modify in line 786 from:

      if (options.has(OPT_DOWNLOAD) && !(options.has(OPT_BINARY_FILE))) {


      if (options.has(OPT_DOWNLOAD)) {

      Example of usage on windows:

      BT747cmd.bat -p COM3 -a -b e:\gps\20090108.bin -f e:\gps\gpsdata --outtype KML

      -b => Raw binary log (same as j2se option)
      -f => Output directory + Output file prefix (same as j2se options)

      The rest of options are unchanged.

      • Mario De Weerd

        Mario De Weerd - 2009-01-09

        This change (and an extra one related to tthis) has been implemented in Version 1.67.1.

        Further, it is also possible with Version 1.67.1 to geotag JPG files.  They can be added as extra parameters on the command line.
        By default, the UTC offset (-UTC) will also be used for the files but you can specify the offset with another parameter "-tz".  Accepted formats for "-tz" are "01:03" (hours:minutes) and "03:05:06" (hours:minutes:seconds).  It is possible to add a sign in front of this
        I gues I need to change the sign interpretation to apply only to the hours and not to the minutes and seconds.

    • Yuval Kantor

      Yuval Kantor - 2009-04-01

      Hello Mario,

      I have started using the command line interface and it seems very promising; I would like to implement something running in the background, waiting for a GPS device to be connected. Once a GPS connection is identified, I want it to download the data and run some analysis on the data.

      One thing I still haven't managed to do is to make BT747 identify the port automatically.

      When I type "BT747cmd.bat -l on" I get the following error message:
      281 -
      Listing known ports:
      390 - SER  :COM1
      390 - SER  :COM3
      390 - PAR  :LPT1

      I am sure I am missing something, since I managed to connect to USB (I am using WinXP) using the graphical application.

      Thanks a lot,


      • Mario De Weerd

        Mario De Weerd - 2009-04-01

        The best thing to do is to specify the port name:
        BT747cmd -p COM3 -l on

        for example.

        I think the default is COM4 and would be surprise that the graphical application connects to another port.  The automatic search works essentially on *nix or Mac.

    • Gareth

      Gareth - 2009-08-21

      I think one of the posts wanted confirmation that the command line worked from linux? It does! This is version 1.68.25
      Are there any return values set by the jar on success/failure?
      Here are a couple of scripts. I have the script scanit called once per minute from cron. This performs a check to make sure it isn't already running, then if not.
      It creates a new 'base' name: Todays date plus a number
      It checks to see whether the qstarz Q1000P datalogger is within range. If so, and it has just come into range (i.e. last check was out of range), it creates a bluetooth link.
      It then downloads the current data over the bluetooth link. Then converts the data to a GPX file, todays date, with each track dated after that.
      If successful, it erases the logger.
      It then sets the logger back to record, and closes the bluetooth link.
      The aim of this is for use on a boat. The logger will log whilst the boat is in motion, and if taken off the boat, will log the track taken. Then, once back onto the boat, it will be automatically downloaded and erased ready for more logging.

      cd ~gareth
      scanitrunning=`ps -ef |grep -c \[s\]canit`

      if [ "$scanitrunning" -lt 4 ]
      found=`hcitool scan |grep iBT-GPS`

      if [ "x$found" != "x" ]
      if [ -a "/tmp/searchdone" ]
      #echo "Already downloaded"
      touch /tmp/searchdone
      #echo "Device available"
      bash rfcomm-cmd &
      sleep 2
      bash bt747-cmd
      rfcomm release /dev/rfcomm1
      #echo "Hardware missing"
      rm  -f /tmp/searchdone
      echo "Scanit running"
      echo -n
      echo $scanitrunning
      ps -ef |grep \[s\]canit

      rfcomm connect rfcomm1 00:1C:88:10:DB:40

      cd ~gareth/bt747/
      mbase="`date +%Y_%m_%d`"
      while [ -a GPS-$base.bin ]; do let count=$count+1;base=$mbase-$count; done
      success=`./ -p /dev/rfcomm1 -f GPS-$base --download-method SMART -a 2>&1 `
      osuccess=`echo $success |grep SUCCESS`
      if [ "x$osuccess" != "x" ]
      success=`./ -b GPS-$base.bin --outtype gpx -f GPS-$base --splittype day --UTC -7 2>&1 `
      osuccess=`echo $success |grep "Conversion done"`
      if [ "x$osuccess" != "x" ]
      ./ -p /dev/rfcomm1 -E
      echo "Error occurred converting data to gpx"
      echo $success
      echo "Error occurred Downloading data"
      echo $success
      ./ -p /dev/rfcomm1 -l on


Log in to post a comment.