⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 catcher_init.tcl

📁 MTK平台抓日志log的工具,适用于MTK6225,6226以及6223等平台.
💻 TCL
字号:
#
#Disable Commands
#

proc package {args} {
	error "package is not supported by Catcher."
}	
proc load {args} {
	error "load is not supported by Catcher."
}	
proc exit {args} {
	error "Please use 'Exit' in the File Menu."
}
proc quit {args} {
	error "Please use 'Exit' in the File Menu."
}

#
#background errors
#
proc bgerror {args} {
	puts "Background Error"
	foreach msg $args {
	    puts $msg
	}
}

proc connect {args} {
	conn
}
proc disconnect {args} {
	disconn
}

#for query MMI Screen ID
proc qscrid {args} {
    conn
    logon MMI_L4C_SAP 4
    logon WAP_MMI_SAP 4
    
    cinst local_MSG_ID_TST_INJECT_STRING_1 tst_inject_string_struct  "{
    	ref_count = 0x1;
    	string\[0\] = 0x6d;
    	string\[10\] = 0x3f;
    	string\[1\] = 0x74;
    	string\[2\] = 0x6b;
    	string\[3\] = 0x2b;
    	string\[4\] = 0x73;
    	string\[5\] = 0x63;
    	string\[6\] = 0x72;
    	string\[7\] = 0x6e;
    	string\[8\] = 0x69;
    	string\[9\] = 0x64;
    };"
    
    cinst ilm_MSG_ID_TST_INJECT_STRING_1 ilmessage "{
    	src_mod_id = MOD_NIL;
    	dest_mod_id = MOD_MMI;
    	sap_id = INVALID_SAP;
    	msg_id = MSG_ID_TST_INJECT_STRING;
    	local_params.local_params_ptr = local_MSG_ID_TST_INJECT_STRING_1;
    	peer_buff.peer_buff_ptr = NULL;
    };"
        
    set bh [bwait msgcode==MSG_ID_MMI_INJECT_STRING_RSP {convert_mmi_scr_id 0x[getfldvalfromstream_local [getfldvalue waitMsgMSG_ID_MMI_INJECT_STRING_RSP local_params.local_params_ptr ilmessage] scrnid mmi_inject_string_rsp_struct]}]
    injectmsg ilm_MSG_ID_TST_INJECT_STRING_1
    after 500
    killbwait $bh        
}




#for l1v
proc l1v_testcase {case pattern patternsize} {    
    
    foreach i [after info] {after cancel $i}
    deleteallwaitmsg
    cinst l1v_local ul1d_loopback_req_struct "{        
        test_id=1; case_id=$case; pattern_id=$pattern; pattern_size=$patternsize;        
    };"
    
    cinst l1v_ilm ilmessage "{
        src_mod_id = MOD_MPAL; dest_mod_id = MOD_MPAL; 
        sap_id = MPAL_L1_SAP; msg_id = MSG_ID_UL1D_LOOPBACK_REQ;
    	local_params.local_params_ptr = l1v_local; peer_buff.peer_buff_ptr = NULL;        
    };"
    
    set abort_handle [after 20000 {puts "Abort Timer Timeout!! Test Case Terminated!!";global g_e;set g_e 2}]
    puts "MSG_ID_UL1D_LOOPBACK_REQ --->|"
    after idle injectmsg l1v_ilm
    xwait msgcode==MSG_ID_UL1D_LOOPBACK_RESULT_IND {puts "|-->MSG_ID_UL1D_LOOPBACK_RESULT_IND";global g_e;set g_e 1}    
    vwait g_e
    killallwait
    after cancel $abort_handle
    if {1 != [checkmsg waitMsgMSG_ID_UL1D_LOOPBACK_RESULT_IND_1]} then {error "Fail to wait MSG_ID_UL1D_LOOPBACK_RESULT_IND"}
    
    set localbuf [getfldvalue waitMsgMSG_ID_UL1D_LOOPBACK_RESULT_IND_1 local_params.local_params_ptr ilmessage]
    set ret_case [getfldvalfromstream_local $localbuf case_id ul1d_loopback_result_ind_struct]
    set ret_pattern [getfldvalfromstream_local $localbuf pattern_id ul1d_loopback_result_ind_struct]
    if {$ret_case != $case} then {error "Invalid Case ID Return!"}
    if {$ret_pattern != $pattern} then {error "Invalid Pattern ID Return!"}    
}

#for umts
proc ul1v_testcase {case p0 p1 p2 p3 p4 p5 p6 p7 p8 p9 s0 s1 s2 s3 s4 s5 s6 s7 s8 s9 s10 s11 s12 s13 s14 s15 s16 s17 s18 s19 a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19} {
    
    foreach i [after info] {after cancel $i}
    deleteallwaitmsg
    cinst l1v_local ul1d_loopback_req_struct "{ 
        ref_count=1;       
        test_id=2; case_id=$case;       
        pm\[0\]=$p0; pm\[1\]=$p1; pm\[2\]=$p2; pm\[3\]=$p3; pm\[4\]=$p4; pm\[5\]=$p5; 
        pm\[6\]=$p6; pm\[7\]=$p7; pm\[8\]=$p8; pm\[9\]=$p9;
        sz\[0\]=$s0; sz\[1\]=$s1; sz\[2\]=$s2; sz\[3\]=$s3; sz\[4\]=$s4; sz\[5\]=$s5; 
        sz\[6\]=$s6; sz\[7\]=$s7; sz\[8\]=$s8; sz\[9\]=$s9;
        sz\[10\]=$s10; sz\[11\]=$s11; sz\[12\]=$s12; sz\[13\]=$s13; sz\[14\]=$s14; sz\[15\]=$s15; 
        sz\[16\]=$s16; sz\[17\]=$s17; sz\[18\]=$s18; sz\[19\]=$s19;
        ad\[0\]=$a0; ad\[1\]=$a1; ad\[2\]=$a2; ad\[3\]=$a3; ad\[4\]=$a4; ad\[5\]=$a5; 
        ad\[6\]=$a6; ad\[7\]=$a7; ad\[8\]=$a8; ad\[9\]=$a9;                  
        ad\[10\]=$a10; ad\[11\]=$a11; ad\[12\]=$a12; ad\[13\]=$a13; ad\[14\]=$a14; ad\[15\]=$a15; 
        ad\[16\]=$a16; ad\[17\]=$a17; ad\[18\]=$a18; ad\[19\]=$a19;                  
    };"
    
    cinst l1v_ilm ilmessage "{
        src_mod_id = MOD_URR; dest_mod_id = MOD_URR; 
        sap_id = UL1_UL1_SAP; msg_id = MSG_ID_UL1D_LOOPBACK_REQ;
    	local_params.local_params_ptr = l1v_local; peer_buff.peer_buff_ptr = NULL;        
    };"
    
    set abort_handle [after 20000 {puts "Abort Timer Timeout!! Test Case Terminated!!";global g_e;set g_e 2}]
    puts "MSG_ID_UL1D_LOOPBACK_REQ --->|"
    after idle injectmsg l1v_ilm
    xwait msgcode==MSG_ID_UL1D_LOOPBACK_RESULT_IND {puts "|-->MSG_ID_UL1D_LOOPBACK_RESULT_IND";global g_e;set g_e 1}    
    vwait g_e
    killallwait
    after cancel $abort_handle
    if {1 != [checkmsg waitMsgMSG_ID_UL1D_LOOPBACK_RESULT_IND_1]} then {error "Fail to wait MSG_ID_UL1D_LOOPBACK_RESULT_IND"}
    
    set localbuf [getfldvalue waitMsgMSG_ID_UL1D_LOOPBACK_RESULT_IND_1 local_params.local_params_ptr ilmessage]
    set ret_case [getfldvalfromstream_local $localbuf case_id ul1d_loopback_result_ind_struct]
    set ret_result [getfldvalfromstream_local $localbuf result ul1d_loopback_result_ind_struct]
    if {$ret_case != $case} then {error "Invalid Case ID $case Return!"}
    if {$ret_result == 0} then {
        global uL1vStopFlag
        if {$uL1vStopFlag == 1} then {error "$case: Target Return Fail!!"} else {puts "$case: Target Return Fail!"}
    }
            
}


proc read_file {filename} {

global VoipFilePath
set filename "$VoipFilePath\\$filename"
set fd [open $filename]
fconfigure $fd -translation binary
set buf [read $fd]
close $fd

foreach i [info globals RunTime*] {global $i}
set buf [subst $buf]
binary scan $buf c* tempbuf
set buf [string map {{ } {,}} $tempbuf]

return $buf

}

proc at_wait {com_port wait_command run_proc} {
    append atwait_listname atwait_list $com_port
    global $atwait_listname
    lappend $atwait_listname $wait_command
    
    append atproc_listname atproc_list $com_port
    global $atproc_listname
    lappend $atproc_listname $run_proc
}

proc process_atwait_list {com_port at_str} {

    append atwait_listname atwait_list $com_port
    global $atwait_listname
    
    if {0==[llength [subst $[subst $atwait_listname]]]} then {return 0}
    
    global exclue_at_command_list
    if {[lsearch -exact $exclue_at_command_list $at_str] != -1} then {
    	puts "$at_str is in exclue_at_command_list"
    	return [llength [subst $[subst $atwait_listname]]]
    }
    
    set first_ele [lindex [subst $[subst $atwait_listname]] 0]
    
    if {$first_ele == $at_str} then {
       puts "Match $at_str in $atwait_listname"
    } elseif {1==[string equal -length 7 $first_ele "RunTime"]} then {
       foreach i [info globals RunTime*] {global $i}
       puts "Assign $at_str to $first_ele"
       set $first_ele $at_str
    } else {return [llength [subst $[subst $atwait_listname]]]}    
    
    append atproc_listname atproc_list $com_port
    global $atproc_listname
    set first_ele [lindex [subst $[subst $atproc_listname]] 0]
    
    #remove the first element
    set $atwait_listname [lreplace [subst $[subst $atwait_listname]] 0 0]
    set $atproc_listname [lreplace [subst $[subst $atproc_listname]] 0 0]
    
    #run the procedure
    puts "Run: $first_ele"
    eval $first_ele
    
    return [llength [subst $[subst $atwait_listname]]]
 
}

proc read_com_port {com_port com_handle} {
	
    set read_buf [read $com_handle]
    if {[string bytelength $read_buf] != 0} then {
	append atrbufname atrbuf $com_port
	global $atrbufname    
	#append the last read
	set rbuf [subst $[subst $atrbufname]]
	    
	append rbuf $read_buf   
	set rbuf_size [string bytelength $rbuf]
	#if {$rbuf_size != 0} then { puts "read $com_port $rbuf_size:[string map {\xd _ \xa _} $rbuf]" }
	    
	set lf_count 0
	set lf_index 0
	set process_index 0
	for {set i 0} {$i<$rbuf_size} {incr i} {    	
	    if {[string index $rbuf $i] == "\xa"} then {
	    	incr lf_count
	    	if {$lf_count == 1} then {
	     	    set lf_index $i
	    	} elseif {$lf_count == 2} then {    	   
	       	    set process_index $i
	       	    set got_at_string [string range $rbuf [expr $lf_index+1] [expr $process_index-2]]
	       	    puts "Got $com_port: $got_at_string"
	       	    set ret [process_atwait_list $com_port $got_at_string]
	       	    if {$ret==0} {
	       	        puts "at_wait list empty. done!"
	       	        set $atrbufname ""
	       	        #prepare for next read!    
    			after 60 "read_com_port $com_port $com_handle"
	       	        return
	       	    }
	       	    set lf_count 0    	   	
	        }
	    } 
	    ##end if \xa   
	}
	##end for
	set $atrbufname [string range $rbuf [expr $process_index+1] end]
    }  
    ##end if read_buf
    
    #prepare for next read!    
    after 60 "read_com_port $com_port $com_handle"
}


proc check_fail_case {msc_file} {

#The procedure will be called for a fail case when running MSC Composer test case list
#Users can customize the tcl procedure and reload catcher again.
#for example reset target and run the test case again:

#rebootm
#if {[catch {source $msc_file} fid]} then {puts $fid; return 1}
#exec xxx.bat

#return 1 to stop running the remain cases
#return 0 to continue the remain cases
return 0

}

proc error_handler {msc_name count err_string } {

#The procedure will be called when a tcl error occured
#Users can customize the tcl procedure and reload catcher again.
#for example record the error in a csv file.

#set fr [open report.csv a+]
#puts $fr "\"$msc_name\",\"$count\",\"$err_string\""
#close $fr

#return 1 to stop the next round
#return 0 to continue the next round if exist
return 1

}


set L1vPatternPath "d:\\upload"
set L1vReportPath "d:\\upload"

set uL1vPatternPath "d:\\upload"
set uL1vStopFlag 0

set VoipFilePath "d:\\upload"

set exclue_at_command_list [list "ABC" "XYZ"]

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -