//! 2.2.6.1 Write Value to Register
//!
//! @param dnRegNumber
//! @param drvValue
//!
USBDM_GDI_API
DiReturnT DiRegisterWrite ( DiUInt32T        dnRegNumber,
                            DiRegisterValueT drvValue ) {
    LOGGING;
    U32c            regValue(drvValue);
    DSC_Registers_t regNum = mapReg(dnRegNumber);
    USBDM_ErrorCode rc = BDM_RC_OK;

    Logging::print("DiRegisterWrite(0x%lX,%s) => %lX\n", (unsigned long)dnRegNumber, DSC_GetRegisterName(regNum), (unsigned long)regValue);

    CHECK_ERROR_STATE();

    if ((regNum == DSC_RegPC) && !pcWritten) {
        pcWritten    = true;
        pcResetValue = regValue;
    }
    if (regNum == DSC_UnknownReg) {
//      rc = BDM_RC_OK;
        rc = BDM_RC_ILLEGAL_PARAMS;
    }
    else {
        rc = DSC_WriteRegister(regNum, (uint32_t)regValue);
    }
    if (rc != BDM_RC_OK) {
        Logging::print("DiRegisterWrite(0x%X,%s) Failed, reason= %s\n",
                       dnRegNumber, DSC_GetRegisterName(regNum), USBDM_GetErrorString(rc));
        return setErrorState(DI_ERR_NONFATAL, rc);
    }
    return setErrorState(DI_OK);
}
コード例 #2
0
//! 2.2.6.1 Write Value to Register
//!
//! @param dnRegNumber
//! @param drvValue
//!
USBDM_GDI_DECLSPEC
DiReturnT DiRegisterWrite ( DiUInt32T        dnRegNumber,
                            DiRegisterValueT drvValue ) {
   LOGGING;
   U32c  value(drvValue);
   USBDM_ErrorCode rc = BDM_RC_OK;

   log.print("DiRegisterWrite(0x%X(%d) <= 0x%08X)\n", dnRegNumber, dnRegNumber, (uint32_t)value);

   CHECK_ERROR_STATE();

   if (dnRegNumber > S12Z_RegCCR) {
      return setErrorState(DI_ERR_PARAM, ("Illegal register identifier"));
   }
   rc = USBDM_WriteReg(dnRegNumber,  value);
   if ((dnRegNumber == S12Z_RegPC) && !pcWritten) {
      log.print("Saving initial PC write = 0x%08X)\n", (uint32_t)value);
      pcWritten    = true;
      pcResetValue = value;
   }
   if (rc != BDM_RC_OK) {
      log.error("0x%X Failed, reason= %s\n",
           dnRegNumber, USBDM_GetErrorString(rc));
      return setErrorState(DI_ERR_NONFATAL, rc);
   }
   return setErrorState(DI_OK);
}
//! 2.2.6.2 Read Value from Register
//!
//! @param dnRegNumber
//! @param drvValue
//!
USBDM_GDI_API
DiReturnT DiRegisterRead ( DiUInt32T         dnRegNumber,
                           pDiRegisterValueT drvValue ) {
    unsigned long dataValue = 0xDEADBEEF;
    DSC_Registers_t regNum = mapReg(dnRegNumber);
    USBDM_ErrorCode rc = BDM_RC_OK;

//   Logging::print("DiRegisterRead(reg# 0x%X(%d))\n", regNum, regNum);
//   Logging::print("DiRegisterRead(%s)\n", DSC_GetRegisterName(regNum));

    CHECK_ERROR_STATE();

    if (regNum == DSC_UnknownReg) {
        dataValue = dnRegNumber;
//      rc = BDM_RC_OK;
        rc = BDM_RC_ILLEGAL_PARAMS;
    }
    else {
        rc = DSC_ReadRegister(regNum, &dataValue);
    }
    if (rc != BDM_RC_OK) {
        Logging::print("DiRegisterRead(0x%X,%s) Failed, reason= %s\n",
                       dnRegNumber, DSC_GetRegisterName(regNum), USBDM_GetErrorString(rc));
        return setErrorState(DI_ERR_NONFATAL, rc);
    }
    *drvValue = (U32c)dataValue;
    Logging::print("DiRegisterRead(0x%X,%s) => %lX\n", dnRegNumber, DSC_GetRegisterName(regNum), dataValue);
    return setErrorState(DI_OK);
}
コード例 #4
0
//! 2.2.6.2 Read Value from Register
//!
//! @param dnRegNumber
//! @param drvValue
//!
USBDM_GDI_DECLSPEC
DiReturnT DiRegisterRead ( DiUInt32T         dnRegNumber,
                           pDiRegisterValueT drvValue ) {
   LOGGING;
   unsigned long     dataValue = 0xDEADBEEF;
   DSC_Registers_t regNum = mapReg(dnRegNumber);
   USBDM_ErrorCode   rc        = BDM_RC_OK;
   log.print("0x%X(%d)\n", dnRegNumber, dnRegNumber);
//   log.print("DiRegisterRead(%s)\n", DSC_GetRegisterName(regNum));

   CHECK_ERROR_STATE();

   if (regNum == DSC_UnknownReg) {
      dataValue = dnRegNumber;
//      rc = BDM_RC_OK;
      rc = BDM_RC_ILLEGAL_PARAMS;
   }
   else {
      rc = bdmInterface->readReg(regNum, &dataValue);
   }
   if (rc != BDM_RC_OK) {
      log.print("DiRegisterRead(0x%X,%s) Failed, reason= %s\n",
            dnRegNumber, getDSCRegName(regNum), USBDM_GetErrorString(rc));
      return setErrorState(DI_ERR_NONFATAL, rc);
   }
   *drvValue = (U32c)dataValue;
   log.print("(0x%X,%s) => %8lX\n", dnRegNumber, getDSCRegName(regNum), dataValue);
   return setErrorState(DI_OK);
}
コード例 #5
0
ファイル: Device.cpp プロジェクト: mpweinge/KinectHandTracker
void XN_CALLBACK_TYPE onErrorStateChanged(XnStatus errorState, void* /*pCookie*/)
{
	if (errorState != XN_STATUS_OK)
	{
		setErrorState(xnGetStatusString(errorState));
	}
	else
	{
		setErrorState(NULL);
	}
}
コード例 #6
0
ファイル: Device.cpp プロジェクト: Arkapravo/OpenNI2
	virtual void onDeviceStateChanged(const openni::DeviceInfo* pInfo, openni::DeviceState errorState)
	{
		if (strcmp(pInfo->getUri(), g_device.getDeviceInfo().getUri()) == 0)
		{
			if (errorState != 0)
			{
				setErrorState("Device is in error state! (error %d)", errorState);
			}
			else
			{
				setErrorState("");
			}
		}
	}
コード例 #7
0
//! 2.2.6.2 Read Value from Register
//!
//! @param dnRegNumber
//! @param drvValue
//!
USBDM_GDI_API
DiReturnT DiRegisterRead ( DiUInt32T         dnRegNumber,
                           pDiRegisterValueT drvValue ) {
unsigned long dataValue = 0xDEADBEEF;
USBDM_ErrorCode rc = BDM_RC_OK;

   Logging::print("DiRegisterRead(0x%X(%d))\n", dnRegNumber, dnRegNumber);

   CHECK_ERROR_STATE();

   if (dnRegNumber>=cfv234regID_FIRST_DEBUG_REG) {
      dnRegNumber -= cfv234regID_FIRST_DEBUG_REG;
      rc = USBDM_ReadDReg(dnRegNumber,&dataValue);
      Logging::print("DiRegisterRead(0x%X(%s) => 0x%08X)\n", dnRegNumber, getCFVxDebugRegName(dnRegNumber), (uint32_t)dataValue);
   }
   else if (dnRegNumber >= cfv234regID_FIRST_CONTROL_REG) {
      dnRegNumber -= cfv234regID_FIRST_CONTROL_REG;
      rc = USBDM_ReadCReg(dnRegNumber,&dataValue);
      Logging::print("DiRegisterRead(0x%X(%s) => 0x%08X)\n", dnRegNumber, getCFVxControlRegName(dnRegNumber), (uint32_t)dataValue);
   }
   else {
      switch (dnRegNumber) {
         case cfv234regID_pc :
            rc = USBDM_ReadCReg(CFVx_CRegPC,&dataValue);
            Logging::print("DiRegisterRead(0x%X(%s) => 0x%08X)\n", CFVx_CRegPC, getCFVxControlRegName(CFVx_CRegPC), (uint32_t)dataValue);
            break;
         case cfv234regID_sr :
            rc = USBDM_ReadCReg(CFVx_CRegSR,&dataValue);
            Logging::print("DiRegisterRead(0x%X(%s) => 0x%08X)\n", CFVx_CRegSR, getCFVxControlRegName(CFVx_CRegSR), (uint32_t)dataValue);
            break;
         default : // D0-7, A0-7
            if (dnRegNumber<=cfv234regID_a7) {
               rc = USBDM_ReadReg(dnRegNumber,&dataValue);
               Logging::print("DiRegisterRead(0x%X(%s) => 0x%08X)\n", dnRegNumber, getCFVxRegName(dnRegNumber), (uint32_t)dataValue);
            }
            else {
               Logging::print("DiRegisterRead(Illegal reg# = 0x%X (%d)\n", dnRegNumber, dnRegNumber);
               rc = BDM_RC_ILLEGAL_PARAMS;
            }
            break;
      }
   }
   if (rc != BDM_RC_OK) {
      Logging::print("DiRegisterRead(0x%X) => error\n", dnRegNumber);
      return setErrorState(DI_ERR_NONFATAL, rc);
   }
   *drvValue = (U32c)dataValue;
   Logging::print("0x%X(%d) => 0x%08X\n", dnRegNumber, dnRegNumber, dataValue);
   return setErrorState(DI_OK);
}
コード例 #8
0
//! 2.2.6.1 Write Value to Register
//!
//! @param dnRegNumber
//! @param drvValue
//!
USBDM_GDI_API
DiReturnT DiRegisterWrite ( DiUInt32T        dnRegNumber,
                            DiRegisterValueT drvValue ) {
   LOGGING;
   U32c  value(drvValue);
   USBDM_ErrorCode rc = BDM_RC_OK;

//   Logging::print("DiRegisterWrite(0x%X(%d) <= 0x%08X)\n", dnRegNumber, dnRegNumber, (uint32_t)value);

   CHECK_ERROR_STATE();

   if (dnRegNumber>cfv234regID_FIRST_DEBUG_REG) {
      dnRegNumber -= cfv234regID_FIRST_DEBUG_REG;
      Logging::print("DiRegisterWriteD(0x%X(%s) <= 0x%08X)\n", dnRegNumber, getCFVxDebugRegName(dnRegNumber), (uint32_t)value);
      rc = USBDM_WriteDReg(dnRegNumber,value);
   }
   else if (dnRegNumber > cfv234regID_FIRST_CONTROL_REG) {
      dnRegNumber -= cfv234regID_FIRST_CONTROL_REG;
      Logging::print("DiRegisterWriteC(0x%X(%s) <= 0x%08X)\n", dnRegNumber, getCFVxControlRegName(dnRegNumber), (uint32_t)value);
      rc = USBDM_WriteCReg(dnRegNumber,value);
   }
   else {
      switch (dnRegNumber) {
         case cfv234regID_pc :
            Logging::print("DiRegisterWrite(0x%X(%s) <= 0x%08X)\n", CFVx_CRegPC, getCFVxControlRegName(CFVx_CRegPC), (uint32_t)value);
            rc = USBDM_WriteCReg(CFVx_CRegPC,value);
            break;
         case cfv234regID_sr :
            Logging::print("DiRegisterWrite(0x%X(%s) <= 0x%08X)\n", CFVx_CRegSR, getCFVxControlRegName(CFVx_CRegSR), (uint32_t)value);
            rc = USBDM_WriteCReg(CFVx_CRegSR,value);
            break;
         default : // D0-7, A0-7
            if (dnRegNumber<=cfv234regID_a7) {
               Logging::print("DiRegisterWrite(0x%X(%s) <= 0x%08X)\n", dnRegNumber, getCFVxRegName(dnRegNumber), (uint32_t)value);
               rc = USBDM_WriteReg(dnRegNumber,value);
            }
            else {
               Logging::print("DiRegisterWrite(illegal reg# = 0x%X (%d)\n", dnRegNumber, dnRegNumber);
               rc = BDM_RC_ILLEGAL_PARAMS;
            }
            break;
      }
   }
   if (rc != BDM_RC_OK) {
//      Logging::error("DiRegisterWrite(0x%X,%s) Failed, reason= %s\n",
//            dnRegNumber, DSC_GetRegisterName(regNum), USBDM_GetErrorString(rc));
      return setErrorState(DI_ERR_NONFATAL, rc);
   }
   return setErrorState(DI_OK);
}
//!  2.2.7.1 Set Breakpoint
//!
//! @param pdnBreakpointId
//! @param dbBreakpoint
//!
USBDM_GDI_API
DiReturnT DiBreakpointSet ( DiBpResultT *pdnBreakpointId,
                            DiBpT        dbBreakpoint ) {

    Logging::print("DiBreakpointSet() - not implemented\n");
    return setErrorState(DI_ERR_NOTSUPPORTED);
}
コード例 #10
0
ファイル: Device.cpp プロジェクト: Arkapravo/OpenNI2
	virtual void onDeviceDisconnected(const openni::DeviceInfo* pInfo)
	{
		if (strcmp(pInfo->getUri(), g_device.getDeviceInfo().getUri()) == 0)
		{
			setErrorState("Device disconnected!");
		}
	}
コード例 #11
0
//!  2.2.7.3 Clear All Breakpoints
//!
USBDM_GDI_DECLSPEC
DiReturnT DiBreakpointClearAll ( void ) {

   LOGGING_Q;
   log.print("- not implemented\n");
   return setErrorState(DI_ERR_NOTSUPPORTED);
}
コード例 #12
0
//!  2.2.7.1 Set Breakpoint
//!
//! @param pdnBreakpointId
//! @param dbBreakpoint
//!
USBDM_GDI_DECLSPEC
DiReturnT DiBreakpointSet ( DiBpResultT *pdnBreakpointId,
                             DiBpT        dbBreakpoint ) {
   LOGGING_Q;
   log.print("- not implemented\n");
   return setErrorState(DI_ERR_NOTSUPPORTED);
}
コード例 #13
0
//!  2.2.7.3 Clear All Breakpoints
//!
USBDM_GDI_DECLSPEC
DiReturnT DiBreakpointClearAll ( void ) {
   LOGGING_E;
//
//   CHECK_ERROR_STATE();
//
//   return DiBreakpointClear(breakpointId);
   return setErrorState(DI_ERR_NOTSUPPORTED);
}
コード例 #14
0
//!  2.2.8.2 Execute a Single Step
//!
//! @param dnNrInstructions
//!
USBDM_GDI_DECLSPEC
DiReturnT DiExecSingleStep ( DiUInt32T dnNrInstructions ) {
   LOGGING_Q;

   USBDM_ErrorCode BDMrc;
   log.print("(%d)\n", dnNrInstructions);

   CHECK_ERROR_STATE();

   if (dnNrInstructions>1) {
      log.print("() - Only a single step is supported!\n");
      return setErrorState(DI_ERR_PARAM, ("Only a single step is allowed"));
   }
   BDMrc = USBDM_TargetStep();
   if (BDMrc != BDM_RC_OK) {
      return setErrorState(DI_ERR_NONFATAL, BDMrc);
   }
   return setErrorState(DI_OK);
}
コード例 #15
0
int QState::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QAbstractState::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 2)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 2;
    }
#ifndef QT_NO_PROPERTIES
    else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0:
            *reinterpret_cast< QAbstractState**>(_v) = initialState();
            break;
        case 1:
            *reinterpret_cast< QAbstractState**>(_v) = errorState();
            break;
        case 2:
            *reinterpret_cast< ChildMode*>(_v) = childMode();
            break;
        }
        _id -= 3;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0:
            setInitialState(*reinterpret_cast< QAbstractState**>(_v));
            break;
        case 1:
            setErrorState(*reinterpret_cast< QAbstractState**>(_v));
            break;
        case 2:
            setChildMode(*reinterpret_cast< ChildMode*>(_v));
            break;
        }
        _id -= 3;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 3;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 3;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 3;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 3;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 3;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 3;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
コード例 #16
0
//! 2.2.6.2 Read Value from Register
//!
//! @param dnRegNumber
//! @param drvValue
//!
USBDM_GDI_DECLSPEC
DiReturnT DiRegisterRead ( DiUInt32T         dnRegNumber,
                           pDiRegisterValueT drvValue ) {
   unsigned long dataValue = 0xDEADBEEF;
   USBDM_ErrorCode rc = BDM_RC_OK;
   LOGGING;
   log.print("0x%X(%d)\n", dnRegNumber, dnRegNumber);

   CHECK_ERROR_STATE();

   if (dnRegNumber > S12Z_RegCCR) {
      return setErrorState(DI_ERR_PARAM, ("Illegal register identifier"));
   }
   rc = USBDM_ReadReg(dnRegNumber,  &dataValue);
   if (rc != BDM_RC_OK) {
      log.print("DiRegisterRead(0x%X) => error\n", dnRegNumber);
      return setErrorState(DI_ERR_NONFATAL, rc);
   }
   *drvValue = (U32c)dataValue;
   log.print("0x%lX(%ld) => 0x%08lX\n", (unsigned long)dnRegNumber, (unsigned long)dnRegNumber, (unsigned long)dataValue);
   return setErrorState(DI_OK);
}
コード例 #17
0
int QtStateMachine::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: started(); break;
        case 1: stopped(); break;
        case 2: finished(); break;
        case 3: start(); break;
        case 4: stop(); break;
        case 5: d_func()->_q_start(); break;
        case 6: d_func()->_q_process(); break;
        default: ;
        }
        _id -= 7;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QtState**>(_v) = rootState(); break;
        case 1: *reinterpret_cast< QtAbstractState**>(_v) = initialState(); break;
        case 2: *reinterpret_cast< QtAbstractState**>(_v) = errorState(); break;
        case 3: *reinterpret_cast< QString*>(_v) = errorString(); break;
        }
        _id -= 4;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 1: setInitialState(*reinterpret_cast< QtAbstractState**>(_v)); break;
        case 2: setErrorState(*reinterpret_cast< QtAbstractState**>(_v)); break;
        }
        _id -= 4;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 4;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 4;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 4;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 4;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 4;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 4;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
コード例 #18
0
//!  2.2.8.2 Execute a Single Step
//!
//! @param dnNrInstructions
//!
USBDM_GDI_API
DiReturnT DiExecSingleStep ( DiUInt32T dnNrInstructions ) {
    USBDM_ErrorCode BDMrc;

    Logging::print("DiExecSingleStep(%d)\n", dnNrInstructions);

    CHECK_ERROR_STATE();

#if (TARGET == MC56F80xx)
    BDMrc = DSC_TargetStepN(dnNrInstructions);
#else
    if (dnNrInstructions>1) {
        Logging::print("DiExecSingleStep() - Only a single step is supported!\n");
        return setErrorState(DI_ERR_PARAM, ("Only a single step is allowed"));
    }
    BDMrc = USBDM_TargetStep();
#endif

    if (BDMrc != BDM_RC_OK) {
        return setErrorState(DI_ERR_NONFATAL, BDMrc);
    }
    return setErrorState(DI_OK);
}
コード例 #19
0
//!  2.2.7.2 Clear a Breakpoint
//!
//! @param dnBreakpointId
//!
USBDM_GDI_DECLSPEC
DiReturnT DiBreakpointClear ( DiUInt32T dnBreakpointId ) {
   LOGGING_E;
//
//unsigned long bdmscrValue;
//
//   CHECK_ERROR_STATE();
//
//   if (dnBreakpointId != breakpointId)
//      return setErrorState(DI_ERR_PARAM, ("Clearing non-existent breakpoint"));
//
//   breakpointId = 0;
//
//   USBDM_ReadStatusReg(&bdmscrValue);
//   USBDM_WriteControlReg(bdmscrValue&~(HC08_BDCSCR_BKPTEN|HC08_BDCSCR_FTS));
//
//   return setErrorState(DI_OK);
   return setErrorState(DI_ERR_NOTSUPPORTED);
}
コード例 #20
0
//!  2.2.7.1 Set Breakpoint
//!
//! @param pdnBreakpointId
//! @param dbBreakpoint
//!
USBDM_GDI_DECLSPEC
DiReturnT DiBreakpointSet ( DiBpResultT *pdnBreakpointId,
                             DiBpT        dbBreakpoint ) {
   LOGGING_E;

//   unsigned long bdmscrValue;
//   U32c bkptAddress;
//   unsigned long breakpointModifier = HC08_BDCSCR_FTS;
//
//   CHECK_ERROR_STATE();
//
//   if (dbBreakpoint.dbtBpType & DI_BPT_EXECUTE) {
//      // Execute breakpoint
//      bkptAddress        = dbBreakpoint.u.exe.daBp;
//      breakpointModifier = 0;
//   }
//   else if (dbBreakpoint.dbtBpType & (DI_BPT_READ|DI_BPT_WRITE|DI_BPT_VALUE)) {
//      // Data read/write bkpt
//      bkptAddress = dbBreakpoint.u.rwv.daBp;
//   }
//   else
//      return setErrorState(DI_ERR_PARAM, ("Illegal breakpoint type"));
//
//   // Can only support 1 breakpoint
//   if (breakpointId != 0) {
//      log.print("DiBreakpointSet(0x%4X) - Too many breakpoints\n", (uint32_t)bkptAddress);
//      return setErrorState(DI_ERR_PARAM, ("Too many breakpoints"));
//   }
//
//   breakpointId = 1;
//
//   USBDM_WriteDReg(HCS08_DRegBKPT, (uint32_t)bkptAddress);
//   currentBreakPointAddress = bkptAddress;
//   USBDM_ReadStatusReg(&bdmscrValue);
//   USBDM_WriteControlReg(bdmscrValue|HC08_BDCSCR_BKPTEN|breakpointModifier);
//   log.print("DiBreakpointSet(0x%4X, #%d:%s)\n",
//         (uint32_t)bkptAddress, breakpointId, breakpointModifier?"E/D":"E");
//   pdnBreakpointId->dbBp   = dbBreakpoint;
//   pdnBreakpointId->dnBpId = breakpointId;
//   return setErrorState(DI_OK);
   return setErrorState(DI_ERR_NOTSUPPORTED);
}
コード例 #21
0
//!  2.2.8.6 Get DI Execution/Exit Status
//!
//! @param pdesExitStatus
//!
//! @return \n
//!     DI_OK              => OK \n
//!     DI_ERR_FATAL       => Error see \ref currentErrorString
//!
USBDM_GDI_API
DiReturnT DiExecGetStatus ( pDiExitStatusT pdesExitStatus ) {
    LOGGING;
    USBDM_ErrorCode BDMrc;
    static DiExitCauseT lastStatus = DI_WAIT_USER;
    static int pollCount = 0;
    OnceStatus_t onceStatus;
//   Logging::print("DiExecGetStatus()\n");

    // Defaults
    pdesExitStatus->dscCause = DI_WAIT_UNKNOWN;
    pdesExitStatus->dwBpId   = 0x1000400; // bkpt ID?
    pdesExitStatus->szReason = (DiStringT)"unknown state";

// Removed as prevents CW retry strategy
//   CHECK_ERROR_STATE();

    // Update status or autoconnect (includes status update)
//   if (bdmOptions.autoReconnect)
//      DIrc = targetConnect();
//   else
//      DIrc = getBDMStatus(&USBDMStatus);

//   if (DIrc != DI_OK) {
//      Logging::print("DiExecGetStatus()=> connect()/getStatus() failed\n");
//      return DIrc;
//   }

    pdesExitStatus->szReason = (DiStringT)getBDMStatusName(&USBDMStatus);

    BDMrc = DSC_GetStatus(&onceStatus);
    if (BDMrc != BDM_RC_OK) {
        Logging::print("DiExecGetStatus() - Failed, BDMrc=%s\n", USBDM_GetErrorString(BDMrc));
        return setErrorState(DI_ERR_NONFATAL, BDMrc);
    }

    switch (onceStatus) {
    case stopMode:
    case debugMode:
    case unknownMode:
    default:
        // Halted - in debug halted mode
        pdesExitStatus->dscCause = DI_WAIT_UNKNOWN; // for DSC
        pdesExitStatus->szReason = (DiStringT)"Debug Halted";
        if ((lastStatus != pdesExitStatus->dscCause) || (pollCount++>20)) {
            pollCount = 0;
            Logging::print("DiExecGetStatus() - %s\n", DSC_GetOnceStatusName(onceStatus));
            Logging::print("DiExecGetStatus() status change => DI_WAIT_MISCELLANEOUS, (%s)\n",
                           pdesExitStatus->szReason);
        }
        break;
    case executeMode :
    case externalAccessMode:
        // Processor executing
        pdesExitStatus->dscCause = DI_WAIT_RUNNING;
        pdesExitStatus->szReason = (DiStringT)"Running";
        if ((lastStatus != pdesExitStatus->dscCause) || (pollCount++>20)) {
            pollCount = 0;
            Logging::print("DiExecGetStatus() - %s\n", DSC_GetOnceStatusName(onceStatus));
            Logging::print("DiExecGetStatus() status change => DI_WAIT_RUNNING, (%s)\n",
                           pdesExitStatus->szReason);
        }
        break;
    }
    lastStatus = pdesExitStatus->dscCause;
    return setErrorState(DI_OK);
}
コード例 #22
0
//! 2.2.6.2 Read Value from Register
//!
//! @param dnRegNumber
//! @param drvValue
//!
USBDM_GDI_DECLSPEC
DiReturnT DiRegisterRead ( DiUInt32T         dnRegNumber,
                           pDiRegisterValueT drvValue ) {
   LOGGING;
   log.print("0x%X(%d)\n", dnRegNumber, dnRegNumber);

   unsigned long     dataValue = 0xDEADBEEF;
   USBDM_ErrorCode   rc        = BDM_RC_OK;
   log.print("0x%X(%d)\n", dnRegNumber, dnRegNumber);

   if (forceMassErase) {
      // Dummy register reads until device in unsecured
      *drvValue = (U32c)dataValue;
      return setErrorState(DI_OK);
   }
   CHECK_ERROR_STATE();

   if (dnRegNumber>cfv1regID_FIRST_DEBUG_regID_BYTE)
      switch (dnRegNumber) {
         case cfv1regID_xcsr_byte :
            rc = USBDM_ReadStatusReg(&dataValue);
            break;
         case cfv1regID_csr2_byte :
            rc = USBDM_ReadDReg(CFV1_DRegCSR2byte,&dataValue);
            break;
         case cfv1regID_csr3_byte :
            rc = USBDM_ReadDReg(CFV1_DRegCSR3byte,&dataValue);
            break;
         default                  :
            log.print("DiRegisterRead(Illegal Reg# 0x%X(%d)\n", dnRegNumber, dnRegNumber);
            rc = BDM_RC_ILLEGAL_PARAMS;
            break;
      }
   else if (dnRegNumber>cfv1regID_FIRST_DEBUG_REG)
      rc = USBDM_ReadDReg(dnRegNumber-cfv1regID_FIRST_DEBUG_REG,&dataValue);
   else if (dnRegNumber > cfv1regID_FIRST_CONTROL_REG)
      rc = USBDM_ReadCReg(dnRegNumber-cfv1regID_FIRST_CONTROL_REG,&dataValue);
   else {
      switch (dnRegNumber) {
         case cfv1regID_pc :
            rc = USBDM_ReadCReg(CFV1_CRegPC,&dataValue);
            break;
         case cfv1regID_sr :
            rc = USBDM_ReadCReg(CFV1_CRegSR,&dataValue);
            break;
         default : // D0-7, A0-7
            if (dnRegNumber>15) {
               log.print("DiRegisterRead(Illegal Reg# 0x%X(%d)\n", dnRegNumber, dnRegNumber);
               rc = BDM_RC_ILLEGAL_PARAMS;
            }
            else
               rc = USBDM_ReadReg(dnRegNumber,&dataValue);
            break;
      }
   }
   if (rc != BDM_RC_OK) {
      log.print("DiRegisterRead(0x%X) => error\n", dnRegNumber);
      return setErrorState(DI_ERR_NONFATAL, rc);
   }
   *drvValue = (U32c)dataValue;
   log.print("0x%lX(%ld) => 0x%08lX\n", (unsigned long)dnRegNumber, (unsigned long)dnRegNumber, (unsigned long)dataValue);
   return setErrorState(DI_OK);
}
コード例 #23
0
//! 2.2.6.1 Write Value to Register
//!
//! @param dnRegNumber
//! @param drvValue
//!
USBDM_GDI_DECLSPEC
DiReturnT DiRegisterWrite ( DiUInt32T        dnRegNumber,
                            DiRegisterValueT drvValue ) {
   LOGGING;
   U32c            value(drvValue);
   USBDM_ErrorCode rc  = BDM_RC_OK;

   log.print("(0x%X(%d) <= 0x%08X)\n", dnRegNumber, dnRegNumber, (uint32_t)value);

   CHECK_ERROR_STATE();

   if (dnRegNumber>cfv1regID_FIRST_DEBUG_regID_BYTE) {
      switch (dnRegNumber) {
         case cfv1regID_xcsr_byte :
            rc = USBDM_WriteControlReg(value);
            if (rc != BDM_RC_OK) {
               log.print("DiRegisterWrite(%s(0x%X)) Failed, reason= %s\n",
                     "XCSR.byte", dnRegNumber, USBDM_GetErrorString(rc));
               return setErrorState(DI_ERR_NONFATAL, rc);
            }
            break;
         case cfv1regID_csr2_byte :
            rc = USBDM_WriteDReg(CFV1_DRegCSR2byte,value);
            if (rc != BDM_RC_OK) {
               log.print("DiRegisterWrite(%s(0x%X)) Failed, reason= %s\n",
                     "CSR2.byte", dnRegNumber, USBDM_GetErrorString(rc));
               return setErrorState(DI_ERR_NONFATAL, rc);
            }
            break;
         case cfv1regID_csr3_byte :
            rc = USBDM_WriteDReg(CFV1_DRegCSR3byte,value);
            if (rc != BDM_RC_OK) {
               log.print("DiRegisterWrite(%s(0x%X)) Failed, reason= %s\n",
                     "CSR3.byte", dnRegNumber, USBDM_GetErrorString(rc));
               return setErrorState(DI_ERR_NONFATAL, rc);
            }
            break;
         default                  :
            log.print("DiRegisterWrite(Illegal Reg# 0x%X(%d)\n", dnRegNumber, dnRegNumber);
            rc = BDM_RC_ILLEGAL_PARAMS;
            break;
      }
   }
   else if (dnRegNumber>cfv1regID_FIRST_DEBUG_REG) {
      int regNum = dnRegNumber-cfv1regID_FIRST_DEBUG_REG;
      rc = USBDM_WriteDReg(regNum,value);
      if (rc != BDM_RC_OK) {
         log.print("DiRegisterWrite(%s(0x%X)) Failed, reason= %s\n",
               getCFV1DebugRegName(regNum), dnRegNumber, USBDM_GetErrorString(rc));
         return setErrorState(DI_ERR_NONFATAL, rc);
      }
   }
   else if (dnRegNumber > cfv1regID_FIRST_CONTROL_REG) {
      int regNum = dnRegNumber-cfv1regID_FIRST_CONTROL_REG;
      rc = USBDM_WriteCReg(regNum,value);
      if (rc != BDM_RC_OK) {
         log.print("DiRegisterWrite(%s(0x%X)) Failed, reason= %s\n",
               getCFV1ControlRegName(regNum), dnRegNumber, USBDM_GetErrorString(rc));
         return setErrorState(DI_ERR_NONFATAL, rc);
      }
   }
   else {
      switch (dnRegNumber) {
         case cfv1regID_pc : /*  PC */
            if (!pcWritten) {
               log.print("Saving initial PC write = 0x%08X)\n", (uint32_t)value);
               pcWritten    = true;
               pcResetValue = value;
            }
            rc = USBDM_WriteCReg(CFV1_CRegPC,value);
            if (rc != BDM_RC_OK) {
               log.print("DiRegisterWrite(%s(0x%X)) Failed, reason= %s\n",
                     "PC", dnRegNumber, USBDM_GetErrorString(rc));
               return setErrorState(DI_ERR_NONFATAL, rc);
            }
            break;
         case cfv1regID_sr :
            rc = USBDM_WriteCReg(CFV1_CRegSR,value);
            if (rc != BDM_RC_OK) {
               log.print("DiRegisterWrite(%s(0x%X)) Failed, reason= %s\n",
                     "SR", dnRegNumber, USBDM_GetErrorString(rc));
               return setErrorState(DI_ERR_NONFATAL, rc);
            }
            break;
         default : // D0-7, A0-7
            if (dnRegNumber>15) {
               log.print("DiRegisterWrite(Illegal Reg# 0x%X(%d)\n", dnRegNumber, dnRegNumber);
               rc = BDM_RC_ILLEGAL_PARAMS;
            }
            else {
               rc = USBDM_WriteReg(dnRegNumber,value);
               if (rc != BDM_RC_OK) {
                  log.print("DiRegisterWrite(%s(0x%X)) Failed, reason= %s\n",
                        getCFV1RegName(dnRegNumber), dnRegNumber, USBDM_GetErrorString(rc));
                  return setErrorState(DI_ERR_NONFATAL, rc);
               }
            }
            break;
      }
   }
   if (rc != BDM_RC_OK) {
      log.error("0x%X Failed, reason= %s\n",
           dnRegNumber, USBDM_GetErrorString(rc));
      return setErrorState(DI_ERR_NONFATAL, rc);
   }
   return setErrorState(DI_OK);
}
コード例 #24
0
/*
    Insert complete CIMResponseData entities into the cache. If the
    cache is at its max size limit, and there are more provider responses
    wait until it the size drops below the full limit.
    If the operation is closed, ignore the response.
    Return true if putCache worked, false if closed and nothing put into
    the cache.
    NOTE: This function assumes that responses for a request are serialized
    in _enqueueResponse See _enqueueResponseMutex.
*/
bool EnumerationContext::putCache(CIMResponseMessage*& response,
    bool providersComplete)
{
    PEG_METHOD_ENTER(TRC_ENUMCONTEXT, "EnumerationContext::putCache");

    PEGASUS_DEBUG_ASSERT(valid());

    // Design error if we ever get here with providers already set complete
    PEGASUS_DEBUG_ASSERT(!_providersComplete);

    CIMResponseDataMessage* localResponse =
        dynamic_cast<CIMResponseDataMessage*>(response);
    CIMResponseData & from = localResponse->getResponseData();
    //// from.traceResponseData();

    // If there is any binary data, reformat it to SCMO.  There are no
    // size counters for the binary data so reformat to generate
    // counters and make it compatible with the cache access mechanisms
    if (from.hasBinaryData())
    {
        from.resolveBinaryToSCMO();
        //// from.traceResponseData();
    }

#ifdef ENUMERATION_CONTEXT_DIAGNOSTIC_TRACE
    PEG_TRACE((TRC_ENUMCONTEXT, Tracer::LEVEL4,
        "putCache, ContextId=%s isComplete=%s cacheResponseDataType=%u "
            " cacheSize=%u putSize=%u putResponseDataType=%u clientClosed=%s",
        *Str(getContextId()),
        boolToString(providersComplete),
        _responseCache.getResponseDataContent(),
        _responseCache.size(), from.size(), from.getResponseDataContent(),
        boolToString(_clientClosed)));
#endif

    // This test should not be required.  Somewhere in the processing there
    // is a rare return of an erronous response from OOP. This covers that
    // case until we find the issue.  It issues an error a discard trace
    if (from.getResponseDataContent()!=_responseCache.getResponseDataContent())
    {
        PEG_TRACE((TRC_DISCARDED_DATA, Tracer::LEVEL2,
            "Pull Provider Response DataContentType in error. cacheType=%u "
            "responseType=%u "
            "ResponseMsgType=%s ContextId=%s",
            _responseCache.getResponseDataContent(),
            from.getResponseDataContent(),
            MessageTypeToString(response->getType()),
            *Str(getContextId()) ));
        trace();
        // This is temp for testing. KS_TODO delete this console display
        //// cout << System::getCurrentASCIITime()
        ////      << "Error CIMResponseDataMismatch "
        ////     << getContextId() << endl;

        CIMException sysErr = CIMException(CIM_ERR_FAILED,
            "Internal Error in EnumerationContext processing");
        setErrorState(sysErr);
        // Output warning log to indicate that this system failure has occurred

        Logger::put(
                Logger::ERROR_LOG, System::CIMSERVER, Logger::WARNING,
                "Response msg data type mismatch from providers."
                "Internal Error in EnumerationContext processing. "
                " ContextId=", *Str(getContextId() ));
        return _clientClosed;

    }
    // If an operation has closed the enumerationContext
    // ignore any received responses until the providersComplete is received
    // and then remove the Context.
    if (_clientClosed)
    {
        PEG_METHOD_EXIT();
        return false;
    }
    else  // client not closed
    {
        // put the current response into the cache. Lock cache for this
        // operation

        _responseCache.appendResponseData(from);

        // set providersComplete flag from flag in call parameter.
        _providersComplete = providersComplete;

        // test and set the high water mark for this cache.
        if (responseCacheSize() > _cacheHighWaterMark)
        {
            _cacheHighWaterMark = responseCacheSize();
        }
    }

    // Return true indicating that input added to cache and cache is still open
    PEG_METHOD_EXIT();
    return true;
}
コード例 #25
0
//!  2.2.8.2 Execute a Single Step
//!
//! @param dnNrInstructions
//!
USBDM_GDI_DECLSPEC
DiReturnT DiExecSingleStep ( DiUInt32T dnNrInstructions ) {
   LOGGING_Q;
   log.print("(%d)\n", dnNrInstructions);

   USBDM_ErrorCode BDMrc;
   long unsigned ccrValue;
   long unsigned pcValue;
   unsigned char currentOpcode;
   const int interruptMask = (1<<3);
   const int tapOpcode  = 0x84;
   const int tpaOpcode  = 0x85;
   const int seiOpcode  = 0x9B;
   const int cliOpcode  = 0x9A;
   const int waitOpcode = 0x8F;
   const int rtiOpcode  = 0x80;
   const int swiOpcode  = 0x83;
   const int stopOpcode = 0x8E;

   CHECK_ERROR_STATE();
#if (TARGET == MC56F80xx)
   BDMrc = DSC_TargetStepN(dnNrInstructions);
#else
   if (dnNrInstructions>1) {
      log.print("DiExecSingleStep() - Only a single step is supported!\n");
      return setErrorState(DI_ERR_PARAM, ("Only a single step is allowed"));
   }
/*
 * Cases to consider when masking interrupts during step
 *
 * +--------+-----------+---------+-----------------------------------------------------+
 * | Opcode | Initial I | Final I | Problem - action                                    |
 * +--------+-----------+---------+-----------------------------------------------------+
 * | ---    |     1     |    X    | None - no action (interrupts already masked)        |
 * +--------+-----------+---------+-----------------------------------------------------+
 * | CLI    |     0     |    ?    | It may be possible for an interrupt to occur,       |
 * | WAIT   |           |         | setting I-flag which is then incorrectly cleared.   |
 * | STOP   |           |         | (I don't think it applies to CLI but be safe.)      |
 * | SWI    |           |         | - don't 'fix' CCR                                   |
 * +--------+-----------+---------+-----------------------------------------------------+
 * | RTI    |     0     |    1    | Contrived but possible situation. I flag            |
 * |        |           |         | incorrectly cleared - don't 'fix' CCR               |
 * +--------+-----------+---------+-----------------------------------------------------+
 * | SEI    |     0     |    1    | The instruction may set I-flag which is then        |
 * | TAP    |     0     |    1    | incorrectly cleared - don't 'fix' CCR               |
 * +--------+-----------+---------+-----------------------------------------------------+
 * | TPA    |     0     |    X    | The wrong value is transferred to A - fix A         |
 * +--------+-----------+---------+-----------------------------------------------------+
 * | ---    |     0     |    0    | CCR change - clear I-flag in new CCR                |
 * +--------+-----------+---------+-----------------------------------------------------+
 */
   if (bdmOptions.maskInterrupts) {
      log.print("DiExecSingleStep() - checking if interrupt masking needed\n");
      USBDM_ReadReg(HCS08_RegCCR, &ccrValue);
      if ((ccrValue&interruptMask) != 0) {
         // Interrupts already masked - just step
         BDMrc = USBDM_TargetStep();
      }
      else {
         // Mask interrupts
         log.print("DiExecSingleStep() - masking interrupts\n");
         USBDM_WriteReg(HCS08_RegCCR, ccrValue|interruptMask);
         // Get current instruction opcode
         USBDM_ReadReg(HCS08_RegPC, &pcValue);
         USBDM_ReadMemory(1,1,pcValue,&currentOpcode);
         // Do a step
         BDMrc = USBDM_TargetStep();
         switch(currentOpcode) {
            case cliOpcode  :
            case waitOpcode :
            case seiOpcode  :
            case tapOpcode  :
            case rtiOpcode  :
            case swiOpcode  : // Not ever stepped - treated as subroutine?
            case stopOpcode :
               log.print("DiExecSingleStep() - skipping CCR restore\n");
               // Don't 'fix' CCR as updated by instruction or int ack
               break;
            case tpaOpcode :
               // Fix A & CCR  (clear I flag)
               log.print("DiExecSingleStep() - fixing A & CCR reg\n");
               USBDM_WriteReg(HCS08_RegA, ccrValue&~interruptMask);
               USBDM_WriteReg(HCS08_RegCCR, ccrValue&~interruptMask);
               break;
            default :
               // Fix CCR (clear I flag)
               // Unmask interrupts
               log.print("DiExecSingleStep() - fixing CCR reg\n");
               USBDM_ReadReg(HCS08_RegCCR, &ccrValue);
               USBDM_WriteReg(HCS08_RegCCR, ccrValue&~interruptMask);
               break;
         }
      }
   }
   else
      BDMrc = USBDM_TargetStep();
#endif
   if (BDMrc != BDM_RC_OK) {
      return setErrorState(DI_ERR_NONFATAL, BDMrc);
   }
   return setErrorState(DI_OK);
}
コード例 #26
0
//!  2.2.8.6 Get DI Execution/Exit Status
//!
//! @param pdesExitStatus
//!
//! @return \n
//!     DI_OK              => OK \n
//!     DI_ERR_FATAL       => Error see \ref currentErrorString
//!
USBDM_GDI_API
DiReturnT DiExecGetStatus ( pDiExitStatusT pdesExitStatus ) {
   LOGGING;
   USBDM_ErrorCode BDMrc;
   static DiExitCauseT lastStatus = DI_WAIT_USER;

//   Logging::print("DiExecGetStatus()\n");

   // Defaults
   pdesExitStatus->dscCause = DI_WAIT_UNKNOWN;
   pdesExitStatus->dwBpId   = 0x1000400; // bkpt ID?
   pdesExitStatus->szReason = (DiStringT)"unknown state";

// Removed as prevents CW retry strategy
//   CHECK_ERROR_STATE();

   if (bdmOptions.autoReconnect) {
      USBDM_ErrorCode bdmRc = targetConnect(softConnectOptions);

      if (bdmRc != BDM_RC_OK) {
         Logging::print("DiExecGetStatus()=> connect failed\n");
         return setErrorState(DI_ERR_COMMUNICATION, bdmRc);
      }
   }
   else {
      USBDM_GetBDMStatus(&USBDMStatus);
   }
//   pdesExitStatus->szReason = (DiStringT)getBDMStatusName(&USBDMStatus);

   if (USBDMStatus.reset_recent == RESET_DETECTED) {
      Logging::print("DiExecGetStatus()=>Target has been reset\n");
      mtwksDisplayLine("Target RESET detected\n");
   }
   if (bdmOptions.usePSTSignals) {
      // Check processor state using PST signals
      if (USBDMStatus.halt_state) {
         // Processor halted
         pdesExitStatus->dscCause = DI_WAIT_UNKNOWN;
         pdesExitStatus->szReason = (DiStringT)"Debug Halted";
         if (lastStatus != pdesExitStatus->dscCause) {
            Logging::print("DiExecGetStatus(PST) status change => DI_WAIT_UNKNOWN, (%s)\n",
                  pdesExitStatus->szReason);
            }
      }
      else {
         // Processor executing
         pdesExitStatus->dscCause = DI_WAIT_RUNNING;
         pdesExitStatus->szReason = (DiStringT)"Running";
         if (lastStatus != pdesExitStatus->dscCause) {
            Logging::print("DiExecGetStatus(PST) status change => DI_WAIT_RUNNING, (%s)\n",
                  pdesExitStatus->szReason);
            }
      }
   }
   else {
      // Probe D0 register - if fail assume processor running!
      // BUG - If stopped D0 can still be read so CW thinks the target is halted
      //       but is still running.
      unsigned long int dummy;
      BDMrc = USBDM_ReadReg(CFVx_RegD0, &dummy);
      if (BDMrc == BDM_RC_OK) {
         // Processor halted
         pdesExitStatus->dscCause = DI_WAIT_UNKNOWN;
         pdesExitStatus->szReason = (DiStringT)"Debug Halted";
         if (lastStatus != pdesExitStatus->dscCause) {
            Logging::print("DiExecGetStatus() status change => DI_WAIT_UNKNOWN, (%s)\n",
                  pdesExitStatus->szReason);
         }
      }
      else {
         // Processor executing
         pdesExitStatus->dscCause = DI_WAIT_RUNNING;
         pdesExitStatus->szReason = (DiStringT)"Running";
         if (lastStatus != pdesExitStatus->dscCause) {
            Logging::print("DiExecGetStatus() status change => DI_WAIT_RUNNING, (%s)\n",
                  pdesExitStatus->szReason);
         }
      }
   }
   lastStatus = pdesExitStatus->dscCause;
   return setErrorState(DI_OK);
}
コード例 #27
0
//!  2.2.7.3 Clear All Breakpoints
//!
USBDM_GDI_API
DiReturnT DiBreakpointClearAll ( void ) {

    Logging::print("DiBreakpointClearAll() - not implemented\n");
    return setErrorState(DI_ERR_NOTSUPPORTED);
}
コード例 #28
0
ファイル: statisticsobject.cpp プロジェクト: aachenmax/YUView
void StatisticsObject::readStatisticsFromFile(int frameIdx, int typeID)
{
    try {
        QFile inputFile(p_srcFilePath);

        if(inputFile.open(QIODevice::ReadOnly) == false)
            return;

        StatisticsItem anItem;
        QTextStream in(&inputFile);
        
        Q_ASSERT_X(p_pocTypeStartList.contains(frameIdx) && p_pocTypeStartList[frameIdx].contains(typeID), "StatisticsObject::readStatisticsFromFile", "POC/type not found in file. Do not call this function with POC/types that do not exist.");
        qint64 startPos = p_pocTypeStartList[frameIdx][typeID];
        if (bFileSortedByPOC)
        {
          // If the statistics file is sorted by POC we have to start at the first entry of this POC and parse the 
          // file until another POC is encountered. If this is not done, some information from a different typeID 
          // could be ignored during parsing.
          
          // Get the position of the first line with the given frameIdx
          startPos = std::numeric_limits<qint64>::max();
          QMap<int,qint64>::iterator it;
          for (it = p_pocTypeStartList[frameIdx].begin(); it != p_pocTypeStartList[frameIdx].end(); it++)
            if (it.value() < startPos)
              startPos = it.value();
        }

        // fast forward
        in.seek(startPos);

        while (!in.atEnd())
        {
            // read one line
            QString aLine = in.readLine();

            // get components of this line
            QStringList rowItemList = parseCSVLine(aLine, ';');

            if (rowItemList[0].isEmpty())
                continue;

            int poc = rowItemList[0].toInt();
            int type = rowItemList[5].toInt();

            // if there is a new poc, we are done here!
            if( poc != frameIdx )
                break;
            // if there is a new type and this is a non interleaved file, we are done here.
            if ( !bFileSortedByPOC && type != typeID )
                break;

            int value1 = rowItemList[6].toInt();
            int value2 = (rowItemList.count()>=8)?rowItemList[7].toInt():0;

            int posX = rowItemList[1].toInt();
            int posY = rowItemList[2].toInt();
            unsigned int width = rowItemList[3].toUInt();
            unsigned int height = rowItemList[4].toUInt();

            // Check if block is within the image range
            if (posX + width > p_width || posY + height > p_height) {
              // Block not in image
              throw("A block is outside of the specified image size in the statistics file.");
            }

            StatisticsType *statsType = getStatisticsType(type);
            Q_ASSERT_X(statsType != NULL, "StatisticsObject::readStatisticsFromFile", "Stat type not found.");
            anItem.type = ((statsType->visualizationType == colorMapType) || (statsType->visualizationType == colorRangeType)) ? blockType : arrowType;

            anItem.positionRect = QRect(posX, posY, width, height);

            anItem.rawValues[0] = value1;
            anItem.rawValues[1] = value2;
            anItem.color = QColor();

            if (statsType->visualizationType == colorMapType)
            {
                ColorMap colorMap = statsType->colorMap;
                anItem.color = colorMap[value1];
            }
            else if (statsType->visualizationType == colorRangeType)
            {
                if (statsType->scaleToBlockSize)
                    anItem.color = statsType->colorRange->getColor((float)value1 / (float)(anItem.positionRect.width() * anItem.positionRect.height()));
                else
                    anItem.color = statsType->colorRange->getColor((float)value1);
            }
            else if (statsType->visualizationType == vectorType)
            {
                // find color
                anItem.color = statsType->vectorColor;

                // calculate the vector size
                anItem.vector[0] = (float)value1 / statsType->vectorSampling;
                anItem.vector[1] = (float)value2 / statsType->vectorSampling;
            }

            // set grid color. if unset for this type, use color of type for grid, too
            if (statsType->gridColor.isValid())
            {
                anItem.gridColor = statsType->gridColor;
            }
            else
            {
                anItem.gridColor = anItem.color;
            }

            p_statsCache[poc][type].append(anItem);
        }
        inputFile.close();

    } // try
    catch ( const char * str ) {
        std::cerr << "Error while parsing: " << str << '\n';
        setErrorState(QString("Error while parsing meta data: ") + QString(str));
        return;
    }
    catch (...) {
        std::cerr << "Error while parsing.";
        setErrorState(QString("Error while parsing meta data."));
        return;
    }

    return;
}
コード例 #29
0
//!  2.2.8.6 Get DI Execution/Exit Status
//!
//! @param pdesExitStatus
//!
//! @return \n
//!     DI_OK              => OK \n
//!     DI_ERR_FATAL       => Error see \ref currentErrorString
//!
USBDM_GDI_DECLSPEC
DiReturnT DiExecGetStatus ( pDiExitStatusT pdesExitStatus ) {
   LOGGING;

   USBDM_ErrorCode      BDMrc;
   static DiExitCauseT  lastStatus     = DI_WAIT_USER;

   // Defaults
   pdesExitStatus->dscCause = DI_WAIT_UNKNOWN;
   pdesExitStatus->dwBpId   = 0; // bkpt ID?
   pdesExitStatus->szReason = (DiStringT)"unknown state";
   if (bdmOptions.autoReconnect) {
      USBDM_ErrorCode bdmRc = bdmInterface->targetConnectWithRetry(softConnectOptions);
      if (bdmRc != BDM_RC_OK) {
         log.print("=> DI_ERR_COMMUNICATION\n");
         return setErrorState(DI_ERR_COMMUNICATION, bdmRc);
      }
   }
   log.print("Calling USBDM_GetBDMStatus()\n");
   USBDMStatus_t USBDMStatus;
   USBDM_GetBDMStatus(&USBDMStatus);
//   pdesExitStatus->szReason = (DiStringT)getBDMStatusName(&USBDMStatus);
   if (USBDMStatus.connection_state == SPEED_NO_INFO) {
      log.print("=> NO_INFO\n");
      return setErrorState(DI_OK);
//      log.print("DiExecGetStatus()=>DI_ERR_COMMUNICATION\n");
//      return setErrorState(DI_ERR_NONFATAL, "Connection with target lost");
   }
   if (USBDMStatus.reset_recent == RESET_DETECTED) {
      log.print("=> Target has been reset\n");
      mtwksDisplayLine("Target RESET detected\n");
   }
   unsigned long status;
   BDMrc = USBDM_ReadStatusReg(&status);
   if (BDMrc != BDM_RC_OK) {
      log.print("=> Status read failed\n");
      return setErrorState(DI_OK);
//      return setErrorState(DI_ERR_NONFATAL, BDMrc);
   }
   if ((status&CFV1_XCSR_ENBDM) == 0) {
      log.print("=> ENBDM=0\n");
      return setErrorState(DI_OK);
//      log.print("DiExecGetStatus()=>DI_ERR_NONFATAL\n");
//      return setErrorState(DI_ERR_NONFATAL, "Connection with target lost");
   }
   if ((status&CFV1_XCSR_STOP) != 0) {
      // Stopped - low power sleep, treated as running
//      pdesExitStatus->dscCause = DI_WAIT_EXTERNAL|DI_WAIT_MISCELLANEOUS;
      pdesExitStatus->dscCause = DI_WAIT_RUNNING;
      pdesExitStatus->szReason = (DiStringT)"Target Stopped (Low power)...";
      if (lastStatus != pdesExitStatus->dscCause) {
//         log.print("DiExecGetStatus() status change => DI_WAIT_EXTERNAL|DI_WAIT_MISCELLANEOUS, (%s)\n",
         log.print("DiExecGetStatus() status change => DI_WAIT_RUNNING, (%s)\n",
               pdesExitStatus->szReason);
      }
   }
   else if ((status&CFV1_XCSR_HALT) != 0) {
      // Halted - in debug halted mode
      pdesExitStatus->dscCause = DI_WAIT_MISCELLANEOUS;
      pdesExitStatus->szReason = (DiStringT)"Debug Halted";
      if (lastStatus != pdesExitStatus->dscCause) {
         log.print("Status change => DI_WAIT_MISCELLANEOUS, (%s)\n",
               pdesExitStatus->szReason);
#if (TARGET==CFV1) && defined(CONVERT_RESETS_TO_EXCEPTIONS)
         // Read-write PC on halt
         // This causes Illegal Operand and Address Errors to be converted from
         // Resets to Exceptions.
         // Without this code the debugger is a bit misleading as it halts at the
         // start of the exception handler but then does the reset on resume!
         unsigned long PCValue;
         USBDM_ReadCReg(CFV1_CRegPC, &PCValue);
         USBDM_WriteCReg(CFV1_CRegPC, PCValue);
#endif
      }
   }
   else {
      // Processor executing
      pdesExitStatus->dscCause = DI_WAIT_RUNNING;
      pdesExitStatus->szReason = (DiStringT)"Running";
      if (lastStatus != pdesExitStatus->dscCause) {
         log.print("Status change => DI_WAIT_RUNNING, (%s)\n",
               pdesExitStatus->szReason);
      }
   }
   log.print("Reason = %s\n", pdesExitStatus->szReason);
   lastStatus = pdesExitStatus->dscCause;
   return setErrorState(DI_OK);
}
コード例 #30
0
ファイル: statisticsobject.cpp プロジェクト: aachenmax/YUView
void StatisticsObject::readHeaderFromFile()
{
    try {
        QFile inputFile(p_srcFilePath);

        if(inputFile.open(QIODevice::ReadOnly) == false)
            return;

        // cleanup old types
        p_statsTypeList.clear();

        // scan headerlines first
        // also count the lines per Frame for more efficient memory allocation
        // if an ID is used twice, the data of the first gets overwritten
        bool typeParsingActive = false;
        StatisticsType aType;

        while (!inputFile.atEnd())
        {
            // read one line
            QByteArray aLineByteArray = inputFile.readLine();
            QString aLine(aLineByteArray);

            // get components of this line
            QStringList rowItemList = parseCSVLine(aLine, ';');

            if (rowItemList[0].isEmpty())
                continue;

            // either a new type or a line which is not header finishes the last type
            if (((rowItemList[1] == "type") || (rowItemList[0][0] != '%')) && typeParsingActive)
            {
                // last type is complete
                p_statsTypeList.append(aType);

                // start from scratch for next item
                aType = StatisticsType();
                typeParsingActive = false;

                // if we found a non-header line, stop here
                if( rowItemList[0][0] != '%' )
                    return;
            }

            if (rowItemList[1] == "type")   // new type
            {
                aType.typeID = rowItemList[2].toInt();

                aType.readFromRow(rowItemList); // get remaining info from row
                typeParsingActive = true;
            }
            else if (rowItemList[1] == "mapColor")
            {
                int id = rowItemList[2].toInt();

                // assign color
                unsigned char r = (unsigned char)rowItemList[3].toInt();
                unsigned char g = (unsigned char)rowItemList[4].toInt();
                unsigned char b = (unsigned char)rowItemList[5].toInt();
                unsigned char a = (unsigned char)rowItemList[6].toInt();
                aType.colorMap[id] = QColor(r,g,b,a);
            }
            else if (rowItemList[1] == "range")
            {
                aType.colorRange = new ColorRange(rowItemList);
            }
            else if (rowItemList[1] == "defaultRange")
            {
                aType.colorRange = new DefaultColorRange(rowItemList);
            }
            else if (rowItemList[1] == "vectorColor")
            {
                unsigned char r = (unsigned char)rowItemList[2].toInt();
                unsigned char g = (unsigned char)rowItemList[3].toInt();
                unsigned char b = (unsigned char)rowItemList[4].toInt();
                unsigned char a = (unsigned char)rowItemList[5].toInt();
                aType.vectorColor = QColor(r,g,b,a);
            }
            else if (rowItemList[1] == "gridColor")
            {
                unsigned char r = (unsigned char)rowItemList[2].toInt();
                unsigned char g = (unsigned char)rowItemList[3].toInt();
                unsigned char b = (unsigned char)rowItemList[4].toInt();
                unsigned char a = 255;
                aType.gridColor = QColor(r,g,b,a);
            }
            else if (rowItemList[1] == "scaleFactor")
            {
                aType.vectorSampling = rowItemList[2].toInt();
            }
            else if (rowItemList[1] == "scaleToBlockSize")
            {
                aType.scaleToBlockSize = (rowItemList[2] == "1");
            }
            else if (rowItemList[1] == "seq-specs")
            {
                QString seqName = rowItemList[2];
                QString layerId = rowItemList[3];
                // For now do nothing with this information.
                // Show the file name for this item instead.
                if (rowItemList[4].toInt()>0)
                    setWidth(rowItemList[4].toInt());
                if (rowItemList[5].toInt()>0)
                    setHeight(rowItemList[5].toInt());
                if (rowItemList[6].toDouble()>0.0)
                    setFrameRate(rowItemList[6].toDouble());
            }
        }

        inputFile.close();

    } // try
    catch ( const char * str ) {
        std::cerr << "Error while parsing meta data: " << str << '\n';
        setErrorState(QString("Error while parsing meta data: ") + QString(str));
        return;
    }
    catch (...) {
        std::cerr << "Error while parsing meta data.";
        setErrorState(QString("Error while parsing meta data."));
        return;
    }

    return;
}