logdev is a .cnf file configurable logger instrument, similar to serdev
in that it allows new logger instruments to be added to the glider without
writing new binary drivers/modifying source code. Available .cnf file 
parameters are:

name=               * name of instrument that appears in configuration menus
                      example: name=LAB
prefix=             * two character prefix for creating data files
                      example: prefix=la leads to data files named la0001az.x
timeout=            * timeout (millieconds) to use when waiting for a response
powerup-timeout=    - timeout to use when waiting for prompt after power-up
                      0 means no wait
baud=               * baud rate for serial communications
warmup=             * warmup (milliseconds) between power up and spot sample
voltage=            * voltage (10 or 24) to charge power usage 
current=            * current (A) draw when powered on
cmdprefix=          * cmdfile parameter prefix, four characters $xx_
                      example: cmdprefix=$LA_
prompt=             - prompt to wait for before issuing serial commands
                      example: prompt=>
datatype=           - should be z or u for gzipped or uncompressed data
wakeup=             - sequence to send when power is on to get a prompt
                      example: wakeup=%b%r
sample=             - command to acquire and report a single sample
                      example: sample=sample%r
dive-start          - commmand to send at dive start (to reset or clean memory
                      for example)
start=              - command to start continuous sampling and logging
                      example: start="start %f compress%r" 
stop=               - command to stop sampling and logging
                      example: stop=stop%r
status=             - command to pass status info from glider to logger
                      at each sample interval
                      example: ctd=%C,%T,%D%r%[OK]
                      The response from the logger (anything captured while 
                      waiting for strings in []) will be parsed and can
                      be used to change glider heading if the string
                      heading=NUMBER is found in the response. 
xmodem=             - command to download a file via xmodem
                      example: xmodem="xs %f %m%r"  
download=           - command to download an ASCII file via serial dump
                      example: download="cat %f%r"
profiles-download=  - choose one of separate, dive, climb, merged
metadata=           - command to issue before downloading file. Any captured
                      output (with %[]) is copied to head of datafile.
cleanup=            - command to clear storage memory at mission launch
                      example: cleanup="del la*.x%r"
ct-cmd=             - command to read CT real-time CT data
                      example: %r%p%F%9S%9L%9%r%[%r%nS>]
ct-resp=            - specifies how to parse the response returned in 
                      %[] from ct-cmd according to the serdev parser
                      channel 0 = C freq, 1 = T freq, 2 = C, 3 = T, 4 = S
                      example: %f,%03,%02,%f
clock-read=         - command to read the clock
                      example: clock-read=clock%r
clock-set=          - command to set the clock, interpreted using strftime
                      example: clock-set="clock %{%m/%d/%Y %H:%M:%S%}%r" 
post-clock=         - power management policy for device power post clock
                      sync. Must be one of "on", "off", or "sleep".
                      Default is off.
clock-sync=         - comma separated list of points at which the clock-set
                      command is sent. Choices are gps1 (after GPS1 fix), 
                      gps2 (after GPS2 fix), and start (before every start
                      command).
                      Default is gps2
post-stop=          - power policy post stopping sampling: on, off, sleep
post-transfer=      - power policy post file transfer: on, off, sleep
sleep=              - sleep command sent when power policy requests it
selftest=           - command to send during pre-launch selftest
script-x=           - name of script file, the contents of which are command
                      strings (one per line) sent with %X (below). If defined 
                      a file with this name will be downloaded from the 
                      basestation at every call (if it exists). 
                      Default is none.
script-y=           - name of script file sent with %Y (below)
script-z=           - name of script file sent with %Z (below)
param-x=            - name of cmdfile parameter, value for which is sent when
                      expanding %x
param-y=            - see param-x and %y below
param-z=            - see param-x and %z below
log-cmd=            - command to send to collect post-dive log results.
                      Results will be reported in the log file as a string
                      using the parameter name given by log-0 (below) unless
                      a log-resp value is also given.
log-resp=           - specifies how the results from the log-cmd should
                      be parsed to break out up to 3 floating point 
                      pseudo-parameters to be reported in the log file 
                      as log-0, log-1, and log-2. The string captured
                      by %[] when log-cmd is issued is passed to the
                      serdev line parser with the string defined by
                      log-resp as the format. %00, %01 and %02 in that
                      format represent values to be parsed out and
                      reported according the to the log-0, -1, and -2
                      name values below.
log-0=              - name of pseudo-parameter to report in log file
log-1=              
log-2=

Parameters marked with a * are required in every logdev .cnf file. 
Command strings with spaces in them should be enclosed in quotes as
in the examples for cleanup, xmodem, etc. above.  Command strings 
(wakeup, sample, start, stop, xmodem, download, cleanup, clock-read, and
log-cmd) are intepreted before transmission according to the 
following rules:

%1 ... %9 = DelayMilliSecs(10) .. DelayMilliSecs(90)
%b = break
%r = CR (13)
%n = NL (10)
%e = esc (27)
%$xx = send hex byte xx - must include both characters (00 - ff)
%p = wait for prompt (up to timeout ms)
%k = send wakeup sequence
%[] = wait for an arbitrary sequence of characters. Characters between the 
      brackets can include any ASCII character. To wait for % use %%. To wait 
      for ] use %]. Use %r and %n to wait for CR and NL, respectively.
      Use %$xx to wait for an arbitrary hex byte. Several commands use the
      string gathered while waiting for the final %[] sequence as a string result
      to be parsed (metadata, log-cmd, and ct-cmd for example) or printed.   
%() = value of glider parameter. %($C_VBD) substitutes the values of
      $C_VBD for example.
%% = %
%i = turn power on - typically only use this and %o to power cycle as
     the driver automatically handles turning power on and off for normal
     operations
%o = turn power off
%g = glider ID (%03d)
%d = dive number (%04d)
%f = glider's local filename string without extension (example tm0001az)
%h = glider's current magnetic heading
%m = upload max size (%ld), interpretation varies (bytes, lines, samples)
%s = sequential start number (as %d int)
%c = cast number (%d) - will always expand to 1 or 2. This is the sequential
     start number within a single dive cycle.
%a = profile indicator letter ('a' for dive, 'b' for climb) - useful for 
     constructing filenames to match glider local names, e.g., 
     %f can also be written as xy%d%au.x (assuming prefix is xy and
     datatype is u).
%F = flush the input buffer
%T = temperature (deg C)
%D = depth (m)
%H = glider's target magnetic heading
%V = soundspeed (m/s)
%W = vertical velocity (m/s)
%t = seconds into dive(s)
%h = current heading
%H = desired heading
%G = gcphase + gcflags
%l = estimated lat and lon
%<> = interpret characters inside <> as strftime string
%X = send commands in script-x
%Y = send commands in script-y
%Z = send commands in script-z
%w = send value of parameter defined by param-w
%x = send value of parameter defined by param-x
%y = send value of parameter defined by param-y
%z = send value of parameter defined by param-z

Lines in script files (x, y, and z) are fully interpreted. The script 
mechanism is intended to allow complex, multi-command interactions or to 
provide a pilot control of a device during a mission. For example a start 
command might become:

start=%X
script-x=device.bat

where the contents of device.bat are:

%r%pvalue1=17.0%r
%pvalue2=0.05%r
%pstart%r

The pilot could change the values of the parameters value1 and value2 
by creating a new file device.bat on the basestation.  That file will
be transferred to the glider CF card during a call and the logdev driver
will send the commands changing those values the next time it issues a 
start command.

The log-cmd and log-resp values are provided to allow a logdev device to
report diagnostic/engineering values to be included in the glider log 
file. For example

cmdprefix=$AA_
prompt=>
log-cmd=free%r%[%n]%p
log-resp="Directory free space %00 bytes, %01 files"
log-0=FREE
log-1=FILES

will cause the driver to isse the free command (followed by CR) and then
capture all output up to a newline and then wait for a prompt to return
to make sure the command is completed. The captured string is then 
scanned according to the format string in log-resp, with values parsed
out for free space and file count. Those values are then reported in the
log file as pseudo-parameters $AA_FREE and $AA_FILES. If no log-resp
had been provided then the the single entry in the log file would be

$AA_FREEE,Directory free space 12345 bytes, 123 files

All logdev devices recognize four cmdfile parameters: 

$xx_RECORDABOVE     - depth above which the logger is run. A negative value
                      indicates that the logger should be run BELOW this 
                      depth (i.e., -200 means run logger below 200 m,
                      200 means run logger above 200 m). A value of 0
                      means never record.
$xx_PROFILE         - which half of the profile to run the logger 0=none,
                      1=dive, 2=climb, 3=both
$xx_XMITPROFILE     - which half of the profile to transmit data back via
                      Iridium 0=none, 1=dive, 2=climb, 3=both
$xx_UPLOADMAX       - size limit on uploaded files. The device itself
                      must honor this when the glider requests the file
                      via the command specified via xmodem= or download=.
                      Will be passed as the %m in interpolated command
          
$xx_STARTS          - this is a pseudo-parameter maintained by the driver
                      to persist the number of times the device has been
                      started (to create unique filenames for example).
                      It should not be changed manually.

The $xx_ prefix is defined by the cmdprefix in the .cnf file as described
above. Additional parameters can be defined using param-x=, param-y=
and param-z=. For example specifying param-x=RATE and specifying $xx_RATE,1.2
in the cmdfile will cause the interpreter to expand %x in a command string
to the value 1.2. 

The glider communicates with a logdev at a series of action points throughout
the operating cycle. Actions and their associated message number are

    logger_OFF,             // 1    : turns power off
    logger_DIVE_START,      // 2    : send dive-start, check start conditions
    logger_APOGEE_REACHED,  // 3    : send stop
    logger_DIVE_FINISHED,   // 4    : send stop    
    logger_SYNC_CLOCK,      // 5    : sync clock after GPS1 if requested
    logger_SYNC_PPS,        // 6    : sync clock after GPS1 if requested
    logger_SYNC_2_CLOCK,    // 7    : sync clock after GPS2 if requested
    logger_SYNC_2_PPS,      // 8    : sync clock after GPS2 if requested
    logger_XMIT_READY,      // 9    : sent before call to get files from logdev
    logger_XMIT_COMPLETE,   // 10   : sent after call to send files to logdev
    logger_RECOVERY,        // 11   : no op
    logger_PREDIVELOG,      // 12   : no op
    logger_POSTDIVELOG,     // 13   : send log-cmd
    logger_BOOT,            // 14   : no op
    logger_LAUNCH,          // 15   : send cleanup
    logger_SELFTEST,        // 16   : send selftest
    logger_PRE_SELFTEST,    // 17   : no op
    logger_SAMPLE_DEPTH,    // 18   : no op
    logger_SAMPLE_STATUS,   // 19   : send status, send ct-cmd, check depths to start or stop
    logger_DIAGNOSE_POWER,  // 20   : no op
    logger_SEALEVEL,        // 21   : no op
    logger_MOTORS_ON,       // 22   : no op
    logger_MOTORS_OFF,      // 23   : no op
    logger_SURFACE,         // 24   : no op

The menu item selftest sends a series of actions to simulate the state machine:
DIVE_START, 10x SAMPLE_STATUS, APOGEE_REACHED, 10x SAMPLE_STATUS, DIVE_FINISHED,
XMIT_READY. 

Menu item action can be used to simulate any single action message being passed
to the device. An action=NUMBER argument is required. 

For debugging, the edit menu item can be helpful to change the value of cnf
parameters during testing without needing to upload or edit an entirely new
cnf file. Specify the parameter and new value as an argument, e.g., 

    edit start="start%r%n"

These changes are not persisted so eventually you do need to put the final 
values into the cnf file. vi is available on the glider via pdos, from the
menu for example
    
    !vi mydev.cnf

Arbitrary commands can be sent to the device from the menu using the command
menu item:

    command string="ls%r%[#]" string="ls -a%r%[#]"

for example sends ls and ls -a commnads, waiting in each case for the # prompt
before sending the next command and ending the interaction.