Add find_sicsdev and find_myobject functions

This commit is contained in:
Douglas Clowes
2014-04-23 16:26:30 +10:00
parent 93276478f5
commit 46599051d9

View File

@@ -59,3 +59,46 @@ proc ::scobj::hinitprops {scobj args} {
}
}
}
##
# @brief find the node with property 'sicsdev' matching the given name
# start at top (or path) and work down
# @param name, the name of the device we are looking for (e.g. 'tc1')
# @param path, optional starting path (e.g. '/sample')
proc ::scobj::find_sicsdev {name {path "/"}} {
foreach node [hlist ${path}] {
if { [hpropexists ${path}/${node} sicsdev] } {
if { [string match -nocase "${name}" "[hgetpropval ${path}/${node} sicsdev]" } {
return [string map {// /} ${path}/${node}]
}
}
set result [find_dev ${name} ${path}/${node}]
if { ${result} != "" } {
return [string map {// /} ${result}]
}
}
return ""
}
##
# @brief find the node with the property 'type' matching 'sct_object'
# start at the bottom and work up
# @param path, the path of the node where we start looking (e.g. '[sct]')
proc ::scobj::find_myobject {{path ""}} {
if { [string length "${path}"] == 0 } {
if { [catch {
set path "[sct]"
} catch_message] } {
set path ""
}
}
while { [string length ${path}] > 1 } {
if { [hpropexists ${path} type] } {
if { [string match -nocase "sct_object" "[hgetpropval ${path} type]"] } {
return [string map {// /} ${path}]
}
}
set path [pathname ${path}]
}
return ""
}