-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtps_cpython_script.tcl
83 lines (67 loc) · 2.62 KB
/
tps_cpython_script.tcl
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
72
73
74
75
76
77
78
79
80
81
82
83
######################################################################
# Name: tps_cpython_script
# Purpose: <description>
# UPoC type: tps
# Args: tps keyedlist containing the following keys:
# MODE run mode ("start", "run", "time" or "shutdown")
# MSGID message handle
# CONTEXT tps caller context
# ARGS user-supplied arguments:
# <describe user-supplied args here>
#
# Returns: tps disposition list:
# <describe dispositions used here>
#
# Notes: <put your notes here>
#
# History: <date> <name> <comments>
#
proc tps_cpython_script { args } {
global HciConnName ;# Name of thread
keylget args MODE mode ;# Fetch mode
set ctx "" ; keylget args CONTEXT ctx ;# Fetch tps caller context
set uargs {} ; keylget args ARGS uargs ;# Fetch user-supplied args
set debug 0 ; ;# Fetch user argument DEBUG and
catch {keylget uargs DEBUG debug} ;# assume uargs is a keyed list
set module "tps_david/$HciConnName/$ctx" ;# Use this before every echo/puts,
;# it describes where the text came from
set dispList {} ;# Nothing to return
switch -exact -- $mode {
start {
# Perform special init functions
# N.B.: there may or may not be a MSGID key in args
if { $debug } {
puts stdout "$module: Starting in debug mode..."
}
load $::HciSiteDir/bin/libpytps[info sharedlibextension]
set uargs [keylget args ARGS]
set script [keylget uargs SCRIPT]
keyldel uargs SCRIPT
keylset args ARGS $uargs
#echo calling py_tps_proc_init $script $args
py_tps_proc_init $script $args
}
run {
# 'run' mode always has a MSGID; fetch and process it
keylget args MSGID mh
set uargs [keylget args ARGS]
set script [keylget uargs FUNCTION]
keyldel uargs SCRIPT
keyldel uargs FUNCTION
keylset args ARGS $uargs
echo calling py_tps_proc $script $args
return [py_tps_proc $script $args]
}
time {
# Timer-based processing
# N.B.: there may or may not be a MSGID key in args
}
shutdown {
# Doing some clean-up work
}
default {
error "Unknown mode '$mode' in $module"
}
}
return $dispList
}