From e2b0cb3c458ae824c26d922a98c89c93cdd1f73a Mon Sep 17 00:00:00 2001 From: "Kevin P. Fleming" Date: Fri, 13 Jul 2007 21:12:46 +0000 Subject: update to PR48 API release git-svn-id: http://svn.asterisk.org/svn/octasic_api/oct612x/trunk@28 537310ab-6354-42db-a3cc-247b777f7be6 --- .../oct6100api/oct6100_api/oct6100_debug.c | 53 ++++++++++++++++++---- 1 file changed, 44 insertions(+), 9 deletions(-) (limited to 'software/octdeviceapi/oct6100api/oct6100_api/oct6100_debug.c') diff --git a/software/octdeviceapi/oct6100api/oct6100_api/oct6100_debug.c b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_debug.c index 6095108..ac25f81 100644 --- a/software/octdeviceapi/oct6100api/oct6100_api/oct6100_debug.c +++ b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_debug.c @@ -2,7 +2,7 @@ File: oct6100_debug.c - Copyright (c) 2001-2006 Octasic Inc. + Copyright (c) 2001-2007 Octasic Inc. Description: @@ -22,9 +22,9 @@ You should have received a copy of the GNU General Public License along with the OCT6100 GPL API; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -$Octasic_Release: OCT612xAPI-01.00-PR47 $ +$Octasic_Release: OCT612xAPI-01.00-PR48 $ -$Octasic_Revision: 63 $ +$Octasic_Revision: 64 $ \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ @@ -233,12 +233,11 @@ UINT32 Oct6100DebugSelectChannelSer( tPOCT6100_API_CHANNEL pChanEntry = NULL; tPOCT6100_API_CHANNEL pTempChanEntry; tOCT6100_CHANNEL_OPEN TempChanOpen; + tOCT6100_WRITE_BURST_PARAMS BurstParams; UINT16 usChanIndex = 0; UINT32 ulEntryOpenCnt; - - tOCT6100_WRITE_BURST_PARAMS BurstParams; - UINT16 ausWriteData[ 2 ]; - UINT32 ulResult; + UINT16 ausWriteData[ 2 ]; + UINT32 ulResult; /* Get local pointer(s). */ pSharedInfo = f_pApiInstance->pSharedInfo; @@ -442,7 +441,7 @@ UINT32 Oct6100DebugSelectChannelSer( return ulResult; pSharedInfo->DebugInfo.usCurrentDebugChanIndex = usChanIndex; - + /* Cancel data dump request, if there was one. */ pSharedInfo->DebugInfo.fDebugDataBeingDumped = FALSE; pSharedInfo->DebugInfo.ulDebugDataTotalNumBytes = cOCT6100_INVALID_VALUE; @@ -491,6 +490,7 @@ UINT32 Oct6100DebugGetDataSer( UINT16 ausWriteData[ 2 ]; UINT16 usReadData; UINT16 usDebugEventReadPtr; + UINT16 usTempNumEvents; UINT32 ulResult; UINT32 ulToneEventIndex; @@ -649,7 +649,11 @@ UINT32 Oct6100DebugGetDataSer( ulTimestamp |= usReadData; - ulTimestamp >>= 12; + ulTimestamp >>= 12; /* TDM time for 1 event (512 ms) */ + + /* There is a probability here (once very 6.2 days) that the timestamp is close */ + /* to 0, because it has wrapped. But still, we need a way to workaround the highly */ + /* occuring case of the chip just being opened. This will fix this problem. */ if ( ulTimestamp < (UINT32)( pSharedInfo->DebugInfo.usMatrixCBMask + 1 ) ) { if ( pSharedInfo->DebugInfo.usChipDebugEventWritePtr >= 2 ) @@ -672,6 +676,7 @@ UINT32 Oct6100DebugGetDataSer( pSharedInfo->DebugInfo.usNumEvents--; } + /* If the user only requested the last 16 seconds, cap the number of events. */ if ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_16S || f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_16S_LITE ) @@ -681,6 +686,36 @@ UINT32 Oct6100DebugGetDataSer( pSharedInfo->DebugInfo.usNumEvents = (UINT16)( ( 16000 / ( pSharedInfo->DebugInfo.ulRecordedPcmEventByteSize / 8 ) ) & 0xFFFF ); } + /* Make sure that all the events are pertaining to the current hot channel. */ + /* Calculate the event read pointer. */ + ulReadPointer = ( ( pSharedInfo->DebugInfo.usChipDebugEventWritePtr - pSharedInfo->DebugInfo.usNumEvents ) & pSharedInfo->DebugInfo.usMatrixCBMask ) * pSharedInfo->DebugInfo.ulDebugChanStatsByteSize; + ulReadPointer %= ( ( pSharedInfo->DebugInfo.usMatrixCBMask + 1 ) * pSharedInfo->DebugInfo.ulDebugChanStatsByteSize ); + + /* Travel through the events and throw away the bad events. */ + usTempNumEvents = pSharedInfo->DebugInfo.usNumEvents; + pSharedInfo->DebugInfo.usNumEvents = 0; + for ( ulDebugEventIndex = 0; ulDebugEventIndex < usTempNumEvents; ulDebugEventIndex ++ ) + { + /* The HOT channel index for the event is stored at offset 0xF2 (word offset) */ + + ReadParams.ulReadAddress = pSharedInfo->DebugInfo.ulMatrixBaseAddress + ulReadPointer; + ReadParams.ulReadAddress += 0xF2 * sizeof(UINT16); + ReadParams.pusReadData = &usReadData; + + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Check if the current debug index is the same as the one found in the event. */ + if ( usReadData != pSharedInfo->DebugInfo.usCurrentDebugChanIndex ) + pSharedInfo->DebugInfo.usNumEvents = 0; /* As soon as we hit another channel, we reset the number of valid events. */ + else + pSharedInfo->DebugInfo.usNumEvents++; + + /* Increment read pointer to get next event. */ + ulReadPointer = ( ulReadPointer + pSharedInfo->DebugInfo.ulDebugChanStatsByteSize ) % ( ( pSharedInfo->DebugInfo.usMatrixCBMask + 1 ) * pSharedInfo->DebugInfo.ulDebugChanStatsByteSize ); + } + /* In heavy mode, the AF log pointer is retrieved. */ if ( ( pSharedInfo->DebugInfo.usNumEvents >= 2 ) && ( ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_16S ) -- cgit v1.2.3