/* ================================================================================= Function: cif_test_dpm_access read and write DEV identifier in the DEV DPM --------------------------------------------------------------------------------------- Input : ptGlobalDrv - pointer to global DRV structure Output : - Return : TRUE - Hardware check passed FALSE - Hardware check failed ================================================================================= */ unsigned short cif_test_dpm_access( DEV_INSTANCE * ptDevInst) { unsigned char abOrgIdentifier[DEVNAMELEN]; unsigned char abTestString [DEVNAMELEN]; unsigned short usIdx = 0, usIdFound = 0, usRet = 0; DBG_PRN("ptDpmAddress: %lX, size of DPM_MEMORY = %lX\n", (unsigned long)ptDevInst->ptDpmAddress, sizeof(DPM_MEMORY)); abOrgIdentifier[0] = ptDevInst->ptDpmAddress->tDevInfo.DevIdentifier[0]; abOrgIdentifier[1] = ptDevInst->ptDpmAddress->tDevInfo.DevIdentifier[1]; abOrgIdentifier[2] = ptDevInst->ptDpmAddress->tDevInfo.DevIdentifier[2]; DBG_PRN("Dev. Identifier DPM: %.3s", ptDevInst->ptDpmAddress->tDevInfo.DevIdentifier); DBG_PRN("Dev. Identifier read: %.3s", &abOrgIdentifier[0]); for( usIdx = 0, usIdFound = FALSE; (usIdx < DEV_IDENTIFIER_ANZ) && (usIdFound == FALSE); usIdx++) { if( (abOrgIdentifier[0] == abDevIdentifier[usIdx][0]) && (abOrgIdentifier[1] == abDevIdentifier[usIdx][1]) && (abOrgIdentifier[2] == abDevIdentifier[usIdx][2]) ) { usIdFound = TRUE; } } // end for if( usIdFound == FALSE) { // No Identifier found, return fault DBG_PRN("NO IDENTIFIER FOUND\n"); usRet = FALSE; } else { // DEV identifiere is OK, write test identifier ptDevInst->ptDpmAddress->tDevInfo.DevIdentifier[0] = abTestDPM[0]; ptDevInst->ptDpmAddress->tDevInfo.DevIdentifier[1] = abTestDPM[1]; ptDevInst->ptDpmAddress->tDevInfo.DevIdentifier[2] = abTestDPM[2]; abTestString[0] = ptDevInst->ptDpmAddress->tDevInfo.DevIdentifier[0]; abTestString[1] = ptDevInst->ptDpmAddress->tDevInfo.DevIdentifier[1]; abTestString[2] = ptDevInst->ptDpmAddress->tDevInfo.DevIdentifier[2]; // read test identifier if( (abTestString[0] != abTestDPM[0]) || (abTestString[1] != abTestDPM[1]) || (abTestString[2] != abTestDPM[2]) ) { // Can't write test identifier DBG_PRN("READ TEST IDENTIFIER FAILED\n"); usRet = FALSE; } else { // test identifiere is OK, write orignal identifier to dev DPM ptDevInst->ptDpmAddress->tDevInfo.DevIdentifier[0] = abOrgIdentifier[0]; ptDevInst->ptDpmAddress->tDevInfo.DevIdentifier[1] = abOrgIdentifier[1]; ptDevInst->ptDpmAddress->tDevInfo.DevIdentifier[2] = abOrgIdentifier[2]; // read original identifier if( (abOrgIdentifier[0] != ptDevInst->ptDpmAddress->tDevInfo.DevIdentifier[0]) || (abOrgIdentifier[1] != ptDevInst->ptDpmAddress->tDevInfo.DevIdentifier[1]) || (abOrgIdentifier[2] != ptDevInst->ptDpmAddress->tDevInfo.DevIdentifier[2]) ) { // Can't write original identifier DBG_PRN("WRITE ORGINAL IDENTIFIER FAILED\n"); usRet = FALSE; } else { // write original identifier is OK, DPM is accessable DBG_PRN("Done\n"); usRet = TRUE; } } } return usRet; }