From 2af459d57abadc7d8a4fe234ef6beda36e137196 Mon Sep 17 00:00:00 2001 From: jxjajs Date: Sun, 13 Apr 2025 19:17:40 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=9F=A5=E8=AF=A2=E4=BA=91?= =?UTF-8?q?=E5=8F=B0=E4=BD=8D=E7=BD=AE=E5=91=BD=E4=BB=A4=E4=B8=8D=E4=B8=8B?= =?UTF-8?q?=E5=8F=91BUg?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/cpp/SensorsProtocol.cpp | 60 ++++++++++++++++++++++------ 1 file changed, 47 insertions(+), 13 deletions(-) diff --git a/app/src/main/cpp/SensorsProtocol.cpp b/app/src/main/cpp/SensorsProtocol.cpp index beba165d..3cc5dcb9 100644 --- a/app/src/main/cpp/SensorsProtocol.cpp +++ b/app/src/main/cpp/SensorsProtocol.cpp @@ -1978,7 +1978,12 @@ int FindNextCameraPhotoCommand(SIO_PARAM_SERIAL_DEF *pPortParam) srdt.iLastGetPhotoNo = -1; return 1; case NOTIFY_PTZ_CLOSE: /* 通知云台关闭电源*/ - if (pPortParam->sendptzstatecmd > 0) + if (pPortParam->sendptzstatecmd == 0) + { + cmdidx = 0xA0; + pPortParam->sendptzstatecmd++; + } + else { pPortParam->SerialCmdidx = -2; pPortParam->sendptzstatecmd = 0; @@ -1986,12 +1991,24 @@ int FindNextCameraPhotoCommand(SIO_PARAM_SERIAL_DEF *pPortParam) DebugLog(0, szbuf, 'I'); return -1; } - cmdidx = 0xA0; - pPortParam->sendptzstatecmd++; //pPortParam->SerialCmdidx = -1; break; case QUERY_PTZ_STATE: /* 查询云台状态信息*/ - if (pPortParam->sendptzstatecmd > 0) + ::memset(szbuf, 0, sizeof(szbuf)); + sprintf(szbuf, "下发命令sendptzstatecmd=%d!", pPortParam->sendptzstatecmd); + DebugLog(0, szbuf, 'I'); + //if (pPortParam->sendptzstatecmd > 0) +#if 1 + if (pPortParam->sendptzstatecmd == 0) + { + pPortParam->sendptzstatecmd++; + cmdidx = 0x08; + //::memset(szbuf, 0, sizeof(szbuf)); + //sprintf(szbuf, "下发命令sendptzstatecmd=%d!", pPortParam->sendptzstatecmd); + //DebugLog(0, szbuf, 'I'); + } + else +#endif { pPortParam->SerialCmdidx = -2; pPortParam->sendptzstatecmd = 0; @@ -1999,7 +2016,7 @@ int FindNextCameraPhotoCommand(SIO_PARAM_SERIAL_DEF *pPortParam) DebugLog(0, szbuf, 'I'); return -1; } - pPortParam->sendptzstatecmd++; + pPortParam->sendptzstatecmd++; cmdidx = 0x08; //pPortParam->SerialCmdidx = -1; break; @@ -2024,7 +2041,11 @@ int FindNextCameraPhotoCommand(SIO_PARAM_SERIAL_DEF *pPortParam) } break; } - MakeCameraPhotoCommand(pPortParam, cmdidx, imagesize, packetsize, imagequality, srdt.sendphototime); + ::memset(szbuf, 0, sizeof(szbuf)); + strcpy(szbuf, "make:sendptzstatecmd"); + DebugLog(0, szbuf, 'I'); + + MakeCameraPhotoCommand(pPortParam, cmdidx, imagesize, packetsize, imagequality, srdt.sendphototime); return 1; } @@ -2039,6 +2060,10 @@ void MakeCameraPhotoCommand(SIO_PARAM_SERIAL_DEF *pPortParam, uint8_t cmdidx, in sendbuf = pPortParam->PollCmd; + ::memset(szbuf, 0, sizeof(szbuf)); + strcpy(szbuf, "make:sendptzstatecmd start!"); + DebugLog(0, szbuf, 'I'); + //return; icurtime = phototime; i = 0; sendbuf[i++] = 0x00; /* 强制等待时间*/ @@ -2096,11 +2121,17 @@ void MakeCameraPhotoCommand(SIO_PARAM_SERIAL_DEF *pPortParam, uint8_t cmdidx, in sendbuf[3] = (uint8_t)((i - 10) >> 8); sendbuf[4] = (uint8_t)(i - 10); pPortParam->cmdlen = i; - if(0x08 == cmdidx) +#if 1 + //::memset(szbuf, 0, sizeof(szbuf)); + //strcpy(szbuf, "make over!"); + //DebugLog(0, szbuf, 'I'); + if(0x08 == cmdidx) { + ::memset(szbuf, 0, sizeof(szbuf)); strcpy(szbuf, "生成查询云台位置命令!"); DebugLog(0, szbuf, 'I'); } +#endif //return; } @@ -3119,7 +3150,7 @@ void SendCameraCmdFormPollCmdBuf(SIO_PARAM_SERIAL_DEF *pPortParam) char buf[128]; int len, ret; int64_t lctime; - char szbuf[512]; + //char szbuf[512]; memset(buf, 0, sizeof(buf)); lctime = get_msec(); @@ -3132,8 +3163,8 @@ void SendCameraCmdFormPollCmdBuf(SIO_PARAM_SERIAL_DEF *pPortParam) if (pPortParam->SendCmdFlag && (pPortParam->RevCmdFlag == 0)) { //pPortParam->RetryTimeCnt++; - strcpy(szbuf, "1-send"); - DebugLog(0, szbuf, 'E'); + //strcpy(szbuf, "1-send"); + //DebugLog(0, szbuf, 'E'); if ((lctime - pPortParam->RetryTimeCnt > 3 * pPortParam->RetryTime) || (lctime - pPortParam->RetryTimeCnt < 0)) { @@ -3160,8 +3191,8 @@ void SendCameraCmdFormPollCmdBuf(SIO_PARAM_SERIAL_DEF *pPortParam) if (pPortParam->SendCmdFlag && pPortParam->RevCmdFlag) { - strcpy(szbuf, "2-send"); - DebugLog(0, szbuf, 'E'); + //strcpy(szbuf, "2-send"); + //DebugLog(0, szbuf, 'E'); // 清除当前命令 ClearCameraCmdFormPollCmdBuf(pPortParam); } @@ -3460,8 +3491,11 @@ int QueryPtzState(PTZ_STATE *ptz_state, int cmdidx, const char *serfile, unsign if (0x00 == flag) { - sprintf(szbuf, "云台状态查询启动串口定时器!"); + ::memset(szbuf, 0, sizeof(szbuf)); + strcpy(szbuf, "云台状态查询启动串口定时器!"); DebugLog(8, szbuf, 'I'); + //sprintf(szbuf, "下发命令sendptzstatecmd=%d!", cameraport->sendptzstatecmd); + //DebugLog(0, szbuf, 'I'); for (;;) { usleep(10);