-
Notifications
You must be signed in to change notification settings - Fork 1
/
tf-init.expect
executable file
·71 lines (66 loc) · 1.86 KB
/
tf-init.expect
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/expect
#script to set TF TNC to KISS mode
#2014-08-30 Owen Duffy
encoding system iso8859-1
source [file dirname [info script]]/log.expect
set line "\n***** "
append line [timestamp -format "%Y-%m-%d %H:%M:%S" -gmt]
append line " $argv0 starting...\n\n"
send_log $line
#set port /dev/ttyUSB0
set port [lindex $argv 0]
set spawned [spawn -open [open $port RDWR]]
set baud 9600
# -parenb means don't use a parity bit
# -cstopb means "not 2 stop bits, but 1"
# cs8 means 8 bits
# -echo means no echo (full duplex?)
stty ispeed $baud ospeed $baud raw -echo cs8 -parenb -cstopb -onlcr < $port
set timeout 1
#probe for command prompt
#flush buffer
expect -re $
send "\r"
expect {
-ex "* " {
send_log "\nStart KISS...\n"
send "\x1b@K\r"
sleep 2
send_log "\nConfigure KISS...\n"
send "\xc0\x01\x10\xc0\x02\x40\xc0\x03\x0a\xc0\x04\x02\xc0"
send_log "\nAll done!\n"
send_log "==========================================================\n"
exit
}
timeout {
send_log "\nTry to end KISS mode (could be in SMACK)...\n"
set timeout 10
#flush buffer
expect -re $
send "\xc0\xff\xc0"
expect {
"Checksum" {
send_log "\nStart KISS...\n"
send "\r"
set timeout 1
send_log "\nStart KISS 2...\n"
send "\x1b@K\r"
sleep 1
send_log "\nConfigure KISS...\n"
send "\xc0\x01\x10\xc0\x02\x40\xc0\x03\x0a\xc0\x04\x02\xc0"
send_log "\nAll done!\n"
send_log "==========================================================\n"
exit
}
timeout {
set timeout 1
send_log "\nSomething wrong here...\n"
send_log "==========================================================\n"
exit 1
}
}
}
}
send_log "\nUnexpected exit...\n"
send_log "==========================================================\n\n"
exit 2