# HG changeset patch # User A.M. Thurnherr # Date 1284485679 14400 # Node ID fda11de1826e18f06ea755c931426be396533d68 # Parent 99a41e0476b16b94bff2194e429dcebd30970188 version left on Poseidon at end of P403 diff -r 99a41e0476b1 -r fda11de1826e CRUISE_SETUP.expect --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/CRUISE_SETUP.expect Tue Sep 14 13:34:39 2010 -0400 @@ -0,0 +1,208 @@ +#====================================================================== +# C R U I S E _ S E T U P . E X P E C T +# doc: Wed Mar 10 21:14:18 2004 +# dlm: Thu Aug 26 19:49:03 2010 +# (c) 2004 A.M. Thurnherr +# uE-Info: 118 24 NIL 0 0 72 2 2 8 NIL ofnI +#====================================================================== + +#-------- +# HISTORY +#-------- + +# Mar 10, 2004: - created during NBP0402 +# Apr 4, 2004: - final version NBP0402 +# Jun 15, 2004: - adapted to BB150/Workhorse setup +# Jun 16, 2004: - ditto +# Jun 19, 2004: - BUG: could not handle multiple BB150 data files +# Jan 19, 2006: - updated documentation +# - allowed for empty-string time_server +# Nov 4, 2006: - changed backup dir structure +# Aug 25, 2010: - rename* funs modified to allow them to be used to +# that downladed file names have correct case +# - renamed from DEFAULTS.expect to CRUISE_SETUP.expect +# Aug 26, 2010: - added ymodem_receive_cmd +# - changed default string quotes to {} to prevent Tcl variable +# and command substitutions + +#----------- +# TWEAKABLES +#----------- + +# At the beginning of each cast, the clock of the acquisition computer should +# synchronized with the master clock used for timestamping the GPS information. +# The easiest way to accomplish this is by probing an NTP server on the ship +# (if there is one), which can be defined by setting the following variable. +# If there is no such server available, the variable should be set to the +# empty string (set time_server {}), in which case clock synchronization must +# be done differently (e.g. manually). + +set time_server {199.92.161.2}; + +# bbabble needs to know the tty device name(s) of the serial connection(s) +# to the ADCP head(s). If only one head is connected, tty1 is ignored. +# If two heads are connected, the device names are exchangeable, i.e. +# either instrument can be connected to either port. + +set tty0 {/dev/ttyS0}; +set tty1 {/dev/ttyS1}; + +# In case of 2 ADCP heads, babble needs to know which is the master and +# which is the slave. This is accomplished by setting the following variables +# to the corresponding instrument serial numbers (PS0 output). By convention, +# the downlooker is the master. If only a single head is connected, both +# variables are ignored. + +set master_sn 7877; +set slave_sn 1412; + +# Before deployment, every ADCP head has to be programmed by sending it +# a corresponding command file, defined by the following variables. If only +# a single head is connected, the slave_* variable is ignored. + +set master_cmd_file {MASTER.cmd}; +set slave_cmd_file {SLAVE.cmd}; + +# For convenience, it is best to use the station number to name the ADCP data +# files, and to indicate whether the data file comes from the master or +# slave. The following variables variables define the printf(3) format +# that is used to create the files names from the station number. If only +# a single head is connected, the slave_* variable is ignored. +# NOTE: Some implementations of the ymodem protocol (notably lrb running +# under Mandrake 8) use lowercase for the downloaded file. It is +# therefore better to use only lowercase characters in the deployment +# names. + +set master_deployment_name_fmt {%03ddn}; +set slave_deployment_name_fmt {%03dup}; + +# Older RDI instruments (e.g. the BB150) do not allow the data-file name +# to be defined in the instrument, in which case the files have to be +# renamed after downloading. The following variables define the shell +# globbing patterns for the master and slave. For example, the UH BB150 +# used during CLIVAR P02 generated files with extension .612; the coresponding +# globbing pattern is {*.612}. If only a single head is connected, the +# slave_* variable is ignored. +# NB: For dual-headed LADCP systems it is important that the globs do not +# match both master and slave data files. {*.000} therefore will not +# work for dual-head Workhorse systems. + +set master_download_glob {}; +set slave_download_glob {}; + +# For consistency it is nicest if low station numbers contain leading +# zeroes. The following variable defines the corresponding printf(3) format. + +set stn_format {%03d}; + +# The following directory is used to store command files, instrument +# configurations and ADCP data. Separate subdirectories (named according to +# stn_format) are used for each cast. + +set raw_dir {../data/raw}; + +# After downloading, the data directory is backed up to the following +# directory. Make sure that it resides on a different disk than raw_dir. +# Empty string disables backup for testing purposes. +# NOTE: RELATIVE PATHNAMES MUST START FROM CAST DIR (NOT ACQUISITION DIR) + +set backup_dir {../../backup/raw}; + +# By default, bbabble will look for standard UN*X ymodem receive +# programs (rb and lrb). If neither of these exist, if neither is in the +# current $PATH, or if options have to be passed (as is the case on some +# Linux distributions to ensure that the downloaded files have consistent +# (upper-)case filenames, the following variable can be set to a non-empty +# string, such as {rb -u} + +set ymodem_receive_cmd {} + +# bbabble can be made to abort downloading after a preset amount of time, +# defined by the following variable. + +set download_timeout 999999; + +#---------------------------------------------------------------------- +# Semi-Standard Functions +#---------------------------------------------------------------------- + +proc set_computer_time {} { # set computer clock + global time_server; + if {[string length $time_server] == 0} {return} + exec sudo rdate -s $time_server; +} + +proc check_data {file} { # check data file + exec sh -c "scanbb $file"; + exec sh -c "sed -n '/^zmax/,/^zend/s/ at.*/m/p' `basename $file .000`.scn > /dev/tty"; +} + +proc backup_master_data {stn} { # copy data to network + global master_deployment_name_fmt master_cmd_file backup_dir; + if {[string length $backup_dir] == 0} {return} + + if {![file isdirectory $backup_dir]} { + error "$backup_dir does not exist relative to [pwd]"; + } + + set master_dir [format $backup_dir/$master_deployment_name_fmt $stn]; + if {![file isdirectory $master_dir]} {exec mkdir $master_dir}; + exec sh -c "cp [format $master_deployment_name_fmt $stn]* $master_dir"; + exec sh -c "cp $master_cmd_file* $master_dir"; + exec sh -c "cp *log $master_dir"; +} + +proc backup_slave_data {stn} { # copy data to network + global slave_deployment_name_fmt slave_cmd_file backup_dir; + if {[string length $backup_dir] == 0} {return} + + if {![file isdirectory $backup_dir]} { + error "$backup_dir does not exist relative to [pwd]"; + } + + set slave_dir [format $backup_dir/$slave_deployment_name_fmt $stn]; + if {![file isdirectory $slave_dir]} {exec mkdir $slave_dir}; + exec sh -c "cp [format $slave_deployment_name_fmt $stn]* $slave_dir"; + exec sh -c "cp $slave_cmd_file* $slave_dir"; + exec sh -c "cp *log $slave_dir"; +} + +proc rename_master_download_file {target} { # rename after download + global master_download_glob; + + if {[string length $master_download_glob] == 0} {return} + set files [glob -nocomplain $master_download_glob]; + set nfiles [llength $files]; + if {$nfiles == 0} { + if {![file exists $target]} { + error {can't find downloaded master file}; + } + return; + } + if {$nfiles > 1} { + send_user {WARNING: Multiple files downloaded from master --- rename, backup, check manually!}; + } + if {![string equal [lindex $files end] $target]} { + exec mv [lindex $files end] $target; + } +} + +proc rename_slave_download_file {target} { # rename after download + global slave_download_glob; + + if {[string length $slave_download_glob] == 0} {return} + set files [glob -nocomplain $slave_download_glob]; + set nfiles [llength $files]; + if {$nfiles == 0} { + if {![file exists $target]} { + error {can't find downloaded slave file}; + } + return; + } + if {$nfiles > 1} { + send_user {WARNING: Multiple files downloaded from slave --- rename, backup, check manually!}; + } + if {![string equal [lindex $files end] $target]} { + exec mv [lindex $files end] $target; + } +} diff -r 99a41e0476b1 -r fda11de1826e DEFAULTS.expect --- a/DEFAULTS.expect Wed Jul 07 13:29:02 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,194 +0,0 @@ -#====================================================================== -# D E F A U L T S . E X P E C T -# doc: Wed Mar 10 21:14:18 2004 -# dlm: Sat Nov 4 04:19:14 2006 -# (c) 2004 A.M. Thurnherr -# uE-Info: 26 46 NIL 0 0 72 2 2 8 NIL ofnI -#====================================================================== - -#-------- -# HISTORY -#-------- - -# Mar 10, 2004: - created during NBP0402 -# Apr 4, 2004: - final version NBP0402 -# Jun 14, 2004: - copied for CLIVAR P02 -# Jun 15, 2004: - adapted to BB150/Workhorse setup -# Jun 16, 2004: - ditto -# Jun 19, 2004: - BUG: could not handle multiple BB150 data files -# Dec 20, 2004: - adapted for CLIVAR A16S -# Jan 19, 2006: - updated documentation -# - allowed for empty-string time_server -# Oct 3, 2006: - adapted for LADDER cruise -# Oct 28, 2006: - continued -# Nov 1, 2006: - change master/slave serial numbers after CTD4 -# (should have been done after CTD3, but I spaced; A.T.) -# Nov 4, 2006: - changed backup dir structure -# Nov 11,2006: - slave away as beam1 is broken (but did not work since -# CTD15 on Nov 16; F.T) - -#----------- -# TWEAKABLES -#----------- - -# At the beginning of each cast, the clock of the acquisition computer should -# synchronized with the master clock used for timestamping the GPS information. -# The easiest way to accomplish this is by probing an NTP server on the ship -# (if there is one), which can be defined by setting the following variable. -# If there is no such server available, the variable should be set to the -# empty string (set time_server ""), in which case clock synchronization must -# be done differently (e.g. manually). - -set time_server "199.92.161.2"; - -# bbabble needs to know the tty device name(s) of the serial connection(s) -# to the ADCP head(s). If only one head is connected, tty1 is ignored. -# If two heads are connected, the device names are exchangeable, i.e. -# either instrument can be connected to either port. - -set tty0 "/dev/ttyS0"; -set tty1 "/dev/ttyS1"; - -# In case of 2 ADCP heads, babble needs to know which is the master and -# which is the slave. This is accomplished by setting the following variables -# to the corresponding instrument serial numbers (PS0 output). By convention, -# the downlooker is the master. If only a single head is connected, both -# variables are ignored. - -set master_sn 7877; -set slave_sn 1412; - -# Before deployment, every ADCP head has to be programmed by sending it -# a corresponding command file, defined by the following variables. If only -# a single head is connected, the slave_* variable is ignored. - -set master_cmd_file "MASTER.cmd"; -set slave_cmd_file "SLAVE.cmd"; - -# For convenience, it is best to use the station number to name the ADCP data -# files, and to indicate whether the data file comes from the master or -# slave. The following variables variables define the printf(3) format -# that is used to create the files names from the station number. If only -# a single head is connected, the slave_* variable is ignored. -# NOTE: Some implementations of the ymodem protocol (notably lrb running -# under Mandrake 8) use lowercase for the downloaded file. It is -# therefore better to use only lowercase characters in the deployment -# names. - -set master_deployment_name_fmt "%03ddn"; -set slave_deployment_name_fmt "%03dup"; - -# Older RDI instruments (e.g. the BB150) do not allow the data-file name -# to be defined in the instrument, in which case the files have to be -# renamed after downloading. The following variables define the shell -# globbing patterns for the master and slave. For example, the UH BB150 -# used during CLIVAR P02 generated files with extension .612; the coresponding -# globbing pattern is "*.612". If only a single head is connected, the -# slave_* variable is ignored. - -set master_download_glob ""; -set slave_download_glob ""; - -# For consistency it is nicest if low station numbers contain leading -# zeroes. The following variable defines the corresponding printf(3) format. - -set stn_format "%03d"; - -# The following directory is used to store command files, instrument -# configurations and ADCP data. Separate subdirectories (named according to -# stn_format) are used for each cast. - -set raw_dir "../data/raw"; - -# After downloading, the data directory is backed up to the following -# directory. Make sure that it resides on a different disk than raw_dir. -# Empty string disables backup for testing purposes. -# NOTE: RELATIVE PATHNAMES MUST START FROM CAST DIR (NOT ACQUISITION DIR) - -set backup_dir "../../backup/raw"; - -# bbabble can be made to abort downloading after a preset amount of time, -# defined by the following variable. - -set download_timeout 999999; - -#---------------------------------------------------------------------- -# Semi-Standard Functions -#---------------------------------------------------------------------- - -proc set_computer_time {} { # set computer clock - global time_server; - if {[string length $time_server] == 0} {return} - exec sudo rdate -s $time_server; -} - -proc check_data {file} { # check data file - exec sh -c "scanbb $file"; - exec sh -c "sed -n '/^zmax/,/^zend/s/ at.*/m/p' `basename $file .000`.scn > /dev/tty"; -} - -proc backup_master_data {stn} { # copy data to network - global master_deployment_name_fmt master_cmd_file backup_dir; - if {[string length $backup_dir] == 0} {return} - - if {![file isdirectory $backup_dir]} { - error "$backup_dir does not exist relative to [pwd]"; - } - - set master_dir [format $backup_dir/$master_deployment_name_fmt $stn]; - if {![file isdirectory $master_dir]} {exec mkdir $master_dir}; - exec sh -c "cp [format $master_deployment_name_fmt $stn]* $master_dir"; - exec sh -c "cp $master_cmd_file* $master_dir"; - exec sh -c "cp *log $master_dir"; -} - -proc backup_slave_data {stn} { # copy data to network - global slave_deployment_name_fmt slave_cmd_file backup_dir; - if {[string length $backup_dir] == 0} {return} - - if {![file isdirectory $backup_dir]} { - error "$backup_dir does not exist relative to [pwd]"; - } - - set slave_dir [format $backup_dir/$slave_deployment_name_fmt $stn]; - if {![file isdirectory $slave_dir]} {exec mkdir $slave_dir}; - exec sh -c "cp [format $slave_deployment_name_fmt $stn]* $slave_dir"; - exec sh -c "cp $slave_cmd_file* $slave_dir"; - exec sh -c "cp *log $slave_dir"; -} - -proc rename_master_download_file {target} { # BB150 - global master_download_glob; - - if {[string length $master_download_glob] == 0} {return} - set files [glob -nocomplain $master_download_glob]; - set nfiles [llength $files]; - if {$nfiles == 0} { - if {![file exists $target]} { - error "can't find downloaded master file"; - } - return; - } - if {$nfiles > 1} { - send_user "WARNING: Multiple files downloaded from master --- rename, backup, check manually!"; - } - exec mv [lindex $files end] $target; -} - -proc rename_slave_download_file {target} { # BB150 - global slave_download_glob; - - if {[string length $slave_download_glob] == 0} {return} - set files [glob -nocomplain $slave_download_glob]; - set nfiles [llength $files]; - if {$nfiles == 0} { - if {![file exists $target]} { - error "can't find downloaded slave file"; - } - return; - } - if {$nfiles > 1} { - send_user "WARNING: Multiple files downloaded from slave --- rename, backup, check manually!"; - } - exec mv [lindex $files end] $target; -} diff -r 99a41e0476b1 -r fda11de1826e HISTORY --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HISTORY Tue Sep 14 13:34:39 2010 -0400 @@ -0,0 +1,16 @@ +#====================================================================== +# H I S T O R Y +# doc: Thu Aug 26 00:32:14 2010 +# dlm: Thu Aug 26 00:32:28 2010 +# (c) 2010 A.M. Thurnherr +# uE-Info: 9 0 NIL 0 0 72 0 2 8 NIL ofnI +#====================================================================== + +=V1.4= + +Aug 25, 2010: - changed [CRUISE_SETUP.expect] to allow *download_glob + to be used to rename files to make sure that downloaded + files have consistent upper/lower case + - DEFAULTS.expect -> CRUISE_SETUP.expect + - libBB.expect -> libRDI.expect + - began [HISTORY] diff -r 99a41e0476b1 -r fda11de1826e README --- a/README Wed Jul 07 13:29:02 2010 -0400 +++ b/README Tue Sep 14 13:34:39 2010 -0400 @@ -1,9 +1,9 @@ #====================================================================== # R E A D M E # doc: Sat Mar 20 23:10:10 2004 -# dlm: Wed Nov 19 14:21:14 2008 +# dlm: Thu Aug 26 00:17:47 2010 # (c) 2004 ladcp@ -# uE-Info: 68 56 NIL 0 0 72 3 2 8 NIL ofnI +# uE-Info: 16 0 NIL 0 0 72 3 2 8 NIL ofnI #====================================================================== =Connecting Instruments= @@ -30,7 +30,7 @@ - to troubleshoot, you can use "bbabble " but you're on your own there -4) add the special-files and serial numbers to [DEFAULTS.expect] +4) add the special-files and serial numbers to [CRUISE_SETUP.expect] - can change other settings, too 5) test everything by running "reset2" and "dir2" @@ -39,7 +39,7 @@ =Operator Scripts= -NB: [DEFAULTS.expect] must have been edited to set cruise-specific +NB: [CRUISE_SETUP.expect] must have been edited to set cruise-specific information. NB: the search path must be set up to include the directory of the @@ -81,7 +81,7 @@ =Colors= - for dual-headed systems, color is determined by the serial numbers - listed in [DEFAULTS.expect]: red for the master and blue for the + listed in [CRUISE_SETUP.expect]: red for the master and blue for the slave; - this can be different to the colors if [bbabble] is used directly, diff -r 99a41e0476b1 -r fda11de1826e README.FreeBSD --- a/README.FreeBSD Wed Jul 07 13:29:02 2010 -0400 +++ b/README.FreeBSD Tue Sep 14 13:34:39 2010 -0400 @@ -1,9 +1,9 @@ ====================================================================== R E A D M E . F R E E B S D doc: Thu Jan 19 09:43:38 2006 - dlm: Mon Aug 28 20:08:27 2006 + dlm: Thu Aug 26 00:18:00 2010 (c) 2006 A.M. Thurnherr - uE-Info: 106 0 NIL 0 0 72 3 2 4 NIL ofnI + uE-Info: 92 37 NIL 0 0 72 3 2 4 NIL ofnI ====================================================================== This file contains FreeBSDE-specific notes for installing and running @@ -89,7 +89,7 @@ one of them (although the linux binary may work). Compilation is non-trivial and requires hacking of the source. If scanbb is not available, LADCP-data-file checking can be disabled by modifying the -procedure check_data in [DEFAULTS.expect]. This is not recommended, +procedure check_data in [CRUISE_SETUP.expect]. This is not recommended, however. diff -r 99a41e0476b1 -r fda11de1826e README.MacOSX --- a/README.MacOSX Wed Jul 07 13:29:02 2010 -0400 +++ b/README.MacOSX Tue Sep 14 13:34:39 2010 -0400 @@ -1,9 +1,9 @@ ====================================================================== R E A D M E . M A C O S X doc: Thu Jan 19 09:43:38 2006 - dlm: Wed Jan 25 15:47:58 2006 + dlm: Thu Aug 26 00:18:47 2010 (c) 2006 A.M. Thurnherr - uE-Info: 108 0 NIL 0 0 72 3 2 4 NIL ofnI + uE-Info: 109 18 NIL 0 0 72 3 2 4 NIL ofnI ====================================================================== This file contains MacOSX-specific notes for installing and running the @@ -86,7 +86,7 @@ binary versions are available for a variety of systems, MacOSX is not one of them. Compilation is non-trivial and requires hacking of the source. If scanbb is not available, LADCP-data-file checking can be -disabled by modifying the procedure check_data in [DEFAULTS.expect]. +disabled by modifying the procedure check_data in [CRUISE_SETUP.expect]. This is not recommended, however. ====================================================================== @@ -106,6 +106,6 @@ device is called /dev/cu.KeySerial1, but the second one has a "geographical" (containing bus number, &c) name, such as /dev/cu.USA49W3b13P2.2. The name depends on where it is plugged in, -i.e. [DEFAULTS.expect] MAY HAVE TO BE MODIFIED AFTER RE-CONNECTING THE -USB CABLE(S). +i.e. [CRUISE_SETUP.expect] MAY HAVE TO BE MODIFIED AFTER RE-CONNECTING +THE USB CABLE(S). diff -r 99a41e0476b1 -r fda11de1826e abort1 --- a/abort1 Wed Jul 07 13:29:02 2010 -0400 +++ b/abort1 Tue Sep 14 13:34:39 2010 -0400 @@ -2,23 +2,25 @@ #====================================================================== # A B O R T 1 # doc: Wed Mar 10 22:23:52 2004 -# dlm: Wed Nov 19 15:10:44 2008 +# dlm: Thu Aug 26 00:20:26 2010 # (c) 2004 A.M. Thurnherr -# uE-Info: 13 32 NIL 0 0 72 2 2 8 NIL ofnI +# uE-Info: 15 48 NIL 0 0 72 2 2 8 NIL ofnI #====================================================================== # HISTORY: # Jun 19, 2004: - adapted from [endladcp1] # Nov 6, 2006: - adapted to old regsub # Nov 19, 2008: - added version +# Aug 25, 2010: - DEFAULTS.expect -> CRUISE_SETUP.expect +# - libBB.expect -> libRDI.expect #---------------------------------------------------------------------- # Setup #---------------------------------------------------------------------- log_user 0; -source DEFAULTS.expect; -regsub {dir1} [exec which dir1] {libBB.expect} path; +source CRUISE_SETUP.expect; +regsub {dir1} [exec which dir1] {libRDI.expect} path; source $path; print_version; diff -r 99a41e0476b1 -r fda11de1826e abort2 --- a/abort2 Wed Jul 07 13:29:02 2010 -0400 +++ b/abort2 Tue Sep 14 13:34:39 2010 -0400 @@ -2,22 +2,24 @@ #====================================================================== # A B O R T 2 # doc: Wed Mar 10 22:23:52 2004 -# dlm: Wed Nov 19 15:11:04 2008 +# dlm: Thu Aug 26 00:25:52 2010 # (c) 2004 A.M. Thurnherr -# uE-Info: 13 0 NIL 0 0 72 2 2 8 NIL ofnI +# uE-Info: 22 39 NIL 0 0 72 2 2 8 NIL ofnI #====================================================================== # HISTORY: # Jun 19, 2004: - adapted from [endladcp2] # Nov 19, 2008: - added version +# Aug 25, 2010: - DEFAULTS.expect -> CRUISE_SETUP.expect +# - libBB.expect -> libRDI.expect #---------------------------------------------------------------------- # Setup #---------------------------------------------------------------------- log_user 0; -source DEFAULTS.expect; -regsub {dir1} [exec which dir1] {libBB.expect} path; +source CRUISE_SETUP.expect; +regsub {dir1} [exec which dir1] {libRDI.expect} path; source $path; print_version; diff -r 99a41e0476b1 -r fda11de1826e bbabble --- a/bbabble Wed Jul 07 13:29:02 2010 -0400 +++ b/bbabble Tue Sep 14 13:34:39 2010 -0400 @@ -2,9 +2,9 @@ #====================================================================== # B B A B B L E # doc: Thu Mar 11 01:00:51 2004 -# dlm: Wed Dec 6 10:12:50 2006 +# dlm: Thu Aug 26 19:11:05 2010 # (c) 2004 A.M. Thurnherr -# uE-Info: 145 46 NIL 0 0 72 10 2 8 NIL ofnI +# uE-Info: 246 21 NIL 0 0 72 10 2 8 NIL ofnI #====================================================================== # Broad Band Babble --- talk to 1--2 RDI ADCPs @@ -44,12 +44,19 @@ # Nov 14, 2006: - added ^B (baud-rate handling) # - changes to task syncronization # - replace unprintable chars by ? while in ECHO mode (only!) +# Aug 26, 2010: - added -y)modem receive #---------------------------------------------------------------------- # USAGE #---------------------------------------------------------------------- -# bbabble [-m)onochrome] [-s)uppress async ouput] tty1 [tty2] +use Getopt::Std; + +$USAGE = "Usage: $0 [-m)onochrome] [-s)uppress async output] " . + "[-y)modem receive ] " . + " [tty1_device]\n"; + +die($USAGE) unless (getopts("msy:")); # bbabble is started with 1 or 2 arguments, which are tty special files. # On LINUX, /dev/ttyS0 is com1: /dev/ttyS1 is com2: /dev/ttyUSB0 is the @@ -234,11 +241,19 @@ # It does not have its own manpage but is described in the man page of # `rz' (the zmodem receiver). To make matters worse, In the man page # the prgram is always called `rb', even on systems where the executable -# is `lrb'. +# is `lrb'. +# If -y is not given, bbabble trys to find one of the standard ymodem +# executables. Using -y allows options to be set. -chomp($receive_ymodem = `which lrb 2>/dev/null`); -chomp($receive_ymodem = `which rb 2>/dev/null`) if ($receive_ymodem eq ''); -die("$0: cannot find rb or lrb\n") if ($receive_ymodem eq ''); +if (defined($opt_y)) { + $receive_ymodem = $opt_y; +} else { + chomp($receive_ymodem = `which lrb 2>/dev/null`); + chomp($receive_ymodem = `which rb 2>/dev/null`) + if ($receive_ymodem eq ''); + die("$0: cannot find rb or lrb\n") + if ($receive_ymodem eq ''); +} # When uploading command files, each command is sent after a prompt # is received from the instrument. The following variable defines the @@ -253,14 +268,8 @@ use threads; use threads::shared; use IO::Handle; -use Getopt::Std; use POSIX (); -$USAGE = "Usage: $0 [-m)onochrome] [-s)uppress async output] " . - " [tty1_device]\n"; - -die($USAGE) unless (getopts("ms")); - if (scalar(@ARGV) == 1) { $TTY0 = $ARGV[0]; } elsif (scalar(@ARGV) == 2) { diff -r 99a41e0476b1 -r fda11de1826e checkfiles1 --- a/checkfiles1 Wed Jul 07 13:29:02 2010 -0400 +++ b/checkfiles1 Tue Sep 14 13:34:39 2010 -0400 @@ -2,9 +2,9 @@ #====================================================================== # C H E C K F I L E S 1 # doc: Wed Mar 10 22:23:52 2004 -# dlm: Wed Nov 19 15:11:21 2008 +# dlm: Thu Aug 26 00:26:00 2010 # (c) 2004 A.M. Thurnherr -# uE-Info: 27 14 NIL 0 0 72 2 2 8 NIL ofnI +# uE-Info: 26 39 NIL 0 0 72 2 2 8 NIL ofnI #====================================================================== # HISTORY: @@ -14,14 +14,16 @@ # Oct 4, 2006: - adapted to older expect version # Oct 28, 2006: - adapted to older expect version # Nov 19, 2008: - added version +# Aug 25, 2010: - DEFAULTS.expect -> CRUISE_SETUP.expect +# - libBB.expect -> libRDI.expect #---------------------------------------------------------------------- # Setup #---------------------------------------------------------------------- log_user 0; -source DEFAULTS.expect; -regsub {dir1} [exec which dir1] {libBB.expect} path; +source CRUISE_SETUP.expect; +regsub {dir1} [exec which dir1] {libRDI.expect} path; source $path; print_version; diff -r 99a41e0476b1 -r fda11de1826e checkfiles2 --- a/checkfiles2 Wed Jul 07 13:29:02 2010 -0400 +++ b/checkfiles2 Tue Sep 14 13:34:39 2010 -0400 @@ -2,9 +2,9 @@ #====================================================================== # C H E C K F I L E S 2 # doc: Wed Mar 10 22:23:52 2004 -# dlm: Wed Nov 19 15:11:34 2008 +# dlm: Thu Aug 26 00:26:06 2010 # (c) 2004 A.M. Thurnherr -# uE-Info: 28 14 NIL 0 0 72 2 2 8 NIL ofnI +# uE-Info: 27 39 NIL 0 0 72 2 2 8 NIL ofnI #====================================================================== # HISTORY: @@ -15,14 +15,16 @@ # Oct 28, 2006: - adapted to old version expect (regsub) # - allowed for lrb downcasing filenames # Nov 19, 2008: - added version +# Aug 25, 2010: - DEFAULTS.expect -> CRUISE_SETUP.expect +# - libBB.expect -> libRDI.expect #---------------------------------------------------------------------- # Setup #---------------------------------------------------------------------- log_user 0; -source DEFAULTS.expect; -regsub {dir1} [exec which dir1] {libBB.expect} path; +source CRUISE_SETUP.expect; +regsub {dir1} [exec which dir1] {libRDI.expect} path; source $path; print_version; diff -r 99a41e0476b1 -r fda11de1826e dir1 --- a/dir1 Wed Jul 07 13:29:02 2010 -0400 +++ b/dir1 Tue Sep 14 13:34:39 2010 -0400 @@ -2,20 +2,22 @@ #====================================================================== # D I R 1 # doc: Mon Mar 8 02:57:35 2004 -# dlm: Wed Nov 19 15:12:11 2008 +# dlm: Thu Aug 26 00:28:15 2010 # (c) 2004 A.M. Thurnherr -# uE-Info: 11 26 NIL 0 0 72 2 2 4 NIL ofnI +# uE-Info: 14 1 NIL 0 0 72 2 2 8 NIL ofnI #====================================================================== # HISTORY: # Mar 8, 2004: - created # Nov 19, 2008: - added version +# Aug 25, 2010: - DEFAULTS.expect -> CRUISE_SETUP.expect +# - libBB.expect -> libRDI.expect log_user 0; -regsub {dir1} [exec which dir1] {libBB.expect} path; +regsub {dir1} [exec which dir1] {libRDI.expect} path; source $path; -source DEFAULTS.expect; +source CRUISE_SETUP.expect; print_version; diff -r 99a41e0476b1 -r fda11de1826e dir2 --- a/dir2 Wed Jul 07 13:29:02 2010 -0400 +++ b/dir2 Tue Sep 14 13:34:39 2010 -0400 @@ -2,20 +2,22 @@ #====================================================================== # D I R 2 # doc: Mon Mar 8 02:57:35 2004 -# dlm: Wed Nov 19 15:12:58 2008 +# dlm: Thu Aug 26 00:28:27 2010 # (c) 2004 A.M. Thurnherr -# uE-Info: 20 14 NIL 0 0 72 2 2 4 NIL ofnI +# uE-Info: 14 1 NIL 0 0 72 2 2 8 NIL ofnI #====================================================================== # HISTORY: # Mar 8, 2004: - created # Nov 19, 2008: - added version +# Aug 25, 2010: - DEFAULTS.expect -> CRUISE_SETUP.expect +# - libBB.expect -> libRDI.expect log_user 0; -regsub {dir1} [exec which dir1] {libBB.expect} path; +regsub {dir1} [exec which dir1] {libRDI.expect} path; source $path; -source DEFAULTS.expect; +source CRUISE_SETUP.expect; print_version; diff -r 99a41e0476b1 -r fda11de1826e endladcp1 --- a/endladcp1 Wed Jul 07 13:29:02 2010 -0400 +++ b/endladcp1 Tue Sep 14 13:34:39 2010 -0400 @@ -2,9 +2,9 @@ #====================================================================== # E N D L A D C P 1 # doc: Wed Mar 10 22:23:52 2004 -# dlm: Wed Nov 19 15:13:10 2008 +# dlm: Thu Aug 26 19:48:00 2010 # (c) 2004 A.M. Thurnherr -# uE-Info: 28 14 NIL 0 0 72 2 2 8 NIL ofnI +# uE-Info: 20 56 NIL 0 0 72 2 2 8 NIL ofnI #====================================================================== # HISTORY: @@ -15,14 +15,17 @@ # Oct 4, 2006: - adapted to older expect version # Oct 28, 2006: - allowed for lrb downcasing filenames # Nov 19, 2008: - added version +# Aug 25, 2010: - DEFAULTS.expect -> CRUISE_SETUP.expect +# - libBB.expect -> libRDI.expect +# Aug 26, 2010: - added support for ymodem_download_cmd #---------------------------------------------------------------------- # Setup #---------------------------------------------------------------------- log_user 0; -source DEFAULTS.expect; -regsub {dir1} [exec which dir1] {libBB.expect} path; +source CRUISE_SETUP.expect; +regsub {dir1} [exec which dir1] {libRDI.expect} path; source $path; print_version; @@ -84,7 +87,7 @@ regsub {.*/} $argv0 {} basename; start_logging [format %s_%s.log $basename $stnstr]; -spawn $bbabble -ms $tty0; +spawn $bbabble -msy $ymodem_receive_cmd $tty0; wait_for_startup; send_user "\nSaving hardware configuration..."; diff -r 99a41e0476b1 -r fda11de1826e endladcp2 --- a/endladcp2 Wed Jul 07 13:29:02 2010 -0400 +++ b/endladcp2 Tue Sep 14 13:34:39 2010 -0400 @@ -2,9 +2,9 @@ #====================================================================== # E N D L A D C P 2 # doc: Wed Mar 10 22:23:52 2004 -# dlm: Wed Nov 19 15:13:20 2008 +# dlm: Thu Aug 26 19:48:24 2010 # (c) 2004 A.M. Thurnherr -# uE-Info: 32 14 NIL 0 0 72 2 2 8 NIL ofnI +# uE-Info: 102 40 NIL 0 0 72 2 2 8 NIL ofnI #====================================================================== # HISTORY: @@ -18,15 +18,17 @@ # Oct 28, 2006: - allowed for lrb downcasing filenames # Nov 6, 2006: - BUG: error when master download finished much before slave # Nov 19, 2008: - added version - +# Aug 25, 2010: - DEFAULTS.expect -> CRUISE_SETUP.expect +# - libBB.expect -> libRDI.expect +# Aug 26, 2010: - added support for ymodem_download_cmd #---------------------------------------------------------------------- # Setup #---------------------------------------------------------------------- log_user 0; -source DEFAULTS.expect; -regsub {dir1} [exec which dir1] {libBB.expect} path; +source CRUISE_SETUP.expect; +regsub {dir1} [exec which dir1] {libRDI.expect} path; source $path; print_version; @@ -97,7 +99,7 @@ regsub {.*/} $argv0 {} basename; start_logging [format %s_%03d.log $basename $master_stn]; -spawn $bbabble -ms $tty0 $tty1; +spawn $bbabble -msy $ymodem_download_cmd $tty0 $tty1; wait_for_startup; send_user "\nSaving hardware configurations..."; diff -r 99a41e0476b1 -r fda11de1826e erasemem1 --- a/erasemem1 Wed Jul 07 13:29:02 2010 -0400 +++ b/erasemem1 Tue Sep 14 13:34:39 2010 -0400 @@ -2,20 +2,22 @@ #====================================================================== # E R A S E M E M 1 # doc: Mon Mar 8 02:57:35 2004 -# dlm: Wed Nov 19 15:14:20 2008 +# dlm: Thu Aug 26 00:28:39 2010 # (c) 2004 A.M. Thurnherr -# uE-Info: 20 14 NIL 0 0 72 2 2 4 NIL ofnI +# uE-Info: 14 1 NIL 0 0 72 2 2 8 NIL ofnI #====================================================================== # HISTORY: # Mar 8, 2004: - created # Nov 19, 2008: - added version +# Aug 25, 2010: - DEFAULTS.expect -> CRUISE_SETUP.expect +# - libBB.expect -> libRDI.expect log_user 0; -regsub {dir1} [exec which dir1] {libBB.expect} path; +regsub {dir1} [exec which dir1] {libRDI.expect} path; source $path; -source DEFAULTS.expect; +source CRUISE_SETUP.expect; print_version; diff -r 99a41e0476b1 -r fda11de1826e erasemem2 --- a/erasemem2 Wed Jul 07 13:29:02 2010 -0400 +++ b/erasemem2 Tue Sep 14 13:34:39 2010 -0400 @@ -2,20 +2,22 @@ #====================================================================== # E R A S E M E M 2 # doc: Mon Mar 8 02:57:35 2004 -# dlm: Wed Nov 19 15:14:04 2008 +# dlm: Thu Aug 26 00:28:51 2010 # (c) 2004 A.M. Thurnherr -# uE-Info: 20 14 NIL 0 0 72 2 2 4 NIL ofnI +# uE-Info: 18 39 NIL 0 0 72 2 2 8 NIL ofnI #====================================================================== # HISTORY: # Mar 8, 2004: - created # Nov 19, 2008: - added version +# Aug 25, 2010: - DEFAULTS.expect -> CRUISE_SETUP.expect +# - libBB.expect -> libRDI.expect log_user 0; -regsub {dir1} [exec which dir1] {libBB.expect} path; +regsub {dir1} [exec which dir1] {libRDI.expect} path; source $path; -source DEFAULTS.expect; +source CRUISE_SETUP.expect; print_version; diff -r 99a41e0476b1 -r fda11de1826e interact1 --- a/interact1 Wed Jul 07 13:29:02 2010 -0400 +++ b/interact1 Tue Sep 14 13:34:39 2010 -0400 @@ -2,21 +2,22 @@ #====================================================================== # I N T E R A C T 1 # doc: Mon Mar 8 02:57:35 2004 -# dlm: Wed Nov 19 15:15:27 2008 +# dlm: Thu Aug 26 00:29:00 2010 # (c) 2004 A.M. Thurnherr -# uE-Info: 21 14 NIL 0 0 72 0 2 8 NIL ofnI +# uE-Info: 18 39 NIL 0 0 72 0 2 8 NIL ofnI #====================================================================== # HISTORY: # Mar 8, 2004: - created # Nov 19, 2008: - added version - +# Aug 25, 2010: - DEFAULTS.expect -> CRUISE_SETUP.expect +# - libBB.expect -> libRDI.expect log_user 0; -regsub {dir1} [exec which dir1] {libBB.expect} path; +regsub {dir1} [exec which dir1] {libRDI.expect} path; source $path; -source DEFAULTS.expect; +source CRUISE_SETUP.expect; print_version; diff -r 99a41e0476b1 -r fda11de1826e interact2 --- a/interact2 Wed Jul 07 13:29:02 2010 -0400 +++ b/interact2 Tue Sep 14 13:34:39 2010 -0400 @@ -2,9 +2,9 @@ #====================================================================== # I N T E R A C T 2 # doc: Mon Mar 8 02:57:35 2004 -# dlm: Wed Nov 19 15:15:46 2008 +# dlm: Thu Aug 26 00:27:02 2010 # (c) 2004 A.M. Thurnherr -# uE-Info: 22 14 NIL 0 0 72 0 2 8 NIL ofnI +# uE-Info: 20 39 NIL 0 0 72 0 2 8 NIL ofnI #====================================================================== # HISTORY: @@ -12,12 +12,14 @@ # Jun 15, 2004: - BUG: 2nd instrument was not put to sleep correctly # (forgot to wait after toggle) # Nov 19, 2008: - added version +# Aug 25, 2010: - DEFAULTS.expect -> CRUISE_SETUP.expect +# - libBB.expect -> libRDI.expect log_user 0; -regsub {dir1} [exec which dir1] {libBB.expect} path; +regsub {dir1} [exec which dir1] {libRDI.expect} path; source $path; -source DEFAULTS.expect; +source CRUISE_SETUP.expect; print_version; diff -r 99a41e0476b1 -r fda11de1826e ladcp1 --- a/ladcp1 Wed Jul 07 13:29:02 2010 -0400 +++ b/ladcp1 Tue Sep 14 13:34:39 2010 -0400 @@ -2,9 +2,9 @@ #====================================================================== # L A D C P 1 # doc: Wed Mar 10 22:23:52 2004 -# dlm: Wed Nov 19 15:15:57 2008 +# dlm: Thu Aug 26 00:27:08 2010 # (c) 2004 A.M. Thurnherr -# uE-Info: 28 14 NIL 0 0 72 2 2 8 NIL ofnI +# uE-Info: 27 39 NIL 0 0 72 2 2 8 NIL ofnI #====================================================================== # HISTORY: @@ -15,14 +15,16 @@ # Oct 31, 2007: - BUG: wrong default on non-empty memory # Nov 19, 2008: - adapted to new firmware behavior (load_factory_defaults) # Nov 19, 2008: - added version +# Aug 25, 2010: - DEFAULTS.expect -> CRUISE_SETUP.expect +# - libBB.expect -> libRDI.expect #---------------------------------------------------------------------- # Setup #---------------------------------------------------------------------- log_user 0; -source DEFAULTS.expect; -regsub {dir1} [exec which dir1] {libBB.expect} path; +source CRUISE_SETUP.expect; +regsub {dir1} [exec which dir1] {libRDI.expect} path; source $path; print_version; diff -r 99a41e0476b1 -r fda11de1826e ladcp2 --- a/ladcp2 Wed Jul 07 13:29:02 2010 -0400 +++ b/ladcp2 Tue Sep 14 13:34:39 2010 -0400 @@ -2,9 +2,9 @@ #====================================================================== # L A D C P 2 # doc: Wed Mar 10 22:23:52 2004 -# dlm: Wed Nov 19 15:16:11 2008 +# dlm: Thu Aug 26 00:27:14 2010 # (c) 2004 A.M. Thurnherr -# uE-Info: 32 14 NIL 0 0 72 2 2 8 NIL ofnI +# uE-Info: 31 39 NIL 0 0 72 2 2 8 NIL ofnI #====================================================================== # HISTORY: @@ -19,14 +19,16 @@ # Oct 31, 2007: - BUG: wrong default on non-empty memory # Nov 19, 2008: - adapted to new firmware behavior (load_factory_defaults) # Nov 19, 2008: - added version +# Aug 25, 2010: - DEFAULTS.expect -> CRUISE_SETUP.expect +# - libBB.expect -> libRDI.expect #---------------------------------------------------------------------- # Setup #---------------------------------------------------------------------- log_user 0; -source DEFAULTS.expect; -regsub {dir1} [exec which dir1] {libBB.expect} path; +source CRUISE_SETUP.expect; +regsub {dir1} [exec which dir1] {libRDI.expect} path; source $path; print_version; diff -r 99a41e0476b1 -r fda11de1826e ladcp_send_cmd --- a/ladcp_send_cmd Wed Jul 07 13:29:02 2010 -0400 +++ b/ladcp_send_cmd Tue Sep 14 13:34:39 2010 -0400 @@ -2,9 +2,9 @@ #====================================================================== # L A D C P _ S E N D _ C M D # doc: Wed Mar 10 22:23:52 2004 -# dlm: Wed Nov 19 15:16:20 2008 +# dlm: Thu Aug 26 00:27:20 2010 # (c) 2004 A.M. Thurnherr -# uE-Info: 26 14 NIL 0 0 72 2 2 8 NIL ofnI +# uE-Info: 25 39 NIL 0 0 72 2 2 8 NIL ofnI #====================================================================== # HISTORY: @@ -13,14 +13,16 @@ # Nov 6, 2006: - adapted to old regsub # Nov 19, 2008: - adapted to new firmware behavior (load_factory_defaults) # Nov 19, 2008: - added version +# Aug 25, 2010: - DEFAULTS.expect -> CRUISE_SETUP.expect +# - libBB.expect -> libRDI.expect #---------------------------------------------------------------------- # Setup #---------------------------------------------------------------------- log_user 0; -source DEFAULTS.expect; -regsub {dir1} [exec which dir1] {libBB.expect} path; +source CRUISE_SETUP.expect; +regsub {dir1} [exec which dir1] {libRDI.expect} path; source $path; print_version; diff -r 99a41e0476b1 -r fda11de1826e libBB.expect --- a/libBB.expect Wed Jul 07 13:29:02 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,569 +0,0 @@ -#!/usr/bin/expect -f -#====================================================================== -# L I B B B . E X P E C T -# doc: Mon Mar 8 02:57:35 2004 -# dlm: Thu Nov 19 14:48:52 2009 -# (c) 2004 A.M. Thurnherr -# uE-Info: 41 54 NIL 0 0 72 2 2 8 NIL ofnI -#====================================================================== - -# HISTORY: -# Mar 8, 2004: - incepted (NBP0402) -# Mar 15, 2004: - released -# Mar 18, 2004: - improved download-error handling -# - BUG: set correct color in toggle_instrument -# - new reset_two_instruments -# Mar 20, 2004: - increased instrument-toggle timeout to 2s -# - cleaned-up get_deployment_name -# - added save_hardware_config to upload_file (just before CS) -# - renamed continue_logging to resume_logging -# Mar 21, 2004: - debugged user-interaction routines -# - generally increased timeouts -# Apr 4, 2004: - added comments -# Jun 15, 2004: - changed \n to \r for BB150 (CLIVAR P02) -# - started adaptation to BB150 -# Jun 18, 2004: - BUG: could not handle station 008 (illegal octal digit) -# Jun 27, 2004: - doubled wait_for_startup timeouts -# Sep 28, 2006: - added sleep 1 to wait_for_startup (marked AMARYLIS) -# Oct 30, 2006: - improved error messages -# Nov 6, 2006: - added ensure_sleep -# - BUG: input_int had interpreted 010 as octal -# Nov 15, 2006: - added next_speed -# Nov 17, 2006: - added get_serial_number -# - added save_parameters -# Oct 22, 2007: - removed erroneous line of code (that did nothing) -# - changed expect target in next_speed() -# Oct 23, 2007: - cosmetics -# Nov 19, 2008: - added load_factory_defaults() -# - added print_version() -# Oct 12, 2009: - BUG: load_factory_defaults errmesg used non-existent variable -# Nov 19, 2009: - get_deployment_name needed a delay (sleep 1) for the -# instruments sent to the DIMES cruise - -# NOTE: after having written this, I am not much of a fan of TCL and and -# expect(1) syntax any more... - -# PS0 ON BB150 NOTE: -# I AM NOT SURE ABOUT THE FOLLOWING ANY MORE. THE CURRENT CODE -# MAY THEREFORE NOT RUN WITH BB150s!!! -# PS0 does not produce any output on the BB150 unless the factory -# defaults are in effect. (I have not checked exactly which user defaults -# cause this behaviour.) Therefore, every time before PS0 is sent -# to the instrument, the current values are stored, the factory -# defaults restored, PS0 is sent, and then the user values -# are restored. For safety, I removed PS0 from save_hardware_config -# code for the BB150; because it would be really bad if the factory -# defaults would be restored immediately before pinging starts... -# The behaviour was detected on CPU firmware 5.52. - -set NEXT_SPEED \002; # ^B # bbabble commands -set BREAK \003; # ^C -set HELP \010; # ^H -set TOGGLE \024; # ^T -set DNLOAD \030; # ^X - -set cid -1; # current instrument - -proc print_version {} { - send_user "acquire V1.4beta\n" -} - -proc set_color {{cid -1}} { # set instrument color - if {$cid == 0} { - send_user [exec tput setaf 1]; - } elseif {$cid == 1} { - send_user [exec tput setaf 4]; - } else { - send_user [exec tput setaf 0]; - } -} - -proc error {msg} { # print error & exit - global cid; - set_color $cid; - send_error "\nError: $msg\n"; - set_color; - exit 1; -} - -proc gobble_prompts {} { # gobble old prompts - set continue_flushing 1; - while {$continue_flushing > 0} { - expect { - timeout {set continue_flushing 0;} - -timeout 0 ">"; - } - } -} - -proc BREAK {} { # send BREAK - global BREAK; - - gobble_prompts; - send $BREAK; # Wakeup Instrument - expect { - timeout {error "Can't wake Instrument"} - -timeout 8 "RD Instruments (c)" - } - expect { # gobble prompt as well - timeout {error "Can't get wakeup prompt"} - -timeout 3 ">" - } -} - -proc no_error_BREAK {} { # send BREAK without errcheck - global BREAK; - - gobble_prompts; - send $BREAK; - expect -timeout 8 "RD Instruments (c)" - expect -timeout 3 ">" -} - -proc next_speed {} { # select next baudrate - global NEXT_SPEED; - - send $NEXT_SPEED; - expect { - timeout {error "Cannot change speed"} - -timeout 5 ": end" - } - sleep 1 -} - -proc toggle_instrument {} { # select other instrument - global cid TOGGLE; - send $TOGGLE; # switch - expect { - timeout {error "Can't switch instruments"} - -timeout 3 "Instrument" - } - if {$cid == 0} {set cid 1} else {set cid 0} -} - -proc select_master {{toggle_first 1}} { # select master & check S/N - global HELP cid master_sn slave_sn; - - if {$toggle_first} toggle_instrument; - gobble_prompts; - send "\r"; wait_for_prompt; # save current value - send "PS0\r"; - expect { - timeout {error "Can't determine serial number"} - -timeout 8 -re "Instrument S/N: $master_sn.*>|Xducer Ser #: $master_sn.*>|PS0...>" {} - -timeout 8 -re "Instrument S/N: $slave_sn.*>" { - toggle_instrument; - send "PS0\r"; - expect { - timeout {error "Can't determine serial number"} - -timeout 8 -re "Instrument S/N: $master_sn.*>|Xducer Ser #: $master_sn.*>|PS0...>" {} - -timeout 8 -re "Instrument S/N: $slave_sn.*>" { - error "Can't switch to master" - } - } - } - } - set cid 0; -} - -proc select_slave {{toggle_first 1}} { # select slave & check S/N - global HELP cid master_sn slave_sn; - - if {$toggle_first} toggle_instrument; - gobble_prompts; - send "\r"; wait_for_prompt; # save current value - send "PS0\r"; - expect { - timeout {error "Can't determine master/slave"} - -timeout 8 -re "Instrument S/N: $slave_sn.*>" {} - -timeout 8 -re "Instrument S/N: $master_sn.*>|Xducer Ser #: $master_sn.*>|PS0...>" { - toggle_instrument; - send "PS0\r"; - expect { - timeout {error "Can't determine master/slave"} - -timeout 8 -re "Instrument S/N: $slave_sn.*>" {} - -timeout 8 -re "Instrument S/N: $master_sn.*>|Xducer Ser #: $master_sn.*>|PS0...>" { - error "Can't switch to slave" - } - } - } - } - set cid 1; -} - -proc wait_for_startup {} { # wait for bbabble startup - global cid; - expect { - timeout {error "bbabble failed to start up"} - -timeout 10 "device" { - error "No such device: cables plugged in???" - } - -timeout 10 "Instrument 0" {} - } - set cid 0; - sleep 1; # AMARYLIS -} - -proc reset_instrument {} { # reset regardless of state - no_error_BREAK; - send "\r"; # send NOP command - expect { - timeout { - send_error "."; - BREAK; # try again - } - -timeout 5 ">"; # instrument reacted - } -} - -proc reset_two_instruments {} { # reset regardless of state - set ok 0; -### toggle_instrument; - while {$ok < 2} { - no_error_BREAK; - send "\r"; expect { - timeout { - set ok 0; - send_error "!"; - } - -timeout 5 ">" {incr ok} - } - toggle_instrument; - } - select_master; -} - -proc wait_for_prompt {{tout 5}} { # wait for prompt - expect { - timeout {error "Can't get prompt"} - -timeout $tout "ERR" { - error "Instrument returned error $expect_out(buffer)"; - } - -timeout $tout ">" - } -} - -proc put_to_sleep {} { # send instrument to sleep - gobble_prompts; - send "\r"; wait_for_prompt; - send "CZ\r"; - expect { - timeout {error "Can't put Instrument to sleep"} - -timeout 5 -re "Powering Down|POWERING DOWN" - } -} - -proc save_parameters {} { # save parameters - gobble_prompts; - send "\r"; wait_for_prompt; - send "CK\r"; - expect { - timeout {error "Can't put Instrument to sleep"} - -timeout 5 -re "USER defaults" - } -} - -proc ensure_sleep {} { # send instrument to sleep... - gobble_prompts; # unless already sleeping - send "CZ\r"; - expect { - timeout {error "Can't put Instrument to sleep"} - -timeout 5 -re "Powering Down|POWERING DOWN" - } -} - -proc start_download {} { # start downloading - global DNLOAD; - - gobble_prompts; - send "\r"; wait_for_prompt; - send $DNLOAD; - expect { - timeout {error "Can't start download (memory empty?)"} - -timeout 10 "Receiving:" - } -} - -proc wait_for_download_finish {stn tout} { # wait for timeout to finish - global BREAK TOGGLE; - expect { - timeout {error "Download did not finish ok"} - -timeout $tout "Transfer complete" {} - -timeout $tout "ABNORMALLY" { - send $BREAK; send $TOGGLE; send $BREAK; - error "Download did not finish ok"; - } - } - expect -timeout 5 ">"; - - global cid master_download_filename slave_download_filename; - global master_deployment_name_fmt slave_deployment_name_fmt; - if {$cid == 0} { - rename_master_download_file [format $master_deployment_name_fmt $stn]000.000; - } else { - rename_slave_download_file [format $slave_deployment_name_fmt $stn]000.000; - } -} - -proc list_dir {} { # list directory - global cid; - gobble_prompts; - send "\r"; wait_for_prompt; - send "RR\r"; - expect { - -timeout 1 "ERR" { # BB150 - wait_for_prompt; - send "RS\r"; - log_user 1; - } - -timeout 5 "Recorder Directory:"; - } - set_color $cid; log_user 1; - wait_for_prompt; - log_user 0; set_color; -} - -proc erase_memory {} { # erase memory - gobble_prompts; - send "\r"; wait_for_prompt; - send "RE ErAsE\r"; - expect { - timeout {error "Can't erase recorder"} - -timeout 5 "Erasing..." { # BB150 - sleep 3; - wait_for_prompt; - return; - } - -timeout 5 "Recorder erased." # Workhorse - } - wait_for_prompt; -} - -proc save_hardware_config {filename} { # NB: logging continues in ... - gobble_prompts; # ... file given as parameter - send "\r"; wait_for_prompt; - send "TT?\r"; # BB150 - expect -timeout 1 "ERR" { - wait_for_prompt; - set time [exec date +%y/%m/%d,%H:%M:%S]; - set pipe [open "| tr -d \\\r \ - | sed -e s@Time\\ Set.*@LOGGING\\ COMPUTER:\\ $time@ \ - -e /^>/d \ - > $filename" w]; - log_file; log_file -a -open $pipe; - send "T?\r"; wait_for_prompt; - send "RA?\r"; wait_for_prompt; - send "RS?\r"; wait_for_prompt; - send "W?\r"; wait_for_prompt; - send "B?\r"; wait_for_prompt; - send "E?\r"; wait_for_prompt; - send "CG?\r"; wait_for_prompt; - send "CL?\r"; wait_for_prompt; - send "CP?\r"; wait_for_prompt; - send "CQ?\r"; wait_for_prompt; - send "CT?\r"; wait_for_prompt; - send "CX?\r"; wait_for_prompt; - send "PS3\r"; wait_for_prompt; - return; - } - set time [exec date +%Y/%m/%d,%H:%M:%S]; - set pipe [open "| tr -d \\\r \ - | sed -e s/^Press\\ any\\ key\\ to\\ continue\\ *// \ - -e s@Time\\ Set.*@LOGGING\\ COMPUTER:\\ $time@ \ - > $filename" w]; - log_file; - log_file -a -open $pipe; - send "TT?\r"; wait_for_prompt; - send "RF\r"; wait_for_prompt; - send "RR\r"; wait_for_prompt; - send "PS0\r"; wait_for_prompt; - send "PS3\r"; wait_for_prompt; - send "AC\r"; wait_for_prompt; - send "RN?\r"; wait_for_prompt; - send "DEPLOY?\r"; - expect { - timeout {error "Can't get DEPLOY? output"} - -timeout 10 "Press any key to continue" - } - send " "; wait_for_prompt; -} - -proc start_logging {{filename "bbabble.log"}} { # write UNIX conformant log file - set pipe [open "| tr -d \\\r \ - > $filename" w]; - log_file -a -open $pipe; -} - -proc resume_logging {{filename "bbabble.log"}} {# append to UNIX conf. log file - set pipe [open "| tr -d \\\r \ - >> $filename" w]; - log_file; - log_file -a -open $pipe; -} - -proc memory_empty {} { # check whether memory is empty - gobble_prompts; - send "\r"; wait_for_prompt; - send "RA\r"; - expect { - timeout {error "Can't get number of deployments"}; - -timeout 3 -re {[1-9]} { - wait_for_prompt; - return 0; - } - -timeout 3 ">" { - return 1; - } - } -} - -proc set_instrument_clock {} { # set instrument clock - gobble_prompts; - send "\r"; wait_for_prompt; - send "TT?\r"; # check for BB150 - expect { - -timeout 1 "ERR" { - gobble_prompts; - set time [exec date +%y/%m/%d,%H:%M:%S]; - send "TS$time\r"; - wait_for_prompt; - return; - } - } - set time [exec date +%Y/%m/%d,%H:%M:%S]; - send "TT$time\r"; - wait_for_prompt; -} - -proc upload_file {cfn lfn hwfn} { # upload command file - gobble_prompts; # logging stops in this routine - send "\r"; wait_for_prompt; - set cf [open $cfn "r"]; - set lf [open $lfn "w"]; - while {[gets $cf line] >= 0} { - regsub {[ ]*;.*} $line {} line; - if {![regexp {^[ ]*$} $line]} { - puts -nonewline $lf "$line ... "; - if {$line == "CS" || $line == "cs"} { - send_error "!"; - save_hardware_config $hwfn; - send "$line\r"; - expect { - timeout {}; - -timeout 3 expect ">" { - error "Got prompt after CS command"; - } - } - puts $lf "INSTRUMENT PINGING"; - close $cf; close $lf; - log_file; - return; - } - send "$line\r"; - send_error "."; - expect { - timeout {error "Can't get prompt after sending $line"}; - -timeout 5 "ERR" { - error "Sending command $line returned $expect_out(buffer)"; - } - -timeout 5 ">" { - puts $lf "OK"; - } - } - } - } - close $cf; close $lf; -} - -proc load_factory_defaults {} { # set default params - gobble_prompts; - send "\r"; wait_for_prompt; - send "CR1\r"; - expect { - timeout {error "Can't get prompt"}; - -timeout 5 "ERR" { - error "command CR1 returned $expect_out(buffer)"; - } - -timeout 5 ">" - } -} - -proc set_deployment_name {{dn UNSET}} { # set deployment name - gobble_prompts; - send "\r"; wait_for_prompt; - send "RN$dn\r"; - expect -timeout 1 "ERR"; # BB150 - wait_for_prompt; -} - -proc get_deployment_name {} { # get deployment name - global stn_format master_deployment_name_fmt; - gobble_prompts; - send "\r"; wait_for_prompt; - send "RN?\r"; sleep 1; - expect { - timeout {error "Can't get deployment name";} - -timeout 1 "ERR" { # BB150 - if {![file isfile .last_stn]} { - error "Can't find .last_stn"; - } - set stn [exec cat .last_stn]; - set dn [format $master_deployment_name_fmt $stn]; - wait_for_prompt; - return $dn; - } - -timeout 5 -re {Current deployment name = ([^\r]*)} - } - set dn $expect_out(1,string); - wait_for_prompt; - return $dn; -} - -proc get_serial_number {} { # get serial number - gobble_prompts; - send "\r"; wait_for_prompt; - send "PS0\r"; - expect { - timeout {error "Can't get serial number";} - -timeout 5 -re {Instrument S/N: *([0-9]*)} - } - set sn $expect_out(1,string); - wait_for_prompt; - return $sn; -} - -#====================================================================== -# User-Interation Routines -#====================================================================== - -proc affirm {prompt {to -1} {timeout_return 0}} { # yes/no question with timeout - send_user $prompt; # and default answer - while {1} { - expect_user { - timeout { - if {$timeout_return == 0} { - send_user "N\n"; - } else { - send_user "Y\n"; - } - return $timeout_return; - } - -timeout $to -re "^y.*|^Y.*" {return 1;} - -timeout $to -re "^n.*|^N.*" {return 0;} - -re {..*} {send_user "Please answer Y or N..."} - } - } -} - -proc input_int {prompt} { # input an integer - while {1} { - send_user $prompt; - expect_user { - -timeout -1 -re {^[0-9]+\n} { - regsub {^0*} $expect_out(0,string) {} decimal_val; - return $decimal_val; - } - -timeout -1 -re {.+} {send_user "only integers, please!\n"} - } - } -} diff -r 99a41e0476b1 -r fda11de1826e libRDI.expect --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libRDI.expect Tue Sep 14 13:34:39 2010 -0400 @@ -0,0 +1,571 @@ +#!/usr/bin/expect -f +#====================================================================== +# L I B R D I . E X P E C T +# doc: Mon Mar 8 02:57:35 2004 +# dlm: Thu Aug 26 00:23:09 2010 +# (c) 2004 A.M. Thurnherr +# uE-Info: 42 0 NIL 0 0 72 2 2 8 NIL ofnI +#====================================================================== + +# HISTORY: +# Mar 8, 2004: - incepted (NBP0402) +# Mar 15, 2004: - released +# Mar 18, 2004: - improved download-error handling +# - BUG: set correct color in toggle_instrument +# - new reset_two_instruments +# Mar 20, 2004: - increased instrument-toggle timeout to 2s +# - cleaned-up get_deployment_name +# - added save_hardware_config to upload_file (just before CS) +# - renamed continue_logging to resume_logging +# Mar 21, 2004: - debugged user-interaction routines +# - generally increased timeouts +# Apr 4, 2004: - added comments +# Jun 15, 2004: - changed \n to \r for BB150 (CLIVAR P02) +# - started adaptation to BB150 +# Jun 18, 2004: - BUG: could not handle station 008 (illegal octal digit) +# Jun 27, 2004: - doubled wait_for_startup timeouts +# Sep 28, 2006: - added sleep 1 to wait_for_startup (marked AMARYLIS) +# Oct 30, 2006: - improved error messages +# Nov 6, 2006: - added ensure_sleep +# - BUG: input_int had interpreted 010 as octal +# Nov 15, 2006: - added next_speed +# Nov 17, 2006: - added get_serial_number +# - added save_parameters +# Oct 22, 2007: - removed erroneous line of code (that did nothing) +# - changed expect target in next_speed() +# Oct 23, 2007: - cosmetics +# Nov 19, 2008: - added load_factory_defaults() +# - added print_version() +# Oct 12, 2009: - BUG: load_factory_defaults errmesg used non-existent variable +# Nov 19, 2009: - get_deployment_name needed a delay (sleep 1) for the +# instruments sent to the DIMES cruise +# Aug 25, 2010: - libBB.expect -> libRDI.expect + + +# NOTE: after having written this, I am not much of a fan of TCL and and +# expect(1) syntax any more... + +# PS0 ON BB150 NOTE: +# I AM NOT SURE ABOUT THE FOLLOWING ANY MORE. THE CURRENT CODE +# MAY THEREFORE NOT RUN WITH BB150s!!! +# PS0 does not produce any output on the BB150 unless the factory +# defaults are in effect. (I have not checked exactly which user defaults +# cause this behaviour.) Therefore, every time before PS0 is sent +# to the instrument, the current values are stored, the factory +# defaults restored, PS0 is sent, and then the user values +# are restored. For safety, I removed PS0 from save_hardware_config +# code for the BB150; because it would be really bad if the factory +# defaults would be restored immediately before pinging starts... +# The behaviour was detected on CPU firmware 5.52. + +set NEXT_SPEED \002; # ^B # bbabble commands +set BREAK \003; # ^C +set HELP \010; # ^H +set TOGGLE \024; # ^T +set DNLOAD \030; # ^X + +set cid -1; # current instrument + +proc print_version {} { + send_user "acquire V1.4beta\n" +} + +proc set_color {{cid -1}} { # set instrument color + if {$cid == 0} { + send_user [exec tput setaf 1]; + } elseif {$cid == 1} { + send_user [exec tput setaf 4]; + } else { + send_user [exec tput setaf 0]; + } +} + +proc error {msg} { # print error & exit + global cid; + set_color $cid; + send_error "\nError: $msg\n"; + set_color; + exit 1; +} + +proc gobble_prompts {} { # gobble old prompts + set continue_flushing 1; + while {$continue_flushing > 0} { + expect { + timeout {set continue_flushing 0;} + -timeout 0 ">"; + } + } +} + +proc BREAK {} { # send BREAK + global BREAK; + + gobble_prompts; + send $BREAK; # Wakeup Instrument + expect { + timeout {error "Can't wake Instrument"} + -timeout 8 "RD Instruments (c)" + } + expect { # gobble prompt as well + timeout {error "Can't get wakeup prompt"} + -timeout 3 ">" + } +} + +proc no_error_BREAK {} { # send BREAK without errcheck + global BREAK; + + gobble_prompts; + send $BREAK; + expect -timeout 8 "RD Instruments (c)" + expect -timeout 3 ">" +} + +proc next_speed {} { # select next baudrate + global NEXT_SPEED; + + send $NEXT_SPEED; + expect { + timeout {error "Cannot change speed"} + -timeout 5 ": end" + } + sleep 1 +} + +proc toggle_instrument {} { # select other instrument + global cid TOGGLE; + send $TOGGLE; # switch + expect { + timeout {error "Can't switch instruments"} + -timeout 3 "Instrument" + } + if {$cid == 0} {set cid 1} else {set cid 0} +} + +proc select_master {{toggle_first 1}} { # select master & check S/N + global HELP cid master_sn slave_sn; + + if {$toggle_first} toggle_instrument; + gobble_prompts; + send "\r"; wait_for_prompt; # save current value + send "PS0\r"; + expect { + timeout {error "Can't determine serial number"} + -timeout 8 -re "Instrument S/N: $master_sn.*>|Xducer Ser #: $master_sn.*>|PS0...>" {} + -timeout 8 -re "Instrument S/N: $slave_sn.*>" { + toggle_instrument; + send "PS0\r"; + expect { + timeout {error "Can't determine serial number"} + -timeout 8 -re "Instrument S/N: $master_sn.*>|Xducer Ser #: $master_sn.*>|PS0...>" {} + -timeout 8 -re "Instrument S/N: $slave_sn.*>" { + error "Can't switch to master" + } + } + } + } + set cid 0; +} + +proc select_slave {{toggle_first 1}} { # select slave & check S/N + global HELP cid master_sn slave_sn; + + if {$toggle_first} toggle_instrument; + gobble_prompts; + send "\r"; wait_for_prompt; # save current value + send "PS0\r"; + expect { + timeout {error "Can't determine master/slave"} + -timeout 8 -re "Instrument S/N: $slave_sn.*>" {} + -timeout 8 -re "Instrument S/N: $master_sn.*>|Xducer Ser #: $master_sn.*>|PS0...>" { + toggle_instrument; + send "PS0\r"; + expect { + timeout {error "Can't determine master/slave"} + -timeout 8 -re "Instrument S/N: $slave_sn.*>" {} + -timeout 8 -re "Instrument S/N: $master_sn.*>|Xducer Ser #: $master_sn.*>|PS0...>" { + error "Can't switch to slave" + } + } + } + } + set cid 1; +} + +proc wait_for_startup {} { # wait for bbabble startup + global cid; + expect { + timeout {error "bbabble failed to start up"} + -timeout 10 "device" { + error "No such device: cables plugged in???" + } + -timeout 10 "Instrument 0" {} + } + set cid 0; + sleep 1; # AMARYLIS +} + +proc reset_instrument {} { # reset regardless of state + no_error_BREAK; + send "\r"; # send NOP command + expect { + timeout { + send_error "."; + BREAK; # try again + } + -timeout 5 ">"; # instrument reacted + } +} + +proc reset_two_instruments {} { # reset regardless of state + set ok 0; +### toggle_instrument; + while {$ok < 2} { + no_error_BREAK; + send "\r"; expect { + timeout { + set ok 0; + send_error "!"; + } + -timeout 5 ">" {incr ok} + } + toggle_instrument; + } + select_master; +} + +proc wait_for_prompt {{tout 5}} { # wait for prompt + expect { + timeout {error "Can't get prompt"} + -timeout $tout "ERR" { + error "Instrument returned error $expect_out(buffer)"; + } + -timeout $tout ">" + } +} + +proc put_to_sleep {} { # send instrument to sleep + gobble_prompts; + send "\r"; wait_for_prompt; + send "CZ\r"; + expect { + timeout {error "Can't put Instrument to sleep"} + -timeout 5 -re "Powering Down|POWERING DOWN" + } +} + +proc save_parameters {} { # save parameters + gobble_prompts; + send "\r"; wait_for_prompt; + send "CK\r"; + expect { + timeout {error "Can't put Instrument to sleep"} + -timeout 5 -re "USER defaults" + } +} + +proc ensure_sleep {} { # send instrument to sleep... + gobble_prompts; # unless already sleeping + send "CZ\r"; + expect { + timeout {error "Can't put Instrument to sleep"} + -timeout 5 -re "Powering Down|POWERING DOWN" + } +} + +proc start_download {} { # start downloading + global DNLOAD; + + gobble_prompts; + send "\r"; wait_for_prompt; + send $DNLOAD; + expect { + timeout {error "Can't start download (memory empty?)"} + -timeout 10 "Receiving:" + } +} + +proc wait_for_download_finish {stn tout} { # wait for timeout to finish + global BREAK TOGGLE; + expect { + timeout {error "Download did not finish ok"} + -timeout $tout "Transfer complete" {} + -timeout $tout "ABNORMALLY" { + send $BREAK; send $TOGGLE; send $BREAK; + error "Download did not finish ok"; + } + } + expect -timeout 5 ">"; + + global cid master_download_filename slave_download_filename; + global master_deployment_name_fmt slave_deployment_name_fmt; + if {$cid == 0} { + rename_master_download_file [format $master_deployment_name_fmt $stn]000.000; + } else { + rename_slave_download_file [format $slave_deployment_name_fmt $stn]000.000; + } +} + +proc list_dir {} { # list directory + global cid; + gobble_prompts; + send "\r"; wait_for_prompt; + send "RR\r"; + expect { + -timeout 1 "ERR" { # BB150 + wait_for_prompt; + send "RS\r"; + log_user 1; + } + -timeout 5 "Recorder Directory:"; + } + set_color $cid; log_user 1; + wait_for_prompt; + log_user 0; set_color; +} + +proc erase_memory {} { # erase memory + gobble_prompts; + send "\r"; wait_for_prompt; + send "RE ErAsE\r"; + expect { + timeout {error "Can't erase recorder"} + -timeout 5 "Erasing..." { # BB150 + sleep 3; + wait_for_prompt; + return; + } + -timeout 5 "Recorder erased." # Workhorse + } + wait_for_prompt; +} + +proc save_hardware_config {filename} { # NB: logging continues in ... + gobble_prompts; # ... file given as parameter + send "\r"; wait_for_prompt; + send "TT?\r"; # BB150 + expect -timeout 1 "ERR" { + wait_for_prompt; + set time [exec date +%y/%m/%d,%H:%M:%S]; + set pipe [open "| tr -d \\\r \ + | sed -e s@Time\\ Set.*@LOGGING\\ COMPUTER:\\ $time@ \ + -e /^>/d \ + > $filename" w]; + log_file; log_file -a -open $pipe; + send "T?\r"; wait_for_prompt; + send "RA?\r"; wait_for_prompt; + send "RS?\r"; wait_for_prompt; + send "W?\r"; wait_for_prompt; + send "B?\r"; wait_for_prompt; + send "E?\r"; wait_for_prompt; + send "CG?\r"; wait_for_prompt; + send "CL?\r"; wait_for_prompt; + send "CP?\r"; wait_for_prompt; + send "CQ?\r"; wait_for_prompt; + send "CT?\r"; wait_for_prompt; + send "CX?\r"; wait_for_prompt; + send "PS3\r"; wait_for_prompt; + return; + } + set time [exec date +%Y/%m/%d,%H:%M:%S]; + set pipe [open "| tr -d \\\r \ + | sed -e s/^Press\\ any\\ key\\ to\\ continue\\ *// \ + -e s@Time\\ Set.*@LOGGING\\ COMPUTER:\\ $time@ \ + > $filename" w]; + log_file; + log_file -a -open $pipe; + send "TT?\r"; wait_for_prompt; + send "RF\r"; wait_for_prompt; + send "RR\r"; wait_for_prompt; + send "PS0\r"; wait_for_prompt; + send "PS3\r"; wait_for_prompt; + send "AC\r"; wait_for_prompt; + send "RN?\r"; wait_for_prompt; + send "DEPLOY?\r"; + expect { + timeout {error "Can't get DEPLOY? output"} + -timeout 10 "Press any key to continue" + } + send " "; wait_for_prompt; +} + +proc start_logging {{filename "bbabble.log"}} { # write UNIX conformant log file + set pipe [open "| tr -d \\\r \ + > $filename" w]; + log_file -a -open $pipe; +} + +proc resume_logging {{filename "bbabble.log"}} {# append to UNIX conf. log file + set pipe [open "| tr -d \\\r \ + >> $filename" w]; + log_file; + log_file -a -open $pipe; +} + +proc memory_empty {} { # check whether memory is empty + gobble_prompts; + send "\r"; wait_for_prompt; + send "RA\r"; + expect { + timeout {error "Can't get number of deployments"}; + -timeout 3 -re {[1-9]} { + wait_for_prompt; + return 0; + } + -timeout 3 ">" { + return 1; + } + } +} + +proc set_instrument_clock {} { # set instrument clock + gobble_prompts; + send "\r"; wait_for_prompt; + send "TT?\r"; # check for BB150 + expect { + -timeout 1 "ERR" { + gobble_prompts; + set time [exec date +%y/%m/%d,%H:%M:%S]; + send "TS$time\r"; + wait_for_prompt; + return; + } + } + set time [exec date +%Y/%m/%d,%H:%M:%S]; + send "TT$time\r"; + wait_for_prompt; +} + +proc upload_file {cfn lfn hwfn} { # upload command file + gobble_prompts; # logging stops in this routine + send "\r"; wait_for_prompt; + set cf [open $cfn "r"]; + set lf [open $lfn "w"]; + while {[gets $cf line] >= 0} { + regsub {[ ]*;.*} $line {} line; + if {![regexp {^[ ]*$} $line]} { + puts -nonewline $lf "$line ... "; + if {$line == "CS" || $line == "cs"} { + send_error "!"; + save_hardware_config $hwfn; + send "$line\r"; + expect { + timeout {}; + -timeout 3 expect ">" { + error "Got prompt after CS command"; + } + } + puts $lf "INSTRUMENT PINGING"; + close $cf; close $lf; + log_file; + return; + } + send "$line\r"; + send_error "."; + expect { + timeout {error "Can't get prompt after sending $line"}; + -timeout 5 "ERR" { + error "Sending command $line returned $expect_out(buffer)"; + } + -timeout 5 ">" { + puts $lf "OK"; + } + } + } + } + close $cf; close $lf; +} + +proc load_factory_defaults {} { # set default params + gobble_prompts; + send "\r"; wait_for_prompt; + send "CR1\r"; + expect { + timeout {error "Can't get prompt"}; + -timeout 5 "ERR" { + error "command CR1 returned $expect_out(buffer)"; + } + -timeout 5 ">" + } +} + +proc set_deployment_name {{dn UNSET}} { # set deployment name + gobble_prompts; + send "\r"; wait_for_prompt; + send "RN$dn\r"; + expect -timeout 1 "ERR"; # BB150 + wait_for_prompt; +} + +proc get_deployment_name {} { # get deployment name + global stn_format master_deployment_name_fmt; + gobble_prompts; + send "\r"; wait_for_prompt; + send "RN?\r"; sleep 1; + expect { + timeout {error "Can't get deployment name";} + -timeout 1 "ERR" { # BB150 + if {![file isfile .last_stn]} { + error "Can't find .last_stn"; + } + set stn [exec cat .last_stn]; + set dn [format $master_deployment_name_fmt $stn]; + wait_for_prompt; + return $dn; + } + -timeout 5 -re {Current deployment name = ([^\r]*)} + } + set dn $expect_out(1,string); + wait_for_prompt; + return $dn; +} + +proc get_serial_number {} { # get serial number + gobble_prompts; + send "\r"; wait_for_prompt; + send "PS0\r"; + expect { + timeout {error "Can't get serial number";} + -timeout 5 -re {Instrument S/N: *([0-9]*)} + } + set sn $expect_out(1,string); + wait_for_prompt; + return $sn; +} + +#====================================================================== +# User-Interation Routines +#====================================================================== + +proc affirm {prompt {to -1} {timeout_return 0}} { # yes/no question with timeout + send_user $prompt; # and default answer + while {1} { + expect_user { + timeout { + if {$timeout_return == 0} { + send_user "N\n"; + } else { + send_user "Y\n"; + } + return $timeout_return; + } + -timeout $to -re "^y.*|^Y.*" {return 1;} + -timeout $to -re "^n.*|^N.*" {return 0;} + -re {..*} {send_user "Please answer Y or N..."} + } + } +} + +proc input_int {prompt} { # input an integer + while {1} { + send_user $prompt; + expect_user { + -timeout -1 -re {^[0-9]+\n} { + regsub {^0*} $expect_out(0,string) {} decimal_val; + return $decimal_val; + } + -timeout -1 -re {.+} {send_user "only integers, please!\n"} + } + } +} diff -r 99a41e0476b1 -r fda11de1826e prepare_instrument --- a/prepare_instrument Wed Jul 07 13:29:02 2010 -0400 +++ b/prepare_instrument Tue Sep 14 13:34:39 2010 -0400 @@ -2,9 +2,9 @@ #====================================================================== # P R E P A R E _ I N S T R U M E N T # doc: Wed Nov 15 00:54:23 2006 -# dlm: Wed Nov 19 15:16:44 2008 +# dlm: Thu Aug 26 00:27:24 2010 # (c) 2006 ladder@ -# uE-Info: 27 14 NIL 0 0 72 2 2 8 NIL ofnI +# uE-Info: 25 39 NIL 0 0 72 2 2 8 NIL ofnI #====================================================================== # HISTORY: @@ -13,15 +13,16 @@ # Oct 22, 2007: - added sleep 3 after BREAK for HP heads # Oct 23, 2007: - cosmetics # Nov 19, 2008: - added version - +# Aug 25, 2010: - DEFAULTS.expect -> CRUISE_SETUP.expect +# - libBB.expect -> libRDI.expect #---------------------------------------------------------------------- # Setup #---------------------------------------------------------------------- log_user 0; -source DEFAULTS.expect; -regsub {dir1} [exec which dir1] {libBB.expect} path; +source CRUISE_SETUP.expect; +regsub {dir1} [exec which dir1] {libRDI.expect} path; source $path; print_version; diff -r 99a41e0476b1 -r fda11de1826e print_version --- a/print_version Wed Jul 07 13:29:02 2010 -0400 +++ b/print_version Tue Sep 14 13:34:39 2010 -0400 @@ -2,18 +2,20 @@ #====================================================================== # P R I N T _ V E R S I O N # doc: Mon Mar 8 02:57:35 2004 -# dlm: Wed Nov 19 15:17:01 2008 +# dlm: Thu Aug 26 00:29:15 2010 # (c) 2004 A.M. Thurnherr -# uE-Info: 11 27 NIL 0 0 72 2 2 4 NIL ofnI +# uE-Info: 11 3 NIL 0 0 72 2 2 8 NIL ofnI #====================================================================== # HISTORY: -# Nov 19, 2008: - created +# Nov 19, 2008: - created +# Aug 25, 2010: - DEFAULTS.expect -> CRUISE_SETUP.expect +# - libBB.expect -> libRDI.expect log_user 0; -regsub {dir1} [exec which dir1] {libBB.expect} path; +regsub {dir1} [exec which dir1] {libRDI.expect} path; source $path; -source DEFAULTS.expect; +source CRUISE_SETUP.expect; print_version; diff -r 99a41e0476b1 -r fda11de1826e reset1 --- a/reset1 Wed Jul 07 13:29:02 2010 -0400 +++ b/reset1 Tue Sep 14 13:34:39 2010 -0400 @@ -2,21 +2,22 @@ #====================================================================== # R E S E T 1 # doc: Mon Mar 8 02:57:35 2004 -# dlm: Wed Nov 19 15:17:32 2008 +# dlm: Thu Aug 26 00:29:22 2010 # (c) 2004 A.M. Thurnherr -# uE-Info: 21 14 NIL 0 0 72 2 2 4 NIL ofnI +# uE-Info: 18 39 NIL 0 0 72 2 2 8 NIL ofnI #====================================================================== # HISTORY: # Mar 8, 2004: - created # Nov 19, 2008: - added version - +# Aug 25, 2010: - DEFAULTS.expect -> CRUISE_SETUP.expect +# - libBB.expect -> libRDI.expect log_user 0; -regsub {dir1} [exec which dir1] {libBB.expect} path; +regsub {dir1} [exec which dir1] {libRDI.expect} path; source $path; -source DEFAULTS.expect; +source CRUISE_SETUP.expect; print_version; diff -r 99a41e0476b1 -r fda11de1826e reset2 --- a/reset2 Wed Jul 07 13:29:02 2010 -0400 +++ b/reset2 Tue Sep 14 13:34:39 2010 -0400 @@ -2,21 +2,22 @@ #====================================================================== # R E S E T 2 # doc: Mon Mar 8 02:57:35 2004 -# dlm: Wed Nov 19 15:17:48 2008 +# dlm: Thu Aug 26 00:29:29 2010 # (c) 2004 A.M. Thurnherr -# uE-Info: 11 26 NIL 0 0 72 2 2 4 NIL ofnI +# uE-Info: 18 39 NIL 0 0 72 2 2 8 NIL ofnI #====================================================================== # HISTORY: # Mar 8, 2004: - created # Nov 19, 2008: - added version - +# Aug 25, 2010: - DEFAULTS.expect -> CRUISE_SETUP.expect +# - libBB.expect -> libRDI.expect log_user 0; -regsub {dir1} [exec which dir1] {libBB.expect} path; +regsub {dir1} [exec which dir1] {libRDI.expect} path; source $path; -source DEFAULTS.expect; +source CRUISE_SETUP.expect; set_color; send_user "Connecting to instruments..."