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