author | A.M. Thurnherr <athurnherr@yahoo.com> |
Fri, 03 Jul 2020 10:25:08 -0400 | |
changeset 12 | 5e67754f6457 |
parent 11 | c39e37d59638 |
permissions | -rwxr-xr-x |
0 | 1 |
#!/usr/bin/expect -f |
2 |
#====================================================================== |
|
12
5e67754f6457
V1.6: no more master/slave terminology
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
11
diff
changeset
|
3 |
# E N D L A D C P 1 |
0 | 4 |
# doc: Wed Mar 10 22:23:52 2004 |
12
5e67754f6457
V1.6: no more master/slave terminology
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
11
diff
changeset
|
5 |
# dlm: Fri Jul 3 10:15:18 2020 |
0 | 6 |
# (c) 2004 A.M. Thurnherr |
12
5e67754f6457
V1.6: no more master/slave terminology
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
11
diff
changeset
|
7 |
# uE-Info: 123 9 NIL 0 0 72 2 2 8 NIL ofnI |
0 | 8 |
#====================================================================== |
9 |
||
10 |
# HISTORY: |
|
11 |
# Apr 4, 2004: - adapted from [endladcp2] |
|
12 |
# Jun 18, 2004: - BUG: could not handle station 008 (illegal octal digit) |
|
13 |
# Jan 25, 2005: - BUG: bbabble could not be in relative path (on MacOSX) |
|
14 |
# Feb 14, 2006: - BUG: log files were written to bin dir |
|
15 |
# Oct 4, 2006: - adapted to older expect version |
|
16 |
# Oct 28, 2006: - allowed for lrb downcasing filenames |
|
17 |
# Nov 19, 2008: - added version |
|
4
fda11de1826e
version left on Poseidon at end of P403
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
0
diff
changeset
|
18 |
# Aug 25, 2010: - DEFAULTS.expect -> CRUISE_SETUP.expect |
fda11de1826e
version left on Poseidon at end of P403
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
0
diff
changeset
|
19 |
# - libBB.expect -> libRDI.expect |
fda11de1826e
version left on Poseidon at end of P403
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
0
diff
changeset
|
20 |
# Aug 26, 2010: - added support for ymodem_download_cmd |
5 | 21 |
# Dec 1, 2010: - BUG: ymodem_receive_cmd instead of ymodem_download_cmd |
11 | 22 |
# Nov 10, 2013: - added dir listing before downlaod |
12
5e67754f6457
V1.6: no more master/slave terminology
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
11
diff
changeset
|
23 |
# Jul 3, 2020: - expunged master/slave terminology |
0 | 24 |
|
25 |
#---------------------------------------------------------------------- |
|
26 |
# Setup |
|
27 |
#---------------------------------------------------------------------- |
|
28 |
||
29 |
log_user 0; |
|
4
fda11de1826e
version left on Poseidon at end of P403
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
0
diff
changeset
|
30 |
source CRUISE_SETUP.expect; |
fda11de1826e
version left on Poseidon at end of P403
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
0
diff
changeset
|
31 |
regsub {dir1} [exec which dir1] {libRDI.expect} path; |
0 | 32 |
source $path; |
33 |
||
34 |
print_version; |
|
35 |
||
36 |
if ![file isdirectory $raw_dir] { |
|
37 |
error "directory $raw_dir does not exist"; |
|
38 |
} |
|
39 |
||
40 |
if {$argc != 0} { |
|
41 |
if {![affirm "downloading files to directory [lindex $argv 0] --- ok (y/N)? " 10]} { |
|
42 |
exit; |
|
43 |
} |
|
44 |
} |
|
45 |
||
46 |
#---------------------------------------------------------------------- |
|
11 | 47 |
# List Directory Contents |
0 | 48 |
#---------------------------------------------------------------------- |
49 |
||
50 |
spawn bbabble -ms $tty0; |
|
51 |
||
52 |
set_color; |
|
53 |
send_user "Connecting to instrument..."; |
|
54 |
wait_for_startup; |
|
55 |
reset_instrument; |
|
56 |
||
11 | 57 |
send_user "\n"; list_dir; |
58 |
||
59 |
#---------------------------------------------------------------------- |
|
60 |
# Get Station Number & Carry Out Sanity Checks |
|
61 |
#---------------------------------------------------------------------- |
|
62 |
||
0 | 63 |
send_user "\nGetting station number..."; |
64 |
set deployment_name [get_deployment_name]; |
|
12
5e67754f6457
V1.6: no more master/slave terminology
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
11
diff
changeset
|
65 |
if {[scan $deployment_name $DL_deployment_name_fmt stn] != 1} { |
5e67754f6457
V1.6: no more master/slave terminology
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
11
diff
changeset
|
66 |
send_error "$deployment_name $DL_deployment_name_fmt"; |
0 | 67 |
error "Can't get station number"; |
68 |
} |
|
69 |
set stnstr [format $stn_format $stn]; |
|
70 |
send_user "\[$stnstr\]"; |
|
71 |
||
72 |
set cast_dir [format %s/%s $raw_dir $stnstr]; |
|
73 |
if {![file isdirectory $cast_dir]} { |
|
74 |
put_to_sleep; |
|
75 |
error "cast directory $cast_dir does not exist!"; |
|
76 |
} |
|
77 |
regsub {^[^/]} [exec which bbabble] "[exec pwd]/&" bbabble; |
|
78 |
||
79 |
if {$argc == 1} { # override download directory |
|
80 |
set cast_dir [lindex $argv 0]; |
|
81 |
if {![file isdir $cast_dir]} {exec mkdir $cast_dir} |
|
82 |
} |
|
83 |
||
84 |
cd $cast_dir; |
|
85 |
if {[llength [glob -nocomplain {*.[0-9][0-9][0-9]}]] > 0} { |
|
86 |
put_to_sleep; |
|
87 |
error "cast directory [pwd] contains RDI data files!"; |
|
88 |
} |
|
89 |
||
90 |
send \004; |
|
91 |
||
92 |
#---------------------------------------------------------------------- |
|
93 |
# Download Data |
|
94 |
#---------------------------------------------------------------------- |
|
95 |
||
96 |
regsub {.*/} $argv0 {} basename; |
|
97 |
start_logging [format %s_%s.log $basename $stnstr]; |
|
98 |
||
4
fda11de1826e
version left on Poseidon at end of P403
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
0
diff
changeset
|
99 |
spawn $bbabble -msy $ymodem_receive_cmd $tty0; |
0 | 100 |
wait_for_startup; |
101 |
||
102 |
send_user "\nSaving hardware configuration..."; |
|
103 |
save_hardware_config [format %s000.LOG $deployment_name]; |
|
104 |
resume_logging [format %s_%s.log $basename $stnstr]; |
|
105 |
||
106 |
send_user "\nStarting download..."; |
|
107 |
start_download; |
|
108 |
||
109 |
send_user "\n"; |
|
110 |
set_color 0; |
|
111 |
log_user 1; wait_for_download_finish $stn $download_timeout; log_user 0; |
|
112 |
set_color; |
|
113 |
||
114 |
send_user "\nPutting instrument to sleep..."; |
|
115 |
put_to_sleep; |
|
116 |
||
117 |
send_user "\nChecking data file...\n"; |
|
118 |
set_color 0; |
|
12
5e67754f6457
V1.6: no more master/slave terminology
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
11
diff
changeset
|
119 |
check_data [format %s000.000 [format $DL_deployment_name_fmt $stn]]; |
0 | 120 |
set_color; |
121 |
||
122 |
send_user "Backing up data file..."; |
|
12
5e67754f6457
V1.6: no more master/slave terminology
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
11
diff
changeset
|
123 |
backup_DL_data $stn; |
0 | 124 |
|
125 |
send_user "\nDone\n" |