|
|
@@ -12,34 +12,34 @@ static const char DEFAULT_ADAPTER_LIBRARY_NAME[] = "libDeviceControl.cmbsz.1.1.s
|
|
|
|
|
|
namespace
|
|
|
{
|
|
|
+/*
|
|
|
+PAD, Desk2S1.0: false
|
|
|
+* Stand2S, CardStore, Desk2S.2.0, Desk2S.2.1, Desk1S.1.0: true
|
|
|
+*/
|
|
|
bool IsNeedOpenUsb(CEntityBase* pCallerEntity)
|
|
|
{
|
|
|
bool result = false;
|
|
|
ErrorCodeEnum errCode = Error_Unexpect;
|
|
|
CSystemStaticInfo sysDevInfo;
|
|
|
errCode = pCallerEntity->GetFunction()->GetSystemStaticInfo(sysDevInfo);
|
|
|
- if (errCode != Error_Succeed) {
|
|
|
- Dbg("get device info failed while judge open usb or not");
|
|
|
- } else {
|
|
|
- CSimpleStringA strMachineType;
|
|
|
- strMachineType = sysDevInfo.strMachineType;
|
|
|
- WORD majorVersion = sysDevInfo.MachineVersion.GetMajor();
|
|
|
- WORD minorVersion = sysDevInfo.MachineVersion.GetMinor();
|
|
|
- CSimpleStringA machineVersion = CSimpleStringA::Format("%d.%d", majorVersion, minorVersion);
|
|
|
- Dbg("MachineType:%s, machineVersion:%s", strMachineType.GetData(), machineVersion.GetData());
|
|
|
+ CSimpleStringA strMachineType;
|
|
|
+ strMachineType = sysDevInfo.strMachineType;
|
|
|
+ WORD majorVersion = sysDevInfo.MachineVersion.GetMajor();
|
|
|
+ WORD minorVersion = sysDevInfo.MachineVersion.GetMinor();
|
|
|
+ CSimpleStringA machineVersion = CSimpleStringA::Format("%d.%d", majorVersion, minorVersion);
|
|
|
+ Dbg("MachineType:%s, machineVersion:%s", strMachineType.GetData(), machineVersion.GetData());
|
|
|
|
|
|
- if (!strMachineType.Compare("RVC.PAD", true)
|
|
|
- || (!strMachineType.Compare("RVC.Desk2S", true) && !machineVersion.Compare("1.0"))) {
|
|
|
- result = false;
|
|
|
- } else if (!strMachineType.Compare("RVC.Stand2S", true) || !strMachineType.Compare("RVC.CardStore", true)
|
|
|
- || (!strMachineType.Compare("RVC.Desk2S", true) && !machineVersion.Compare("2.0"))
|
|
|
- || (!strMachineType.Compare("RVC.Desk2S", true) && !machineVersion.Compare("2.1"))
|
|
|
- || (!strMachineType.Compare("RVC.Desk1S", true) && !machineVersion.Compare("1.0"))) {
|
|
|
- result = true;
|
|
|
- } else {
|
|
|
- //TODO:: if add new machine type
|
|
|
- result = true;
|
|
|
- }
|
|
|
+ if (!strMachineType.Compare("RVC.PAD", true)
|
|
|
+ || (!strMachineType.Compare("RVC.Desk2S", true) && !machineVersion.Compare("1.0"))) {
|
|
|
+ result = false;
|
|
|
+ } else if (!strMachineType.Compare("RVC.Stand2S", true) || !strMachineType.Compare("RVC.CardStore", true)
|
|
|
+ || (!strMachineType.Compare("RVC.Desk2S", true) && !machineVersion.Compare("2.0"))
|
|
|
+ || (!strMachineType.Compare("RVC.Desk2S", true) && !machineVersion.Compare("2.1"))
|
|
|
+ || (!strMachineType.Compare("RVC.Desk1S", true) && !machineVersion.Compare("1.0"))) {
|
|
|
+ result = true;
|
|
|
+ } else {
|
|
|
+ //TODO:: if add new machine type
|
|
|
+ result = true;
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
@@ -153,13 +153,9 @@ ErrorCodeEnum CDeviceControlFSM::InitializeTokenLib()
|
|
|
}
|
|
|
}
|
|
|
return eErr;
|
|
|
-
|
|
|
#else
|
|
|
-
|
|
|
return Error_NotSupport;
|
|
|
-
|
|
|
#endif //RVC_OS_WIN
|
|
|
-
|
|
|
}
|
|
|
|
|
|
ErrorCodeEnum CDeviceControlFSM::OnExit()
|
|
|
@@ -197,9 +193,11 @@ unsigned int CDeviceControlFSM::s0_on_event(FSMEvent* pEvt)
|
|
|
task->ctx = ue->ctx;
|
|
|
GetEntityBase()->GetFunction()->PostThreadPoolTask(task);
|
|
|
pEvt->SetHandled();
|
|
|
- m_bWorkingOp = true;
|
|
|
- WorkingOpTask *pOp = new WorkingOpTask(this);
|
|
|
- GetEntityBase()->GetFunction()->PostThreadPoolTask(pOp);
|
|
|
+#if defined(RVC_OS_WIN)
|
|
|
+ m_bWorkingOp = true;
|
|
|
+ WorkingOpTask* pOp = new WorkingOpTask(this);
|
|
|
+ GetEntityBase()->GetFunction()->PostThreadPoolTask(pOp);
|
|
|
+#endif //RVC_OS_WIN
|
|
|
return 0;
|
|
|
}
|
|
|
case USER_EVT_INIT_TOKEN:
|
|
|
@@ -209,10 +207,11 @@ unsigned int CDeviceControlFSM::s0_on_event(FSMEvent* pEvt)
|
|
|
task->ctx = ue->ctx;
|
|
|
GetEntityBase()->GetFunction()->PostThreadPoolTask(task);
|
|
|
pEvt->SetHandled();
|
|
|
- m_bWorkingOp = true;
|
|
|
- WorkingOpTask *pOp = new WorkingOpTask(this);
|
|
|
- GetEntityBase()->GetFunction()->PostThreadPoolTask(pOp);
|
|
|
-
|
|
|
+#if defined(RVC_OS_WIN)
|
|
|
+ m_bWorkingOp = true;
|
|
|
+ WorkingOpTask* pOp = new WorkingOpTask(this);
|
|
|
+ GetEntityBase()->GetFunction()->PostThreadPoolTask(pOp);
|
|
|
+#endif //RVC_OS_WIN
|
|
|
return 0;
|
|
|
}
|
|
|
default:
|
|
|
@@ -268,10 +267,7 @@ unsigned int CDeviceControlFSM::s4_on_event(FSMEvent* pEvt)
|
|
|
int CDeviceControlFSM::UsbControl(SpReqAnsContext<DeviceControlService_USB_Req,DeviceControlService_USB_Ans>::Pointer ctx)
|
|
|
{
|
|
|
Dbg("open %d",ctx->Req.open);
|
|
|
- const bool bIsNeedOpenUsb = IsNeedOpenUsb(m_pEntity);
|
|
|
- if(!bIsNeedOpenUsb){
|
|
|
- Dbg("no need open/close usb, this machine's usb is always open.");
|
|
|
- } else {
|
|
|
+ if(IsNeedOpenUsb(m_pEntity)) {
|
|
|
ControlType eType;
|
|
|
if (ctx->Req.open) {
|
|
|
eType = USB_PORT_ENABLE;
|
|
|
@@ -282,8 +278,9 @@ int CDeviceControlFSM::UsbControl(SpReqAnsContext<DeviceControlService_USB_Req,D
|
|
|
LogEvent(Severity_Middle, LOG_EVT_USB_CONTROL_OFF, "usb off");//control by gpio
|
|
|
LogEvent(Severity_Middle, LOG_EVT_USB_LIGHT_OFF, "usb off");//control by gpio
|
|
|
}
|
|
|
+ } else {
|
|
|
+ Dbg("no need open/close usb, this machine's usb is always open.");
|
|
|
}
|
|
|
-
|
|
|
ctx->Answer(Error_Succeed);
|
|
|
return 0;
|
|
|
}
|
|
|
@@ -291,13 +288,10 @@ int CDeviceControlFSM::UsbControl(SpReqAnsContext<DeviceControlService_USB_Req,D
|
|
|
int CDeviceControlFSM::GetUkeyIDx(SpReqAnsContext<DeviceControlService_GetUkeyID_Req, DeviceControlService_GetUkeyID_Ans>::Pointer ctx)
|
|
|
{
|
|
|
LOG_FUNCTION();
|
|
|
- if (ctx == NULL)
|
|
|
- {
|
|
|
+ if (ctx == NULL) {
|
|
|
Dbg("ctx is null.");
|
|
|
- ctx->Answer(Error_Null);
|
|
|
return 1;
|
|
|
}
|
|
|
-
|
|
|
#if defined(RVC_OS_WIN)
|
|
|
char pID[512];
|
|
|
ZeroMemory(pID, 512);
|
|
|
@@ -328,7 +322,6 @@ int CDeviceControlFSM::InitTokenx(SpReqAnsContext<DeviceControlService_InitToken
|
|
|
if (ctx == NULL)
|
|
|
{
|
|
|
Dbg("ctx is null.");
|
|
|
- ctx->Answer(Error_Null);
|
|
|
return 1;
|
|
|
}
|
|
|
#if defined(RVC_OS_WIN)
|
|
|
@@ -396,7 +389,7 @@ int CDeviceControlFSM::QueryUSB(SpReqAnsContext<DeviceControlService_QueryUSBSta
|
|
|
Dbg("connect to gpio failed.");
|
|
|
pGpio->SafeDelete();
|
|
|
pGpio = NULL;
|
|
|
- ctx->Answer(Error_Unexpect);
|
|
|
+ ctx->Answer(eErr);
|
|
|
return 0;
|
|
|
}
|
|
|
GpioService_QueryCurrSet_Req req;
|
|
|
@@ -411,19 +404,21 @@ int CDeviceControlFSM::QueryUSB(SpReqAnsContext<DeviceControlService_QueryUSBSta
|
|
|
else
|
|
|
{
|
|
|
Dbg("Query usb failed.");
|
|
|
- pGpio->SafeDelete();
|
|
|
+ pGpio->GetFunction()->CloseSession();
|
|
|
pGpio = NULL;
|
|
|
- ctx->Answer(Error_Unexpect);
|
|
|
+ ctx->Answer(eErr);
|
|
|
return 0;
|
|
|
}
|
|
|
}
|
|
|
return 0;
|
|
|
}
|
|
|
+/** 5s per times and quit after 100 times*/
|
|
|
void CDeviceControlFSM::WorkingOp()
|
|
|
{
|
|
|
int count = 0;
|
|
|
while(m_bWorkingOp)
|
|
|
{
|
|
|
+ //relate with eventconvert
|
|
|
LogEvent(Severity_Low,LOG_EVT_USB_CONTROL_OP,"ukey op.");
|
|
|
Sleep(5000);
|
|
|
count++;
|