author | A.M. Thurnherr <athurnherr@yahoo.com> |
Fri, 03 Jul 2020 10:25:08 -0400 | |
changeset 12 | 5e67754f6457 |
parent 4 | fda11de1826e |
permissions | -rwxr-xr-x |
0 | 1 |
#!/usr/bin/expect -f |
2 |
#====================================================================== |
|
3 |
# L A D C P _ S E N D _ C M D |
|
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:
4
diff
changeset
|
5 |
# dlm: Fri Jul 3 10:17:16 2020 |
0 | 6 |
# (c) 2004 A.M. Thurnherr |
12
5e67754f6457
V1.6: no more master/slave terminology
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
7 |
# uE-Info: 104 0 NIL 0 0 72 2 2 8 NIL ofnI |
0 | 8 |
#====================================================================== |
9 |
||
10 |
# HISTORY: |
|
11 |
# Apr 4, 2004: - adapted from [ladcp1] |
|
12 |
# Feb 14, 2006: - BUG: log files were written to bin dir |
|
13 |
# Nov 6, 2006: - adapted to old regsub |
|
14 |
# Nov 19, 2008: - adapted to new firmware behavior (load_factory_defaults) |
|
15 |
# 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
|
16 |
# 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
|
17 |
# - libBB.expect -> libRDI.expect |
12
5e67754f6457
V1.6: no more master/slave terminology
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
18 |
# Jul 3, 2020: - expunged master/slave terminology |
0 | 19 |
|
20 |
#---------------------------------------------------------------------- |
|
21 |
# Setup |
|
22 |
#---------------------------------------------------------------------- |
|
23 |
||
24 |
log_user 0; |
|
4
fda11de1826e
version left on Poseidon at end of P403
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
0
diff
changeset
|
25 |
source CRUISE_SETUP.expect; |
fda11de1826e
version left on Poseidon at end of P403
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
0
diff
changeset
|
26 |
regsub {dir1} [exec which dir1] {libRDI.expect} path; |
0 | 27 |
source $path; |
28 |
||
29 |
print_version; |
|
30 |
||
31 |
if {$argc != 2} { |
|
32 |
error "Usage: $argv0 <tty port> <cmd-file>" |
|
33 |
} |
|
34 |
if {![file isfile [lindex $argv 1]]} { |
|
35 |
error "[lindex $argv 1]: no such file" |
|
36 |
} |
|
37 |
||
38 |
set ask 1; |
|
39 |
if {[file isfile .last_stn]} { |
|
40 |
set stn [format $stn_format [expr [exec cat .last_stn] + 1]]; |
|
41 |
if {[affirm "Use station number $stn? (y/N) " 10]} { |
|
42 |
set ask 0; |
|
43 |
} |
|
44 |
} |
|
45 |
if {$ask == 1} { |
|
46 |
set stn [format $stn_format [input_int "Station number = "]]; |
|
47 |
} |
|
48 |
||
49 |
if ![file isdirectory $raw_dir] { |
|
50 |
error "directory $raw_dir does not exist"; |
|
51 |
} |
|
52 |
set cast_dir [format %s/%s $raw_dir $stn]; |
|
53 |
if [file isdirectory $cast_dir] { |
|
54 |
error "data directory $cast_dir already exists!"; |
|
55 |
} |
|
56 |
set prev_cast_dir [format %s/%s $raw_dir [expr $stn - 1]]; |
|
57 |
if {![file isdirectory $prev_cast_dir]} { |
|
58 |
if {![affirm "WARNING: previous-station data directory $prev_cast_dir does not exist --- are you sure the station number $stn is ok? (y/N) " 10]} { |
|
59 |
send_error "$argv0 aborted\n"; |
|
60 |
exit 0; |
|
61 |
} |
|
62 |
} |
|
63 |
||
64 |
#---------------------------------------------------------------------- |
|
65 |
# Deploy LADCP |
|
66 |
#---------------------------------------------------------------------- |
|
67 |
||
68 |
set_color; |
|
69 |
send_user "Connecting to instrument..."; |
|
70 |
spawn bbabble -ms [lindex $argv 0]; |
|
71 |
wait_for_startup; |
|
72 |
reset_instrument; |
|
73 |
if {![memory_empty]} { |
|
74 |
if {![affirm "\nWARNING: Memory is not empty; continue anyway? (y/N) " 10 1]} { |
|
75 |
send_user "Putting instrument to sleep..."; |
|
76 |
put_to_sleep; |
|
77 |
send_user "\nDone\n"; |
|
78 |
exit; |
|
79 |
} |
|
80 |
} else { |
|
81 |
send_user "\n"; |
|
82 |
} |
|
83 |
||
84 |
exec mkdir $cast_dir; |
|
85 |
exec cp [lindex $argv 1] $cast_dir; |
|
86 |
exec echo $stn > .last_stn; |
|
87 |
cd $cast_dir; |
|
88 |
||
89 |
if {![file isfile [lindex $argv 1]]} { |
|
90 |
error "Failed to copy [lindex $argv 1] to [pwd]"; |
|
91 |
} |
|
92 |
||
93 |
regsub {.*/} $argv0 {} basename; |
|
94 |
start_logging [format %s_%03d.log $basename $stn]; |
|
95 |
||
96 |
send_user "Resetting instrument to factory defaults..."; |
|
97 |
load_factory_defaults; |
|
98 |
||
99 |
send_user "Setting instrument clock..."; |
|
100 |
set_computer_time; |
|
101 |
set_instrument_clock; |
|
102 |
||
103 |
send_user "\nSetting deployment name..."; |
|
12
5e67754f6457
V1.6: no more master/slave terminology
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
4
diff
changeset
|
104 |
set_deployment_name [format $DL_deployment_name_fmt $stn]; |
0 | 105 |
|
106 |
send_user "\nUploading command file"; |
|
107 |
upload_file [lindex $argv 1] [format %s_log [lindex $argv 1]] "DEPLOY.hwconfig"; |
|
108 |
||
109 |
send_user "\nDone\n"; |