#---------------------------------------------------------------------------------------------------------#
# Property of Seagate Technology, Copyright 2006, All rights reserved #
#---------------------------------------------------------------------------------------------------------#
# Description: Read Write Module
# $File: //depot/TSE/PF3/work/branches/Pharaoh_Eval_5/scripts/RdWr.py $
# $Revision: #12 $
# $DateTime: 2009/04/20 16:29:48 $
# $Author: Ross.A.Nelson $
# $Header: //depot/TSE/PF3/work/branches/Pharaoh_Eval_5/scripts/RdWr.py#12 $
# Level: 3
#---------------------------------------------------------------------------------------------------------#
from TestParamExtractor import TP
from Exceptions import CDblogDataMissing
import MessageHandler as objMsg
from Constants import *
from Drive import objDut # usage is objDut[PortIndex]
from Utility import CUtility
import types, os, sys
from Process import CProcess
from Process import CCudacom
import Channel
from FSO import CFSO
from Servo import CServoOpti
from Servo import CServo
from SdatParameters import *
from math import log10,pow
from time import time
import struct
from MediaScan import CUserFlaw
import ScrCmds
from array import array
from PowerControl import objPwrCtrl
import binascii
from base_GOTF import CGOTFGrading
from StateTable import StateTable, StateParams
import MathLib
from DbLog import DbLogTable
class CRdWr(CProcess,CCudacom):
def __init__(self, params = {}):
CProcess.__init__(self)
self.testZones = None
self.headRange = None
self.dut = objDut[PortIndex]
self.params = params
def St(self,inPrm):
inPrm = dict(inPrm)
if 'ZONE_POS' in self.params:
inPrm['ZONE_POSITION'] = self.params['ZONE_POS']
if self.testZones == None:
stats = CProcess.St(self,inPrm)
else:
# Create disable flash update mask
mword = {}
mword['CWORD1'] = inPrm['CWORD1']
if type(mword['CWORD1']) == types.TupleType:
mword['CWORD1'] = mword['CWORD1'][0]
if inPrm['test_num'] in [151, 251]:
#Disable flash update if this is a by-zone/head update
mword['CWORD1'] = mword['CWORD1'] | 0x0008
inPrm.update({'BIT_MASK':self.oUtility.ReturnTestCylWord(self.oUtility.setZoneMask(self.testZones)),
'CWORD1': mword['CWORD1'] })
if not self.headRange == None:
inPrm['TEST_HEAD'] = self.headRange
stats = CProcess.St(self,inPrm)
return stats
def modRAP(self, offset, value, mask):
rapOffPrm = {
'test_num': 178,
'prm_name': "Modify RAP Word %s to %s using mask %s" % (str(offset), str(value), str(mask)),
'CWORD1': 0x0220,
'RAP_WORD':(offset, value, mask)
}
self.St(rapOffPrm)
pass
def measCQM(self, basePrm = {}):
if basePrm == {}:
basePrm={
#Test 151 - read channel optimization.
#Null Opti- BER/CQM measure
'test_num':151,
'prm_name':'CQM BER Measure PRM_151',
'timeout':1000,
'spc_id':1,
'CWORD1': 0x4008,
"TARGET_TRK_WRITES" : (0x01,),
"NUM_SAMPLES" : (0x02,), # 1 might be sufficient
# regID start end step
"REG_TO_OPT1" : (0x0,0x0,0x0,0x00,), # REGID_TDTARG (0x91,12,12,0x01,),
"RESULTS_RETURNED" : (0x0F),
"NON_DIS_WEDGES" : (50,),
#"RW_MODE" : (0x0,), # Force Sync - currently required for Agere
# Force reset of channel back to defaults between each bucket point.
# This is done by forcing a zero seek. Prevents failure do to railed taps.
"SEEK_COUNT" : (1,), # Just needs to be non-zero, only one seek is performed.
"TRGT_PRE_READS" : (0x00,), # Training Reads (par value in sectors now) - set to zero
#"RETRY_LIMIT" : (5,), # Retries to perform on read errors.
"PATTERNS" : (0xAA,0xFF,0xFF,),
# Optional:
"LIMIT32" : (0,0,), # Display TAP and CQM debug data (1,0,),
"ZONE_POSITION": TP.ZONE_POS,
}
SetFailSafe()
self.St(basePrm)
ClearFailSafe()
def writetrack(self, retries = 0):
"""
Write the current track
@return: Drive Status
"""
writeRetryCnt = 0
while writeRetryCnt <= retries:
buf, errorCode = self.Fn(1355)
if errorCode == 0:
break
writeRetryCnt += 1
else:
objMsg.printMsg("Failed to write track, %s retries attempted."% retries)
objMsg.printMsg("writetrack err, errorCode= %s, sense data = %s " % (errorCode,binascii.hexlify(buf)),objMsg.CMessLvl.IMPORTANT)
return buf # Return buffer contents only.
def ber(self, targetBer, numRevs, TLevel, timeout = 60, printResult = 0):
"""
Run the BER test, seek to target track using ActiveHead and ActiveCylinder and measure raw BER.
@param targetBer: Target BER limit (times 10) to measure. Number of revs are calculated internally to meet the target BER.
@param numRevs: Number of revs to read in the BER test. Will override the targetBer if numRevs is non-zero.
@param TLevel: ECC Level (0 to 30 by 2's -- See TLEVEL define below in setEccLevel).
@return: Bit Error Rate, Data Errors, Sync Errors, Other Errors, Sectors Per Rev, Sense Code, and failed sector if other error.
"""
if ((TLevel % 2) != 0) or (TLevel > 30):
objMsg.printMsg("Invalid TLevel Entered!")
return
buf = ReceiveBuffer(timeout,checkSRQ=0)
buf, errorCode = self.Fn(1342, targetBer, numRevs, TLevel)
result = struct.unpack("fLLLHHLLL",buf)
other_errors = result[3:4]
if printResult == 1:
objMsg.printMsg("BER = %f " % (result[0:1]) + "Data Errors = %u " % (result[1:2]) + "Sync Errors = %u " % (result[2:3]) + \
"Other Errors = %u " % (result[3:4]) + "Sectors per Rev = %u " % (result[4:5]) + "Sense Data = %x " % (result[6:7]))
if other_errors[0] > 0:
objMsg.printMsg("Failed Sector = %u" % (result[7:8]))
return buf
def setEccLevel(self, level=30):
"""
Set Override ECC Level and enable override.
@param level: Override ECC level 0..30 (default=30)
DISABLE_ECC = 0, // T Level 0
TLEVEL_2 = 2, // T Level 2
TLEVEL_4 = 4, // T Level 4
TLEVEL_6 = 6, // T Level 6
TLEVEL_8 = 8, // T Level 8
TLEVEL_10 = 10, // T Level 10
TLEVEL_12 = 12, // T Level 12
TLEVEL_14 = 14, // T Level 14
TLEVEL_16 = 16, // T Level 16
TLEVEL_18 = 18, // T Level 18
TLEVEL_20 = 20, // T Level 20
TLEVEL_22 = 22, // T Level 22
TLEVEL_24 = 24, // T Level 24
TLEVEL_26 = 26, // T Level 26
TLEVEL_28 = 28, // T Level 28
TLEVEL_30 = 30 // T Level 30
@return: nothing
"""
if ((level % 2) != 0) or (level > 30):
objMsg.printMsg("Invalid TLevel Entered! ECC Level not changed!")
else:
buf, errorCode = self.Fn(1334, level)
return
def displayBuffer(self, buf):
"""
Print a binary string buffer to the string in "pretty" format- bit seperated hex
"""
try:
data = binascii.hexlify(buf)
i1=0
cnt=0
objMsg.printMsg(" ")
评论0