author | A.M. Thurnherr <ant@ldeo.columbia.edu> |
Tue, 14 Sep 2010 13:34:39 -0400 | |
changeset 4 | fda11de1826e |
parent 0 | 648bde652211 |
child 5 | f41d45fe7ae9 |
permissions | -rwxr-xr-x |
0 | 1 |
#!/usr/bin/expect -f |
2 |
#====================================================================== |
|
3 |
# E N D L A D C P 1 |
|
4 |
# doc: Wed Mar 10 22:23:52 2004 |
|
4
fda11de1826e
version left on Poseidon at end of P403
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
0
diff
changeset
|
5 |
# dlm: Thu Aug 26 19:48:00 2010 |
0 | 6 |
# (c) 2004 A.M. Thurnherr |
4
fda11de1826e
version left on Poseidon at end of P403
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
0
diff
changeset
|
7 |
# uE-Info: 20 56 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 |
0 | 21 |
|
22 |
#---------------------------------------------------------------------- |
|
23 |
# Setup |
|
24 |
#---------------------------------------------------------------------- |
|
25 |
||
26 |
log_user 0; |
|
4
fda11de1826e
version left on Poseidon at end of P403
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
0
diff
changeset
|
27 |
source CRUISE_SETUP.expect; |
fda11de1826e
version left on Poseidon at end of P403
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
0
diff
changeset
|
28 |
regsub {dir1} [exec which dir1] {libRDI.expect} path; |
0 | 29 |
source $path; |
30 |
||
31 |
print_version; |
|
32 |
||
33 |
if ![file isdirectory $raw_dir] { |
|
34 |
error "directory $raw_dir does not exist"; |
|
35 |
} |
|
36 |
||
37 |
if {$argc != 0} { |
|
38 |
if {![affirm "downloading files to directory [lindex $argv 0] --- ok (y/N)? " 10]} { |
|
39 |
exit; |
|
40 |
} |
|
41 |
} |
|
42 |
||
43 |
#---------------------------------------------------------------------- |
|
44 |
# Get Station Number |
|
45 |
#---------------------------------------------------------------------- |
|
46 |
||
47 |
spawn bbabble -ms $tty0; |
|
48 |
||
49 |
set_color; |
|
50 |
send_user "Connecting to instrument..."; |
|
51 |
wait_for_startup; |
|
52 |
reset_instrument; |
|
53 |
||
54 |
send_user "\nGetting station number..."; |
|
55 |
set deployment_name [get_deployment_name]; |
|
56 |
if {[scan $deployment_name $master_deployment_name_fmt stn] != 1} { |
|
57 |
send_error "$deployment_name $master_deployment_name_fmt"; |
|
58 |
error "Can't get station number"; |
|
59 |
} |
|
60 |
set stnstr [format $stn_format $stn]; |
|
61 |
send_user "\[$stnstr\]"; |
|
62 |
||
63 |
set cast_dir [format %s/%s $raw_dir $stnstr]; |
|
64 |
if {![file isdirectory $cast_dir]} { |
|
65 |
put_to_sleep; |
|
66 |
error "cast directory $cast_dir does not exist!"; |
|
67 |
} |
|
68 |
regsub {^[^/]} [exec which bbabble] "[exec pwd]/&" bbabble; |
|
69 |
||
70 |
if {$argc == 1} { # override download directory |
|
71 |
set cast_dir [lindex $argv 0]; |
|
72 |
if {![file isdir $cast_dir]} {exec mkdir $cast_dir} |
|
73 |
} |
|
74 |
||
75 |
cd $cast_dir; |
|
76 |
if {[llength [glob -nocomplain {*.[0-9][0-9][0-9]}]] > 0} { |
|
77 |
put_to_sleep; |
|
78 |
error "cast directory [pwd] contains RDI data files!"; |
|
79 |
} |
|
80 |
||
81 |
send \004; |
|
82 |
||
83 |
#---------------------------------------------------------------------- |
|
84 |
# Download Data |
|
85 |
#---------------------------------------------------------------------- |
|
86 |
||
87 |
regsub {.*/} $argv0 {} basename; |
|
88 |
start_logging [format %s_%s.log $basename $stnstr]; |
|
89 |
||
4
fda11de1826e
version left on Poseidon at end of P403
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
0
diff
changeset
|
90 |
spawn $bbabble -msy $ymodem_receive_cmd $tty0; |
0 | 91 |
wait_for_startup; |
92 |
||
93 |
send_user "\nSaving hardware configuration..."; |
|
94 |
save_hardware_config [format %s000.LOG $deployment_name]; |
|
95 |
resume_logging [format %s_%s.log $basename $stnstr]; |
|
96 |
||
97 |
send_user "\nStarting download..."; |
|
98 |
start_download; |
|
99 |
||
100 |
send_user "\n"; |
|
101 |
set_color 0; |
|
102 |
log_user 1; wait_for_download_finish $stn $download_timeout; log_user 0; |
|
103 |
set_color; |
|
104 |
||
105 |
send_user "\nPutting instrument to sleep..."; |
|
106 |
put_to_sleep; |
|
107 |
||
108 |
send_user "\nChecking data file...\n"; |
|
109 |
set_color 0; |
|
110 |
check_data [format %s000.000 [format $master_deployment_name_fmt $stn]]; |
|
111 |
set_color; |
|
112 |
||
113 |
send_user "Backing up data file..."; |
|
114 |
backup_master_data $stn; |
|
115 |
||
116 |
send_user "\nDone\n" |