diff --git a/app/src/main/cpp/SensorsProtocol.cpp b/app/src/main/cpp/SensorsProtocol.cpp index 3cc5dcb9..f382aa02 100644 --- a/app/src/main/cpp/SensorsProtocol.cpp +++ b/app/src/main/cpp/SensorsProtocol.cpp @@ -1991,12 +1991,12 @@ int FindNextCameraPhotoCommand(SIO_PARAM_SERIAL_DEF *pPortParam) DebugLog(0, szbuf, 'I'); return -1; } - //pPortParam->SerialCmdidx = -1; - break; + MakePtzStateQueryCommand(pPortParam, cmdidx); + return 1; case QUERY_PTZ_STATE: /* 查询云台状态信息*/ - ::memset(szbuf, 0, sizeof(szbuf)); - sprintf(szbuf, "下发命令sendptzstatecmd=%d!", pPortParam->sendptzstatecmd); - DebugLog(0, szbuf, 'I'); + //::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) @@ -2016,10 +2016,10 @@ int FindNextCameraPhotoCommand(SIO_PARAM_SERIAL_DEF *pPortParam) DebugLog(0, szbuf, 'I'); return -1; } - pPortParam->sendptzstatecmd++; - cmdidx = 0x08; - //pPortParam->SerialCmdidx = -1; - break; + //pPortParam->sendptzstatecmd++; + //cmdidx = 0x08; + MakePtzStateQueryCommand(pPortParam, cmdidx); + return 1; default: imagesize = 0xFF; @@ -2041,9 +2041,9 @@ int FindNextCameraPhotoCommand(SIO_PARAM_SERIAL_DEF *pPortParam) } break; } - ::memset(szbuf, 0, sizeof(szbuf)); - strcpy(szbuf, "make:sendptzstatecmd"); - DebugLog(0, szbuf, 'I'); + //::memset(szbuf, 0, sizeof(szbuf)); + //strcpy(szbuf, "make:sendptzstatecmd"); + //DebugLog(0, szbuf, 'I'); MakeCameraPhotoCommand(pPortParam, cmdidx, imagesize, packetsize, imagequality, srdt.sendphototime); return 1; @@ -2114,6 +2114,8 @@ void MakeCameraPhotoCommand(SIO_PARAM_SERIAL_DEF *pPortParam, uint8_t cmdidx, in sendbuf[i++] = LOBYTE(LOWORD(OneParam)); sendbuf[i++] = (uint8_t)TwoParam; /* 是否需要保存*/ break; + default: + break; } sendbuf[i] = CalLpc((u_char *)&sendbuf[6], i - 6); i += 1; @@ -2135,6 +2137,49 @@ void MakeCameraPhotoCommand(SIO_PARAM_SERIAL_DEF *pPortParam, uint8_t cmdidx, in //return; } +/********************************************************************************* + 生成 QueryPtzState命令 +**********************************************************************************/ +void MakePtzStateQueryCommand(SIO_PARAM_SERIAL_DEF *pPortParam, uint8_t cmdidx) +{ + int i, icurtime; + u_char *sendbuf; + //char szbuf[128]; + + sendbuf = pPortParam->PollCmd; + + //::memset(szbuf, 0, sizeof(szbuf)); + //strcpy(szbuf, "make:sendptzstatecmd start!"); + //DebugLog(0, szbuf, 'I'); + i = 0; + sendbuf[i++] = 0x00; /* 强制等待时间*/ + sendbuf[i++] = 0x00; /* 强制等待时间*/ + sendbuf[i++] = 0x68; /* 起始字符*/ + sendbuf[i++] = (uint8_t)0x00; /* length */ + sendbuf[i++] = (uint8_t)0x00; /* length */ + sendbuf[i++] = 0x68; /* 起始字符*/ + sendbuf[i++] = (uint8_t)pPortParam->cameraaddr;/* 传感器地址*/ + sendbuf[i++] = cmdidx; /* 命令字*/ + sendbuf[i] = CalLpc((u_char *)&sendbuf[6], i - 6); + i += 1; + sendbuf[i++] = 0x16; /* 信息尾*/ + sendbuf[3] = (uint8_t)((i - 10) >> 8); + sendbuf[4] = (uint8_t)(i - 10); + pPortParam->cmdlen = i; +#if 0 + //::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; +} + // 准备发送云台指令 int Gm_CtrlPtzCmd(SIO_PARAM_SERIAL_DEF *pPortParam, uint32_t ptzcmd) { diff --git a/app/src/main/cpp/SensorsProtocol.h b/app/src/main/cpp/SensorsProtocol.h index 464d4268..0d7633ee 100644 --- a/app/src/main/cpp/SensorsProtocol.h +++ b/app/src/main/cpp/SensorsProtocol.h @@ -534,6 +534,8 @@ int GM_CameraSerialTimer(SIO_PARAM_SERIAL_DEF *pPortParam); int QueryPtzState(PTZ_STATE *ptz_state, int cmdidx, const char *serfile, unsigned int baud, int addr); +void MakePtzStateQueryCommand(SIO_PARAM_SERIAL_DEF *pPortParam, uint8_t cmdidx); + int Query_BDGNSS_Data(BD_GNSS_DATA *BD_data, int samptime, const char *serfile, unsigned int baud); int GM_BdSerialTimer(SIO_PARAM_SERIAL_DEF *pPortParam);