Пример #1
0
/*****************************************************************************
函 数 名  : diag_LogPortSwitch
功能描述  :
输入参数  :
输出参数  :
返 回 值  :
调用函数  :
被调函数  :
修改历史  :
	1.日	期	: 2012年8月27日
	 修改内容  : Creat Function

*****************************************************************************/
VOS_UINT32 diag_LogPortSwitch(VOS_UINT32 ulLogPort)
{
    VOS_UINT32 ulDevChan;

    if(ulLogPort == DIAG_LOG_PORT_VCOM)
    {
        ulDevChan = EN_DIAG_VCOM_BEABER_DIAG_CTRL;
    }
    else if(ulLogPort == DIAG_LOG_PORT_USB)
    {
        ulDevChan = EN_DIAG_USB_BEARER_DIAG_CTRL;
    }
    else if(ulLogPort == DIAG_LOG_PORT_SD)
    {
        ulDevChan = EN_DIAG_SD_BEARER_DIAG;
    }
    else
    {
        return ERR_MSP_INVALID_PARAMETER;
    }

    if((DIAG_PORT_GET_CONN_PORT() != ulDevChan) && (EN_PORT_INIT_SUCC == DIAG_PORT_GET_INIT(ulDevChan)))
    {
        DIAG_PORT_PORT_SWITCH((DIAG_PORT_PHY_BEAR_ENUM)ulDevChan);
    }
    return ERR_MSP_SUCCESS;
}
Пример #2
0
/*lint -save -e958*/
VOS_UINT32 diag_VcomRead(VOS_UINT8 ucDevIndex, VOS_UINT8 *pData, VOS_UINT32 uslength)
{
    VOS_UINT32 ulRet = ERR_MSP_SUCCESS;
#if(FEATURE_SOCP_ON_DEMAND == FEATURE_ON)
    DIAG_PORT_DATA_BUF_STRU * dataNode;
#endif
    /*lint -restore*/
    if((ucDevIndex != DIAG_APPVCOM_CHAN_CTRL)||(NULL == pData)||(0 == uslength))
    {
        diag_printf("[%s]:INVALID PARAMETER ! ucDevIndex :0x%x,uslength :0x%x\n",__FUNCTION__,ucDevIndex,uslength);
        DIAG_DEBUG_SDM_FUN(EN_DIAG_DEBUG_APPVCOM_READ_ERR,0, uslength, 1);
        return ERR_MSP_INVALID_PARAMETER;
    }

#if(FEATURE_SOCP_ON_DEMAND == FEATURE_ON)
    /*端口切换,丢弃链表中数据*/
    if(DIAG_PORT_GET_CONN_PORT() != EN_DIAG_VCOM_BEABER_DIAG_CTRL)
    {
        for(;;)
        {
            dataNode = diag_PortGetNodeFromDataBuf();
            if(dataNode == NULL)
            {
                break;
            }
            VOS_MemFree(MSP_PID_DIAG_APP_AGENT, dataNode->dataBuf);
            VOS_MemFree(MSP_PID_DIAG_APP_AGENT, dataNode);
        }
    }
#endif

    /*设置当前物理通道*/
    DIAG_PORT_PORT_SWITCH(EN_DIAG_VCOM_BEABER_DIAG_CTRL);
    diag_TraceDebug(pData, uslength);

#if(FEATURE_SOCP_ON_DEMAND == FEATURE_ON)
    /*SOCP不可用或者缓存非空*/
    if((g_diagSocpIsEnable != TRUE) || (ERR_MSP_SUCCESS != diag_PortDataBufIsEmpty()))
    {
        diag_PortAddToDataBuf(EN_DIAG_VCOM_BEABER_DIAG_CTRL, (VOS_UINT8 *)pData, uslength);
        if(ERR_MSP_SUCCESS != diag_SendMsg(MSP_PID_DIAG_APP_AGENT, MSP_PID_DIAG_APP_AGENT,
                                           ID_MSG_DIAG_CMD_PORT_REQ_TO_APP_AGENT, (VOS_UINT8 *)&ulRet, sizeof(VOS_UINT32)))
        {
            diag_printf("[%s]:send msg to diag app agent fail!!!!!!!!\n",__func__);
        }
        return ERR_MSP_SUCCESS;
    }
#endif

    ulRet = SCM_SendDecoderSrc(SOCP_DECODER_SRC_LOM,pData,uslength);
    if(ulRet != ERR_MSP_SUCCESS)
    {
        diag_printf("[%s]:SCM_SendDecoderSrc fail ! ulRet :0x%x\n",__FUNCTION__,ulRet);
        DIAG_DEBUG_SDM_FUN(EN_DIAG_DEBUG_APPVCOM_READ_ERR,ulRet, 0, 2);
        return ulRet;
    }
    return ERR_MSP_SUCCESS;
}
Пример #3
0
VOS_UINT32 diag_TcpSendData(DIAG_TCPIP_PORT_ENUM enTcpPort,VOS_UINT8 *pcData, VOS_UINT32 usDataLen, VOS_UINT32 * pusWrtLen)
{
    VOS_INT32 len = SOCKET_ERROR;
    DIAG_TCPIP_CTRL_INFO_STRU* pstTcpIpInfo = diag_GetTcpInfo();
    DIAG_PORT_CONNECT_STA_PFN pfnConn = DIAG_PORT_GET_CONN_CALLBACK();

	DIAG_DEBUG_SDM_FUN(EN_DIAG_TCP_SOCKET_SEND, (VOS_UINT32)enTcpPort, (VOS_UINT32)len, 0);

    if(pstTcpIpInfo->astTcpIpPort[enTcpPort].Tcp ==INVALID_SOCKET)
    {
    	diag_printf("diag_TcpSendData invalid socket!\n");
		DIAG_DEBUG_SDM_FUN(EN_DIAG_TCP_SOCKET_SEND_ERROR, (VOS_UINT32)len, 0, 0);
        return ERR_MSP_FAILURE;
    }

	SCM_INVALID_CACHE(pcData , usDataLen);
	len = send((int)(pstTcpIpInfo->astTcpIpPort[enTcpPort].Tcp), (VOS_CHAR*)pcData, (int)usDataLen, 0);
    if(g_dmsPrintFlag == 1)
    {
       diag_printf("***********diag_TcpSendData !! usDataLen = %d,enTcpPort=%d,pcData = 0x%p\n" ,usDataLen ,enTcpPort, pcData);
       diag_printf("***********diag_TcpSendData !! len=%d,astTcpIpPort[enTcpPort].Tcp=%d \n" ,len,pstTcpIpInfo->astTcpIpPort[enTcpPort].Tcp);
    }

    if (SOCKET_ERROR == len)
    {
        /*如果是重连之后的第一次发送,可能由于任务调度的原因导致socket获取错误;
 */
        /*此类错误不可以关闭socket;
 */
        if(pstTcpIpInfo->astTcpIpPort[enTcpPort].ulIsReCon==1)
        {
            diag_printf("pstTcpIpInfo->astTcpIpPort[enTcpPort].ulIsReCon==1\n");
            DIAG_DEBUG_SDM_FUN(EN_DIAG_TCP_SOCKET_SEND_ERROR, (VOS_UINT32)len, 0, 1);
            return ERR_MSP_FAILURE;
        }

		/*关闭socket
 */
        diag_CloseSocket(enTcpPort);

		/*置连接状态为断开
 */
        if (enTcpPort == EN_TCP_PORT_DIAG)
        {
        	DIAG_PORT_PORT_SWITCH(EN_DIAG_SOCKET_BEARER_TCP_20248);
            if (pfnConn != NULL)
            {
            	DIAG_DEBUG_SDM_FUN(EN_DIAG_TCP_SOCKET_SEND_ERROR, (VOS_UINT32)len, 0, 2);
                pfnConn(DIAG_DISCONN);
            }
        }

		pstTcpIpInfo = diag_GetTcpInfo();
		pstTcpIpInfo->astTcpIpPort[enTcpPort].ulConnectSta = DIAG_DISCONN;
        return ERR_MSP_FAILURE;
    }

    /*后续的发送失败就会直接关闭socket
 */
    pstTcpIpInfo->astTcpIpPort[enTcpPort].ulIsReCon = 0;

    *pusWrtLen = (VOS_UINT32)len;

    return ERR_MSP_SUCCESS;
}
Пример #4
0
static VOS_VOID diag_TcpRcvData(VOS_SOCKET rxSocket, DIAG_TCPIP_PORT_ENUM enTcpPort,
                         DIAG_PORT_CONNECT_STA_PFN pfnConn)
{
	DIAG_TCPIP_CTRL_INFO_STRU *pstDiagTcpInfo;
    VOS_INT32 len = -1;
    VOS_UINT32 Ret;

	DIAG_DEBUG_SDM_FUN(EN_DIAG_TCP_SOCKET_RECV, (VOS_UINT32)len, 0, 0);

    len = recv((int) rxSocket, (char*)g_aucRecvBuf, (int) DIAG_PORT_READ_LEN, 0);
    if ((SOCKET_ERROR == len) || (0 == len))
    {
    	diag_printf("diag_TcpRcvData  recv error !len=%d \n", len);
        DIAG_DEBUG_SDM_FUN(EN_DIAG_TCP_SOCKET_RECV_ERROR, (VOS_UINT32)len, 0, 0);
        diag_CloseSocket(enTcpPort);


        /* reset channel port connect as disconnect,when recv() error*/
        if (enTcpPort == EN_TCP_PORT_DIAG)
        {
        	DIAG_PORT_PORT_SWITCH(EN_DIAG_SOCKET_BEARER_TCP_20248);
            if (pfnConn != NULL)
            {
            	diag_printf("diag_TcpRcvData pfnConn(EN_DMS_CHANNEL_DIAG, DIAG_DISCONN) \n");
                pfnConn(DIAG_DISCONN);
            }
        }

		pstDiagTcpInfo = diag_GetTcpInfo();
		pstDiagTcpInfo->astTcpIpPort[enTcpPort].ulConnectSta = DIAG_DISCONN;
        return;
    }
    else
    {
        if(g_dmsPrintFlag == 1)
        {
    	    diag_printf("diag_TcpRcvData  recv ok ! len=%d ulTcpPort=%d \n" , len , enTcpPort);
        }
        /* send recv data to cdm decoder*/
        if (enTcpPort == EN_TCP_PORT_DIAG)
        {
           if(g_diagPort[EN_DIAG_SOCKET_BEARER_TCP_20248].ucHdlcFlag ==1)
            {


				Ret = SCM_SendDecoderSrc(g_diagPort[EN_DIAG_USB_BEARER_DIAG_CTRL].ulDecodeSrcChanId, g_aucRecvBuf, (VOS_UINT32)len );
                if(g_dmsPrintFlag == 1)
                {
				    diag_printf("diag_TcpRcvData  111 Ret= %d \n" , Ret);
                }
                return ;
            }
        }

#if (VOS_WIN32== VOS_OS_VER)
        else if (enTcpPort == EN_TCP_PORT_AT)
        {
            if(g_diagPort[EN_DIAG_SOCKET_BEARER_TCP_20249].ucHdlcFlag ==1)
            {
                return ;
            }
			else
			{
			}
        }
#endif
    }
}
Пример #5
0
static VOS_VOID diag_AcceptOnSocket(DIAG_TCPIP_PORT_ENUM ucTcpPort , DIAG_TCPIP_PORT_STRU *astTcpPort)
{
    /*lint -save -e565*/
    struct sockaddr_in from;
    /*lint -restore*/
    VOS_SOCKET newSocket;
    VOS_SOCKET *ListenerSocket;
    VOS_INT32 len;
    DIAG_PORT_CONNECT_STA_PFN pfnConn = DIAG_PORT_GET_CONN_CALLBACK();

    ListenerSocket = &(astTcpPort[ucTcpPort].listener);
    /*lint -save -e84 -e565 -e740*/
    len = sizeof(struct sockaddr_in);
    newSocket = accept(*ListenerSocket, (struct sockaddr *)&from, (int *)&len);
    /*lint -restore*/

    if (INVALID_SOCKET == newSocket)
    {
        closesocket(*ListenerSocket);
        *ListenerSocket = INVALID_SOCKET;
		diag_printf("diag_AcceptOnSocket INVALID_SOCKET == newSocket!\n");
        return;
    }

    /*增加Diag通道的重连处理流程*/
    else
    {
        if(astTcpPort[ucTcpPort].Tcp !=INVALID_SOCKET)
        {
            closesocket(astTcpPort[ucTcpPort].Tcp);
            astTcpPort[ucTcpPort].Tcp = INVALID_SOCKET;
            astTcpPort[ucTcpPort].ulIsReCon= 1;
			diag_printf("diag_AcceptOnSocket astTcpPort[ucTcpPort].ulIsReCon= 1;!\n");
            DIAG_DEBUG_SDM_FUN(EN_DIAG_TCP_TCP_RECONNECT, (VOS_UINT32)newSocket, 0, 0);
        }
    }

    DIAG_DEBUG_SDM_FUN(EN_DIAG_TCP_SOCKET_ACP, (VOS_UINT32)newSocket, 0, 0);

    diag_TcpPortLock(ucTcpPort);
    astTcpPort[ucTcpPort].Tcp = newSocket;
    diag_TcpPortUnLock(ucTcpPort);

#if (VOS_WIN32== VOS_OS_VER)
    /* close listening socket (allow one connection per channel)*/
  if(ucTcpPort == EN_TCP_PORT_AT)
    {
        closesocket(*ListenerSocket);
        *ListenerSocket = INVALID_SOCKET;
    }
#endif

    /* 记录该连接状态*/
	if(ucTcpPort == EN_TCP_PORT_DIAG)
	{

        DIAG_PORT_PORT_SWITCH(EN_DIAG_SOCKET_BEARER_TCP_20248);
        if (pfnConn != NULL)
        {
            pfnConn(DIAG_CONN);
			diag_printf("diag_AcceptOnSocket pfnConn(EN_DMS_CHANNEL_DIAG, DIAG_DISCONN)!\n");
        }
    }

    /* 记录该连接状态*/
    astTcpPort[ucTcpPort].ulConnectSta = DIAG_CONN;
}
Пример #6
0
/*****************************************************************************
函 数 名  : diag_PortRdCB
功能描述  :
输入参数  :
输出参数  :
返 回 值  :
调用函数  :
被调函数  :
修改历史  :
	1.日	期	: 2012年8月27日
	 作    者  : heliping
	 修改内容  : Creat Function

*****************************************************************************/
VOS_VOID diag_PortRdCB(DIAG_PORT_PHY_BEAR_ENUM enPort)
{
    ACM_WR_ASYNC_INFO   acmInfo = {};
    UDI_HANDLE ulUdiHandle;
    VOS_UINT32 ret;
    VOS_UINT32 ulDataLen;
    VOS_CHAR*  pdata;
    static VOS_UINT32 ulTotalLen = 0;
#if(FEATURE_SOCP_ON_DEMAND == FEATURE_ON)
    DIAG_PORT_DATA_BUF_STRU * dataNode;
#endif

    ulUdiHandle = DIAG_PORT_GET_HANDLE(enPort);
    if(ulUdiHandle == UDI_INVALID_HANDLE)
    {
        DIAG_DEBUG_SDM_FUN(EN_DIAG_DEBUG_UDI_READ_END,0,0,1);
        diag_printf("[%s]:invalid handle!!!!!!!!\n",__func__);
        return;
    }
    ret = (VOS_UINT32)udi_ioctl(ulUdiHandle,UDI_ACM_IOCTL_GET_READ_BUFFER_CB,&acmInfo);
    if(ret != ERR_MSP_SUCCESS)
    {
        DIAG_DEBUG_SDM_FUN(EN_DIAG_DEBUG_UDI_READ_END,0,0,2);
        diag_printf("[%s]:get read buffer callback err 0x%x!!!!!!!!\n",__func__,ret);
        return;
    }

#if(FEATURE_SOCP_ON_DEMAND == FEATURE_ON)
    /*端口切换,丢弃链表中数据*/
    if(DIAG_PORT_GET_CONN_PORT() != enPort)
    {
        for(;;)
        {
            dataNode = diag_PortGetNodeFromDataBuf();
            if(dataNode == NULL)
            {
                break;
            }
            VOS_MemFree(MSP_PID_DIAG_APP_AGENT, dataNode->dataBuf);
            VOS_MemFree(MSP_PID_DIAG_APP_AGENT, dataNode);
        }
    }
#endif
    ulDataLen = acmInfo.u32Size;
#ifdef FEATURE_UPGRADE_TL
    pdata = acmInfo.pBuffer;
#else
    pdata = acmInfo.pVirAddr;
#endif

    ulTotalLen += ulDataLen;

    DIAG_DEBUG_SDM_FUN(EN_DIAG_DEBUG_UDI_READ_START,ulTotalLen,ulDataLen,0);

    /*设置当前物理通道及通道连接状态*/
    DIAG_PORT_PORT_SWITCH(enPort);

    DIAG_PORT_CHAN_STATE_SWITCH(enPort,ACM_EVT_DEV_READY);
	DIAG_PORT_CHAN_STATE_SWITCH(enPort+1,ACM_EVT_DEV_READY);
    diag_PrintToFile(UsbCtrlRdCB_LogPath, pdata, ulDataLen);
    diag_TraceDebug(pdata, ulDataLen);

#if(FEATURE_SOCP_ON_DEMAND == FEATURE_ON)
    /*SOCP不可用或者缓存非空*/
    if((g_diagSocpIsEnable != TRUE) || (ERR_MSP_SUCCESS != diag_PortDataBufIsEmpty()))
    {
        DIAG_DEBUG_SDM_FUN(EN_DIAG_DEBUG_UDI_READ_END,0,0,3);
        diag_PortAddToDataBuf(enPort, (VOS_UINT8 *)(pdata),ulDataLen);
        ret = (VOS_UINT32)udi_ioctl(ulUdiHandle,UDI_ACM_IOCTL_RETUR_BUFFER_CB,&acmInfo);
        if(ret)
        {
            DIAG_DEBUG_SDM_FUN(EN_DIAG_DEBUG_UDI_READ_END,0,0,4);
            diag_printf("[%s]:return buffer to acm err 0x%x!!!!!!!!\n",__func__,ret);
        }
        if(ERR_MSP_SUCCESS != diag_SendMsg(MSP_PID_DIAG_APP_AGENT, MSP_PID_DIAG_APP_AGENT,
            ID_MSG_DIAG_CMD_PORT_REQ_TO_APP_AGENT, (VOS_UINT8 *)&ret, sizeof(VOS_UINT32)))
        {
            DIAG_DEBUG_SDM_FUN(EN_DIAG_DEBUG_UDI_READ_END,0,0,5);
            diag_printf("[%s]:send msg to diag app agent fail!!!!!!!!\n",__func__);
        }
        return;
    }
#endif

    ret = SCM_SendDecoderSrc(DIAG_PORT_GET_DECODE_SRC(enPort),(VOS_UINT8 *)(pdata),ulDataLen);
    if(ret)
    {
        DIAG_DEBUG_SDM_FUN(EN_DIAG_DEBUG_UDI_READ_END,0,0,6);
        diag_printf("[%s]:SCM_SendDecoderSrc err 0x%x!!!!!!!!\n",__func__,ret);
    }

    ret = (VOS_UINT32)udi_ioctl(ulUdiHandle,UDI_ACM_IOCTL_RETUR_BUFFER_CB,&acmInfo);
    if(ret)
    {
        DIAG_DEBUG_SDM_FUN(EN_DIAG_DEBUG_UDI_READ_END,0,0,7);
        diag_printf("[%s]:SCM_SendDecoderSrc err 0x%x!!!!!!!!\n",__func__,ret);
    }

    return;

}