Beispiel #1
0
 void FBService::StreamMessage(const IDevicePtr& device, mc::IProtocolRef stream, mc::IMessageRef message)
 {
     if ( SFB::RequestDevice::messageId_ == message->GetCode() )
     {
         HandleDeviceRequest(device, stream, message);
     }
     else if ( SFB::ControlMessage::messageId_ == message->GetCode() )
     {
         HandleControlMessage(device, stream, message);
     }
 }
void HandleLoop(void)
{
	FORWARD_ETHER_FRAME* pForwardFrm = NULL;

	ADI_ETHER_BUFFER *pRecv = NULL,*pSend = NULL;

	RX_TX_TIME_STAMP_BUFFER *pTmBuff = NULL;

	ADI_ETHER_FRAME_BUFFER *pPkt = NULL;

	uint32_t FrmLen = 0;

	unsigned int nanSeconds = 0;
	BF609_COMM_ACK_CODE commRet;

	while ( 1 )
	{
		// recv a frame from Eth0;
		pRecv = EtherRecv ( g_hDev[0] );
		if ( pRecv )
		{
			//get time stamp
			pTmBuff = ( RX_TX_TIME_STAMP_BUFFER * ) pRecv;
			nanSeconds = ( unsigned int ) ( pTmBuff->RxTimeStamp.TimeStampLo ) ;

			// get frame length
			FrmLen = pRecv->ProcessedElementCount - 6; //adi_gemac.c process_int 中 加了6 bytes,WHY???

			//send a frame by emac1
			pSend = PackForwardSMVFrame ( nanSeconds, (char*)pRecv->Data +2,
					FrmLen,  &user_net_config_info[1] );

			EtherSend ( g_hDev[1], pSend );

			//reuse recv buff
			pRecv->pNext = NULL;
			pRecv->ProcessedElementCount = 0;
			pRecv->ProcessedFlag = 0;
			adi_ether_Read ( g_hDev[0], pRecv );
		}//if ( pRecv )

		// recv a frame from Eth1;
		pRecv = EtherRecv ( g_hDev[1] );
		if( pRecv )
		{
 			//process control messages frm...
			pForwardFrm = ( FORWARD_ETHER_FRAME * ) ( pRecv->Data );

			if( pForwardFrm->MUAddr == board_info.MUAddr )
			{
				HandleControlMessage((uint8_t*)pForwardFrm);
			}

			//reuse recv buff
			pRecv->pNext = NULL;
			pRecv->ProcessedElementCount = 0;
			pRecv->ProcessedFlag = 0;
			adi_ether_Read ( g_hDev[1], pRecv );
		}
	}//while
}