📄 ssp_debug.c
字号:
{ if( NULL_SOCKET == x_send_sock ) { x_send_sock = socket(AF_INET, SOCK_DGRAM,IPPROTO_UDP); } addr.sin_stAddr.s_ulAddr = dbg_frame_p->debuger_ip_addr; addr.sin_usPort = dbg_frame_p->debuger_port_agnt; sendto( x_send_sock, (S8*)&dbg_frame_p->dstProcessorId, AOS_NTOHS(dbg_frame_p->length), 0, &addr, sizeof(SOCKADDRIN_S) ); } else if( TRANS_TO_ADA_CLI == dbg_frame_p->is_to_borad ) {#if( AOS_INCLUDE_SMP_CLI == TRUE ) cli_out_string( AOS_HTONL(dbg_frame_p->debuger_ip_addr), dbg_frame_p->u.printmsg.str );#endif } aos_dmem_free( (VOID*)mb->head ); msg_free( mb ); aos_task_yield_time(); } }}VOID x_sock_rcv_task(){ S32 iFd; SOCKADDRIN_S addr; S32 iRet, Len = sizeof(SOCKADDRIN_S); struct dbg_frame_s *debugp; struct dbg_frame_s *new_debugp; U32 dbg_dst_processor_id; U16 dbg_msg_len; MSG_S msg; debugp = (struct dbg_frame_s*)aos_msg_alloc(MPE_DEBUG, sizeof( struct dbg_frame_s ) ); if( NULL == debugp ) { return; } aos_memset(&addr,0,sizeof(SOCKADDRIN_S)); addr.sin_chFamily = AF_INET; addr.sin_usPort = AOS_HTONS(CONFIG_DEBUG_UDP_PORT); addr.sin_stAddr.s_ulAddr = 0; iFd = socket(AF_INET, SOCK_DGRAM,IPPROTO_UDP); if( iFd < 0 ) { return; } if( bind(iFd,&addr,sizeof(SOCKADDRIN_S)) < 0 ) { return; } for(;;) { iRet = recvfrom(iFd, (S8*)&debugp->dstProcessorId, (S32)(sizeof(struct dbg_frame_s)-DBG_RESV_HEAD_LEN), 0, &addr , &Len); if( iRet <= 0) { aos_task_delay(1); continue; } new_debugp = (struct dbg_frame_s*)aos_msg_alloc(MPE_DEBUG, sizeof( struct dbg_frame_s ) ); if( NULL == new_debugp ) { continue; } dbg_dst_processor_id = AOS_NTOHL( debugp->dstProcessorId ); dbg_msg_len = AOS_NTOHS(debugp->length); if( dbg_msg_len != iRet ) { continue; } debugp->debuger_ip_addr = addr.sin_stAddr.s_ulAddr; debugp->is_to_borad = TRANS_TO_BOARD; msg.srcProcessorId = LOCAL_PROCESSOR_ID; msg.srcMpe = MPE_DEBUG; msg.dstProcessorId = dbg_dst_processor_id; msg.dstMpe = MPE_DEBUG; msg.msgPrio = MSG_PRIO_NORMAL; msg.ulSize = dbg_msg_len + sizeof(U32)+sizeof(U16)+sizeof(U16); msg.pvMsgBuf = (VOID*)debugp; aos_msg_trysend( &msg ); debugp = new_debugp; }}VOID debug_convert_byte_order( struct dbg_frame_s *debugp ){ AOS_ASSERT( NULL != debugp ); debugp->dstProcessorId = AOS_NTOHL(debugp->dstProcessorId); debugp->length = AOS_NTOHS(debugp->length); switch( debugp->cmd ) { case DEBUG_CMD: debugp->u.cmdmsg.para[0] = AOS_NTOHL( debugp->u.cmdmsg.para[0] ); debugp->u.cmdmsg.para[1] = AOS_NTOHL( debugp->u.cmdmsg.para[1] ); debugp->u.cmdmsg.para[2] = AOS_NTOHL( debugp->u.cmdmsg.para[2] ); debugp->u.cmdmsg.para[3] = AOS_NTOHL( debugp->u.cmdmsg.para[3] ); break; case DEBUG_L3_MSG: debugp->u.l3msg.srcProcessorId = AOS_NTOHL( debugp->u.l3msg.srcProcessorId ); debugp->u.l3msg.srcMpe = AOS_NTOHL( debugp->u.l3msg.srcMpe ); debugp->u.l3msg.dstProcessorId = AOS_NTOHL( debugp->u.l3msg.dstProcessorId ); debugp->u.l3msg.dstMpe = AOS_NTOHL( debugp->u.l3msg.dstMpe ); debugp->u.l3msg.length = AOS_NTOHL( debugp->u.l3msg.length ); debugp->u.l3msg.link_type = AOS_NTOHL( debugp->u.l3msg.link_type ); debugp->u.l3msg.comportno = AOS_NTOHL( debugp->u.l3msg.comportno ); break; case DEBUG_L2_MSG: debugp->u.l2msg.portno = AOS_NTOHL( debugp->u.l2msg.portno ); break; case DEBUG_SHAKEHAND: case DEBUG_GOODBYE: break; case DEBUG_SHOW: aos_printf( MPE_DEBUG,"Unexpected print message" ); break; default: aos_printf( MPE_DEBUG, "Unknown debug cmd=%d", debugp->cmd ); break; }}VOID debug_output( struct dbg_frame_s *debugp ){ struct msg_blk *mb; if( U32_BUTT == print_task_id ) { return; } mb = msg_alloc( ); if( NULL == mb ) { return; } mb->head = (U8*)mem_obj_head(debugp); mb->truelen = mem_obj_size(debugp); mb->end = mb->head + mb->truelen; mb->data = (U8*)debugp; mb->len = debugp->length; mb->tail = mb->data + mb->len; aos_dmem_ref_inc((VOID*)mb->head); msg_que_tail( &x_print_que, mb ); aos_event_post( print_task_id,1 );}VOID debug_cmdmsg_handle( struct dbg_cmd_s *cmdmsgp ){ AOS_ASSERT( NULL != cmdmsgp ); switch( cmdmsgp->subcmd ) { case DEBUG_SUB_CMD: if( AOS_SUCC != ssp_mpe_msg_verify(cmdmsgp->mpe) ) { aos_printf( MPE_DEBUG,"mpe=%d invalid", cmdmsgp->mpe ); } if( MPE_DEBUG == cmdmsgp->mpe ) { debug_own_cmd_handle( cmdmsgp->para[0], cmdmsgp->para[1], cmdmsgp->para[2], cmdmsgp->para[3] ); } else { struct debug_msg_s *local_debug_p; MSG_S msg; local_debug_p = (struct debug_msg_s *)aos_msg_alloc(MPE_DEBUG,sizeof(struct debug_msg_s)); if(NULL==local_debug_p) { break; } local_debug_p->ulCmd = cmdmsgp->para[0]; local_debug_p->ulPara1 = cmdmsgp->para[1]; local_debug_p->ulPara2 = cmdmsgp->para[2]; local_debug_p->ulPara3 = cmdmsgp->para[3]; local_debug_p->ulPara4 = cmdmsgp->para[4]; msg.srcProcessorId = LOCAL_PROCESSOR_ID; msg.srcMpe = MPE_DEBUG; msg.dstProcessorId = LOCAL_PROCESSOR_ID; msg.dstMpe = cmdmsgp->mpe; msg.msgPrio = MSG_PRIO_NORMAL; msg.ulSize = sizeof(struct debug_msg_s); msg.pvMsgBuf = (VOID*)local_debug_p; aos_msg_send( &msg ); } break; case DEBUG_TURNON: if( 0xff == cmdmsgp->mpe ) { ssp_mpe_print_enable_all( ); } else { ssp_mpe_print_enable( cmdmsgp->mpe ); } break; case DEBUG_TURNOFF: if( 0xff == cmdmsgp->mpe ) { ssp_mpe_print_disable_all( ); } else { ssp_mpe_print_disable( cmdmsgp->mpe ); } break; case DEBUG_MEM_SHOW: debug_mem_show( MPE_DEBUG, cmdmsgp->para[0], cmdmsgp->para[1] ); break; case DEBUG_MEM_MOD: debug_mem_modify( cmdmsgp->para[0], cmdmsgp->para[1], cmdmsgp->para[2] ); break; default: aos_printf( MPE_DEBUG,"Debug:Unknown subcmd" ); } }VOID debug_l3_msg_constructor( struct dbg_l3_msg_s *l3msgp ){ S8 *link_string[]={"pstn","bcc","control","link control","protect 1","protect 2"}; MSG_S msg;#define LINK_STRING( type ) ( (type) < (sizeof(link_string)/sizeof(U8*)) ? link_string[type]:"link error" ) if( l3msgp->isV5Msg ) { if( DEBUG_IS_V5_MPE(l3msgp->srcMpe) && (MPE_LCM == l3msgp->dstMpe) ) { aos_printf( MPE_DEBUG,"Constructor v5 message and send to le,dl=%s comport=%d", LINK_STRING(l3msgp->link_type), l3msgp->comportno ); } else if( DEBUG_IS_V5_MPE(l3msgp->dstMpe) && (MPE_LCM == l3msgp->srcMpe) ) { aos_printf( MPE_DEBUG,"Constructor v5 message that comes from le,dl=%s comport=%d", LINK_STRING(l3msgp->link_type), l3msgp->comportno ); } else { aos_printf( MPE_DEBUG,"Constructor v5 message fail,mpe error" ); } } else { aos_printf( MPE_DEBUG,"Constructor message between mpes,srcProc=%d,srcMpe=%d,dstProc=%d,dstMpe=%d", l3msgp->srcProcessorId,l3msgp->srcMpe, l3msgp->dstProcessorId,l3msgp->dstMpe ); } if( 0 == l3msgp->length || l3msgp->length > N201 ) { aos_printf( MPE_DEBUG, "length=%d invalid", l3msgp->length ); return; }#undef LINK_STRING msg.srcProcessorId = l3msgp->srcProcessorId; msg.srcMpe = l3msgp->srcMpe; msg.dstProcessorId = l3msgp->dstProcessorId; msg.dstMpe = l3msgp->dstMpe; msg.msgPrio = MSG_PRIO_NORMAL; msg.ulSize = l3msgp->length; if( l3msgp->isV5Msg ) { DL_MSG_S *v5msgp; v5msgp = (DL_MSG_S*)aos_msg_alloc( MPE_DEBUG,l3msgp->length ); if( NULL == v5msgp ) { return; } aos_memcpy( (VOID*)&v5msgp->ucInfo, (VOID*)&l3msgp->information, l3msgp->length ); if( MPE_LCM == l3msgp->dstMpe ) { v5msgp->ucPrimID = DL_DATA_REQUEST; } else { v5msgp->ucPrimID = DL_DATA_INDICATION; } v5msgp->ucPhyType = LCM_DRV_HDLC; v5msgp->usCommPort= (U16)l3msgp->comportno; v5msgp->ucV5DLType= (U8)l3msgp->link_type; v5msgp->usLength = (U16)l3msgp->length; msg.ulSize += ELEMENT_OFFSET(DL_MSG_S, ucInfo); msg.pvMsgBuf = (VOID*)v5msgp; } else { VOID *msgp; msgp = (VOID*)aos_msg_alloc( MPE_DEBUG,l3msgp->length ); if( NULL == msgp ) { return; } aos_memcpy( msgp, (VOID*)&l3msgp->information, l3msgp->length ); msg.pvMsgBuf = msgp; } aos_msg_send( &msg );}VOID debug_own_cmd_handle( U32 cmd, U32 subcmd, U32 p1, U32 p2 ){ switch( cmd ) { case 1: ssp_show_mpe(); break; case 2: { SYS_TIME_S now; aos_time_get(&now); aos_printf( MPE_DEBUG, "AOS time is %02d:%02d:%02d",now.hour,now.minute,now.second ); } break; case 30: dbg_show_exc_info( subcmd ); dbg_show_tsk_sw_info( subcmd ); dbg_show_infinite_loop_info( subcmd ); dbg_show_last_msg_info( subcmd ); dbg_show_assert_info( subcmd ); dbg_show_run_flow( subcmd ); break; case 31: dbg_show_exc_info( subcmd ); break; case 32: dbg_show_tsk_sw_info( subcmd ); break; case 33: dbg_show_infinite_loop_info( subcmd ); break; case 34: dbg_show_last_msg_info( subcmd ); break; case 35: dbg_show_assert_info( subcmd ); break; case 36: dbg_show_run_flow( subcmd ); break; case 40: aos_show_trace( subcmd, p1, p2 ); break; case 41: if( subcmd ) { aos_printf( MPE_DEBUG, "Enable debug trace" ); g_ulEnableTrace = TRUE; } else { aos_printf( MPE_DEBUG, "disable debug trace" ); g_ulEnableTrace = FALSE; } break;#if(CONFIG_BOARD_EIA == TRUE && CONFIG_OS_VXWORKS == TRUE) case 50: if(AOS_FAIL == cfm_set_parameter(CMD_SERIAL2_USE,(VOID *)&(subcmd), 4)) { AOS_ASSERT(0); } break; case 51: cfm_get_parameter( CMD_SERIAL2_USE,(VOID *)&(subcmd), 4 ); aos_printf( 0, "Serial Mode=%s", 1 == subcmd ? "BILL" : "Serial" ); break;#endif case 60: g_dbgPrint2Log = subcmd; aos_printf( MPE_DEBUG, "Set g_dbgPrint2Log to %u", subcmd ); break; case 70: mem_check_all(__FILE__,__LINE__);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -