|
@@ -170,6 +170,19 @@ void CGpioServiceSession::Handle_QueryCurrSet(SpReqAnsContext<GpioService_QueryC
|
|
|
ctx->Answer(Error_NotSupport);
|
|
|
}
|
|
|
|
|
|
+void CGpioServiceSession::Handle_GetDevInfo(SpReqAnsContext<GpioService_GetDevInfo_Req,
|
|
|
+ GpioService_GetDevInfo_Ans>::Pointer ctx)
|
|
|
+{
|
|
|
+ DbgToBeidou(ctx->link, __FUNCTION__)();
|
|
|
+ m_pEntity->GetDevInfo(ctx);
|
|
|
+}
|
|
|
+
|
|
|
+void CGpioServiceSession::Handle_Exit(SpOnewayCallContext<GpioService_Exit_Info>::Pointer ctx)
|
|
|
+{
|
|
|
+ DbgToBeidou(ctx->link, __FUNCTION__)();
|
|
|
+ m_pEntity->Exit(ctx);
|
|
|
+}
|
|
|
+
|
|
|
bool isnostr(const char* str)
|
|
|
{
|
|
|
int len = strlen(str);
|
|
@@ -231,8 +244,7 @@ struct GpioInitTask : public ITaskSp {
|
|
|
ErrorCodeEnum err = m_entity->Initial();
|
|
|
if (err == Error_Succeed)
|
|
|
{
|
|
|
- LOG_TRACE("Gpio open succeeded.");
|
|
|
-
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Gpio open succeeded.");
|
|
|
//oiltest 20130118 for audiodg handle
|
|
|
m_entity->GetStatus(PHONEPICKUP, NULL);
|
|
|
|
|
@@ -256,7 +268,7 @@ struct GpioInitTask : public ITaskSp {
|
|
|
else
|
|
|
{
|
|
|
DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("gpio open failed(%d).", err);
|
|
|
- m_pTransactionContext->SendAnswer(Error_Unexpect);
|
|
|
+ m_pTransactionContext->SendAnswer(Error_Succeed);
|
|
|
}
|
|
|
}
|
|
|
};
|
|
@@ -444,6 +456,7 @@ ErrorCodeEnum CGpioEntity::Initial()
|
|
|
LogWarn(Severity_Middle, Error_Unexpect, GPIO_UserErrorCode_GetDevCategory_Failed, errMsg.GetData());
|
|
|
}
|
|
|
initTries = 0;
|
|
|
+ m_bOpened = true;
|
|
|
break;
|
|
|
} else {
|
|
|
DevErrorInfo devErrInfo;
|
|
@@ -458,30 +471,32 @@ ErrorCodeEnum CGpioEntity::Initial()
|
|
|
}
|
|
|
} while (initTries < MAX_GPIO_INIT_TRIES);
|
|
|
|
|
|
- if (initTries != 0) {
|
|
|
- LOG_TRACE("open gpio failed.");
|
|
|
+ if (!m_bOpened) {
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("open gpio failed.");
|
|
|
err = Error_DevConnFailed;
|
|
|
}
|
|
|
-
|
|
|
- if (!m_bFuncVer2) {
|
|
|
- err = m_hDevHelper->WritePort(0, 0x00);
|
|
|
- if (err != Error_Succeed)
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("write ports(0) returned: %s)", SpStrError(err));
|
|
|
- err = m_hDevHelper->WritePort(1, 0x00);
|
|
|
- if (err != Error_Succeed)
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("write ports(1) returned: %s)", SpStrError(err));
|
|
|
- if (m_bNewVersion) {
|
|
|
- err = m_hDevHelper->WritePort(3, 0x00);
|
|
|
- if (err != Error_Succeed)
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("write ports(3) returned: %s)", SpStrError(err));
|
|
|
- }
|
|
|
- } else {
|
|
|
+ else {
|
|
|
+ if (!m_bFuncVer2) {
|
|
|
+ eErrDev = m_hDevHelper->WritePort(0, 0x00);
|
|
|
+ if (eErrDev != Error_Succeed)
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("write ports(0) returned: %s)", SpStrError(eErrDev));
|
|
|
+ eErrDev = m_hDevHelper->WritePort(1, 0x00);
|
|
|
+ if (eErrDev != Error_Succeed)
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("write ports(1) returned: %s)", SpStrError(eErrDev));
|
|
|
+ if (m_bNewVersion) {
|
|
|
+ eErrDev = m_hDevHelper->WritePort(3, 0x00);
|
|
|
+ if (eErrDev != Error_Succeed)
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("write ports(3) returned: %s)", SpStrError(eErrDev));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
#if defined(RVC_OS_LINUX)
|
|
|
- err = m_hDevHelper->SetStatus(GPIO_DEV_SN_LIGHT_SENSOR_ALL, GPIO_DEV_LIGHT_MODE_RESET);
|
|
|
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("write resetone returned: %s)", SpStrError(err));
|
|
|
+ eErrDev = m_hDevHelper->SetStatus(GPIO_DEV_SN_LIGHT_SENSOR_ALL, GPIO_DEV_LIGHT_MODE_RESET);
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("write resetone returned: %s)", SpStrError(eErrDev));
|
|
|
#endif //RVC_OS_LINUX
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//oilyang@20170214
|
|
|
eErrDev = Error_Unexpect;
|
|
|
CSmartPointer<IConfigInfo> spConfigRun;
|
|
@@ -499,6 +514,7 @@ ErrorCodeEnum CGpioEntity::Initial()
|
|
|
m_moveDisappearTimes = m_moveHoldTimes;
|
|
|
m_eMachineType = SP::Module::Comm::GetTerminalMachineInfo(this).type;
|
|
|
DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("machine type: %s", SP::Module::Comm::Type2Str(m_eMachineType));
|
|
|
+
|
|
|
return err;
|
|
|
}
|
|
|
|
|
@@ -612,8 +628,13 @@ void CGpioEntity::OnLog(const CAutoArray<CUUID>& SubIDs, const CUUID nLogID, con
|
|
|
DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("unkown event: 0x%X", dwUserCode);
|
|
|
return;
|
|
|
}
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("devseq[%d],mode[%d]close[%d]", Req.devseq, Req.mode, Req.close);
|
|
|
- m_bFuncVer2 ? SetEx(Req) : Set(Req);
|
|
|
+ if (m_bOpened) {
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("devseq[%d],mode[%d]close[%d]", Req.devseq, Req.mode, Req.close);
|
|
|
+ m_bFuncVer2 ? SetEx(Req) : Set(Req);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("devseq[%d],mode[%d]close[%d] cannot do that bcz devopen failed", Req.devseq, Req.mode, Req.close);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void CGpioEntity::WritePin(DWORD dwPinSeq, bool bHighLevel)
|
|
@@ -829,7 +850,7 @@ void CGpioEntity::Set(GpioService_Set_Info req)
|
|
|
void CGpioEntity::GetStatus(int deviceSeq, SpReqAnsContext<GpioService_GetStatus_Req, GpioService_GetStatus_Ans>::Pointer ctx)
|
|
|
{
|
|
|
/** 注意设备序号是实体内定义的逻辑,不是设备端口号,用作于计时器的ID去了*/
|
|
|
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("GetStatus with devseq %d", deviceSeq);
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("GetStatus with devseq %d", deviceSeq);
|
|
|
if (deviceSeq == PHONEPICKUP) {
|
|
|
CSimpleStringA initDriver = "";
|
|
|
int devicePort;
|
|
@@ -877,6 +898,52 @@ void CGpioEntity::OnPositiveFlickerResetTimerout(void* pData)
|
|
|
GetFunction()->SetTimer(pSCI->timerID, pListener, pSCI->setTime);
|
|
|
}
|
|
|
|
|
|
+void CGpioEntity::OnSelfTest(EntityTestEnum eTestType, CSmartPointer<ITransactionContext> pTransactionContext)
|
|
|
+{
|
|
|
+ if (!m_bOpened && m_hDevHelper) {
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("let selftest to restart it!");
|
|
|
+ pTransactionContext->SendAnswer(Error_InvalidState);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ else if(!m_bOpened) {
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("process failed before DevOpen, do not try to restart");
|
|
|
+ pTransactionContext->SendAnswer(Error_Succeed);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ pTransactionContext->SendAnswer(Error_Succeed);
|
|
|
+ return;
|
|
|
+}
|
|
|
+
|
|
|
+void CGpioEntity::GetDevInfo(SpReqAnsContext<GpioService_GetDevInfo_Req, GpioService_GetDevInfo_Ans>::Pointer ctx)
|
|
|
+{
|
|
|
+ if (!m_bOpened) {
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode(GpioService_LogCode_GetDevInfo).setResultCode("RTA2901")("GPIO未打开");
|
|
|
+ ctx->Answer(Error_DevNotAvailable, GPIO_UserErrorCode_DevOpen_Failed);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ DevCategoryInfo info = { 0 };
|
|
|
+ const ULONGLONG ullStart = SP::Module::Comm::RVCGetTickCount();
|
|
|
+ ErrorCodeEnum erroCode = m_hDevHelper->GetDevCategory(info);
|
|
|
+ const ULONGLONG ullEnd = SP::Module::Comm::RVCGetTickCount();
|
|
|
+ if (erroCode == Error_Succeed) {
|
|
|
+ ctx->Ans.model = info.szModel;
|
|
|
+ ctx->Ans.state = (int)info.eState;
|
|
|
+ ctx->Ans.type = info.szType;
|
|
|
+ ctx->Ans.version = CSimpleStringA::Format("%d.%d.%d.%d",
|
|
|
+ info.version.wMajor, info.version.wMinor, info.version.wRevision, info.version.wBuild);
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode(GpioService_LogCode_GetDevInfo)
|
|
|
+ .setAPI("DevAdapter::GetDevCategory").setCostTime(ullEnd - ullStart)("model: %s, state:%d, type:%s, version:%s"
|
|
|
+ , ctx->Ans.model.GetData(), ctx->Ans.state, ctx->Ans.type.GetData(), ctx->Ans.version.GetData());
|
|
|
+ ctx->Answer(erroCode);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode(GpioService_LogCode_GetDevInfo).setAPI("DevAdapter::GetDevCategory")
|
|
|
+ .setCostTime(ullEnd - ullStart).setResultCode("RTA2904")("GetDevInfo failed: %s", SpStrError(erroCode));
|
|
|
+ ctx->Answer(erroCode, GPIO_UserErrorCode_GetDevCategory_Failed);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
//老接口,用于控制灯
|
|
|
bool CGpioEntity::SetOutDriving(GpioService_Set_Info req, OutDrivingInfo od, ULONG iIndex, ULONG pinSeq)
|
|
|
{
|