|
|
@ -1,7 +1,6 @@
|
|
|
|
#include <jni.h>
|
|
|
|
#include <jni.h>
|
|
|
|
#include <string>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
@ -41,411 +40,6 @@ AI_DEF rallypntmsg[6][RALLY_DATA_NUM];
|
|
|
|
AI_DEF slantpntmsg[6][SLANTANGLE_DATA_NUM];
|
|
|
|
AI_DEF slantpntmsg[6][SLANTANGLE_DATA_NUM];
|
|
|
|
char logPath[512];
|
|
|
|
char logPath[512];
|
|
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
|
|
|
/*********************************************************************************
|
|
|
|
|
|
|
|
* 气象数据处理 *
|
|
|
|
|
|
|
|
**********************************************************************************/
|
|
|
|
|
|
|
|
static void PortDataProcess(void)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
float fvalue, fcorvalue, *fvalua, frnb/*, fwind*/;
|
|
|
|
|
|
|
|
//uint16_t uDevAddr;
|
|
|
|
|
|
|
|
unsigned char cmdidx;
|
|
|
|
|
|
|
|
int i, j, aipnt, datanum;
|
|
|
|
|
|
|
|
SIO_PARAM_SERIAL_DEF *pPortParam;
|
|
|
|
|
|
|
|
char szbuf[64];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pPortParam = &serialport;
|
|
|
|
|
|
|
|
//取出装置地址,开始处理地址+++
|
|
|
|
|
|
|
|
if (0x02 == pPortParam->m_au8RecvBuf[5])
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//pPortParam->devaddr = pPortParam->m_au8RecvBuf[4];
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
cmdidx = pPortParam->m_au8RecvBuf[5];
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
|
|
|
aipnt = pPortParam->SameTypeDevIdx;
|
|
|
|
|
|
|
|
uDevAddr = serialport->m_au8RecvBuf[4];
|
|
|
|
|
|
|
|
if (0 == srdt.IsReadWireTem)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (uDevAddr != pPortParam->devaddr)
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
fvalua = &fvalue;
|
|
|
|
|
|
|
|
datanum = pPortParam->m_au8RecvBuf[6];
|
|
|
|
|
|
|
|
if ((0x08 != cmdidx) && (0x09 != cmdidx))
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 0, j = 7; (i < datanum) && (j < 6 + pPortParam->m_au8RecvBuf[1]); i++, j += 5)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (0x08 == cmdidx)
|
|
|
|
|
|
|
|
fvalue = (pPortParam->m_au8RecvBuf[j + 1] << 24) + (pPortParam->m_au8RecvBuf[j + 2] << 16)
|
|
|
|
|
|
|
|
+ (pPortParam->m_au8RecvBuf[j + 3] << 8) + pPortParam->m_au8RecvBuf[j + 4];
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
*(u_char *)fvalua = pPortParam->m_au8RecvBuf[j + 4];
|
|
|
|
|
|
|
|
*((u_char *)fvalua + 1) = pPortParam->m_au8RecvBuf[j + 3];
|
|
|
|
|
|
|
|
*((u_char *)fvalua + 2) = pPortParam->m_au8RecvBuf[j + 2];
|
|
|
|
|
|
|
|
*((u_char *)fvalua + 3) = pPortParam->m_au8RecvBuf[j + 1];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (pPortParam->m_au8RecvBuf[j])
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
case 1: /*温度*/
|
|
|
|
|
|
|
|
weatherpntmsg[0] = fvalue;
|
|
|
|
|
|
|
|
LOGE("温度:%0.3f ", fvalue);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2: /*气压*/
|
|
|
|
|
|
|
|
weatherpntmsg[5] = fvalue;
|
|
|
|
|
|
|
|
LOGE("气压:%0.3f ", fvalue);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3: /*湿度*/
|
|
|
|
|
|
|
|
weatherpntmsg[1] = fvalue;
|
|
|
|
|
|
|
|
LOGE("湿度:%0.3f ", fvalue);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4: /*雨量*/
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 5: /*日照*/
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 6: /*风速*/
|
|
|
|
|
|
|
|
weatherpntmsg[2] = fvalue;
|
|
|
|
|
|
|
|
LOGE("风速:%0.3f ", fvalue);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 7: /*风向*/
|
|
|
|
|
|
|
|
weatherpntmsg[3] = fvalue;
|
|
|
|
|
|
|
|
LOGE("风向:%0.3f ", fvalue);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 8: /*拉力*/
|
|
|
|
|
|
|
|
case 9: /*倾角传感器X轴倾角*/
|
|
|
|
|
|
|
|
case 10: /*倾角传感器Y轴倾角*/
|
|
|
|
|
|
|
|
case 11: /*测温球导线温度*/
|
|
|
|
|
|
|
|
case 12: /*测温球内部温度*/
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 13: /*测温球导线X轴倾角*/
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 14: /*测温球导线Y轴倾角*/
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 15: /*测温球导线电流*/
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 16: /*测温球电池电压*/
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 17: /*A相泄漏电流平均值;*/
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 18: /*A相泄漏电流最大值;*/
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 19: /*A相超过3mA的脉冲频次*/
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 20: /*A相超过10mA的脉冲频次*/
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 21: /*B相泄漏电流平均值;*/
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 22: /*B相泄漏电流最大值;*/
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 23: /*B相超过3mA的脉冲频次*/
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 24: /*B相超过10mA的脉冲频次*/
|
|
|
|
|
|
|
|
case 25: /*C相泄漏电流平均值;*/
|
|
|
|
|
|
|
|
case 26: /*C相泄漏电流最大值;*/
|
|
|
|
|
|
|
|
case 27: /*C相超过3mA的脉冲频次*/
|
|
|
|
|
|
|
|
case 28: /*C相超过10mA的脉冲频次*/
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***************************************************************
|
|
|
|
|
|
|
|
* 按照协议格式化接收数据 *
|
|
|
|
|
|
|
|
***************************************************************/
|
|
|
|
|
|
|
|
static void RecvData(u_char *buf, int len)// 规约读数据处理
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int i, ictime;
|
|
|
|
|
|
|
|
//uint16_t crc, check;
|
|
|
|
|
|
|
|
SIO_PARAM_SERIAL_DEF *pPortParam;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pPortParam = &serialport;
|
|
|
|
|
|
|
|
ictime = (int)time(NULL);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (pPortParam->m_iRecvLen == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
pPortParam->iRecvTime = ictime;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if ((ictime - pPortParam->iRecvTime > 6) || (ictime - pPortParam->iRecvTime < 0))
|
|
|
|
|
|
|
|
pPortParam->iRecvTime = ictime;
|
|
|
|
|
|
|
|
else if (ictime - pPortParam->iRecvTime > 2)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
pPortParam->m_iRecvLen = 0;
|
|
|
|
|
|
|
|
pPortParam->m_iRevStatus = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
switch (pPortParam->m_iRevStatus)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
case 0: // 0x68
|
|
|
|
|
|
|
|
pPortParam->m_iRecvLen = 0;
|
|
|
|
|
|
|
|
pPortParam->m_au8RecvBuf[pPortParam->m_iRecvLen++] = buf[i];
|
|
|
|
|
|
|
|
if (0x68 == buf[i])
|
|
|
|
|
|
|
|
pPortParam->m_iRevStatus++;
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
pPortParam->m_iRevStatus = 18;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1: // len1
|
|
|
|
|
|
|
|
pPortParam->m_au8RecvBuf[pPortParam->m_iRecvLen++] = buf[i];
|
|
|
|
|
|
|
|
pPortParam->m_iRevStatus++;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2: // len2
|
|
|
|
|
|
|
|
pPortParam->m_au8RecvBuf[pPortParam->m_iRecvLen++] = buf[i];
|
|
|
|
|
|
|
|
if (buf[i] == pPortParam->m_au8RecvBuf[pPortParam->m_iRecvLen - 2])
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
pPortParam->m_iRevStatus++;
|
|
|
|
|
|
|
|
pPortParam->m_iNeedRevLength = buf[i] + 5;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
pPortParam->m_iRevStatus = 18;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3: // 0x68
|
|
|
|
|
|
|
|
pPortParam->m_au8RecvBuf[pPortParam->m_iRecvLen++] = buf[i];
|
|
|
|
|
|
|
|
pPortParam->m_iNeedRevLength--;
|
|
|
|
|
|
|
|
if (0x68 == buf[i])
|
|
|
|
|
|
|
|
pPortParam->m_iRevStatus++;
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
pPortParam->m_iRevStatus = 18;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4: // 正确接收数据
|
|
|
|
|
|
|
|
pPortParam->m_iNeedRevLength--;
|
|
|
|
|
|
|
|
pPortParam->m_au8RecvBuf[pPortParam->m_iRecvLen++] = buf[i];
|
|
|
|
|
|
|
|
if (pPortParam->m_iNeedRevLength > 0)
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (buf[i] != 0x16)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
pPortParam->m_iRevStatus = 18;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//if(CheckLpcError(serialport->m_au8RecvBuf, pPortParam->m_iRecvLen) == TRUE)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
PortDataProcess();
|
|
|
|
|
|
|
|
pPortParam->m_iRevStatus = 0;
|
|
|
|
|
|
|
|
pPortParam->RevCmdFlag = 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
pPortParam->m_iRecvLen = 0;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 255:// 错误接收数据
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
if (buf[i] == 0x68)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
pPortParam->m_iRevStatus = 1;
|
|
|
|
|
|
|
|
pPortParam->m_iRecvLen = 1;
|
|
|
|
|
|
|
|
pPortParam->m_au8RecvBuf[0] = buf[i];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (buf[i] == 0x16)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
pPortParam->m_au8RecvBuf[pPortParam->m_iRecvLen++] = buf[i];
|
|
|
|
|
|
|
|
pPortParam->m_iRevStatus = 0;
|
|
|
|
|
|
|
|
pPortParam->m_iRecvLen = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
pPortParam->m_au8RecvBuf[pPortParam->m_iRecvLen++] = buf[i];
|
|
|
|
|
|
|
|
if (pPortParam->m_iRecvLen > 200)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
pPortParam->m_iRecvLen = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int64_t get_msec(void)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
struct timeval tv;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gettimeofday(&tv, NULL);
|
|
|
|
|
|
|
|
int64_t time_in_msec = tv.tv_sec * 1000 + tv.tv_usec / 1000;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return time_in_msec;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//int inum =0;
|
|
|
|
|
|
|
|
//int itimecnt=0;
|
|
|
|
|
|
|
|
static int weather_comm(SERIAL_PARAM weatherport)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int fd = -1;
|
|
|
|
|
|
|
|
int len, i, ret, icnt = 0;
|
|
|
|
|
|
|
|
int64_t ictime, iruntime, isendtime, irecvtime;
|
|
|
|
|
|
|
|
unsigned char sendbuf[] = { 0x68,0x00,0x00,0x68,0x01,0x09,0x0a,0x16 };
|
|
|
|
|
|
|
|
char recvbuf[256], szbuf[512];
|
|
|
|
|
|
|
|
//char serial_description[] = "/dev/ttyS0";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
|
|
|
DIR *dir = opendir("/dev");
|
|
|
|
|
|
|
|
if (dir == NULL) {
|
|
|
|
|
|
|
|
LOGE("_test_ opendir");
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 读取目录项
|
|
|
|
|
|
|
|
struct dirent *entry;
|
|
|
|
|
|
|
|
while ((entry = readdir(dir)) != NULL) {
|
|
|
|
|
|
|
|
// 过滤出串口设备,通常以"ttyS"或"ttyUSB"开头
|
|
|
|
|
|
|
|
if ((strncmp(entry->d_name, "ttyS2", 5) == 0) ||
|
|
|
|
|
|
|
|
(strncmp(entry->d_name, "ttyS0", 5) == 0)) {
|
|
|
|
|
|
|
|
LOGE("_test_ Found serial port: %s\n", entry->d_name);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 关闭目录
|
|
|
|
|
|
|
|
closedir(dir);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
serialport.RevCmdFlag = 1;
|
|
|
|
|
|
|
|
serialport.m_iRecvLen = 0;
|
|
|
|
|
|
|
|
serialport.m_iRevStatus = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
set12VEnable(true);
|
|
|
|
|
|
|
|
setCam3V3Enable(true);
|
|
|
|
|
|
|
|
setRS485Enable(true);
|
|
|
|
|
|
|
|
sleep(2);
|
|
|
|
|
|
|
|
//ictime = (int)time(NULL);
|
|
|
|
|
|
|
|
ictime = get_msec();
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (fd < 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
fd = open(weatherport.pathname, O_RDWR | O_NDELAY);
|
|
|
|
|
|
|
|
//fd = open(weatherport.pathname, O_RDWR | O_NOCTTY);
|
|
|
|
|
|
|
|
if (fd < 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
LOGE("_test_ open serial error \n");
|
|
|
|
|
|
|
|
perror(weatherport.pathname);
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ret = set_port_attr(fd, weatherport.baudrate, weatherport.databit, weatherport.stopbit, weatherport.parity, 0, 0);/*9600 8n1 */
|
|
|
|
|
|
|
|
if (ret < 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
LOGE("_test_ set uart arrt faile \n");
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
usleep(10000);
|
|
|
|
|
|
|
|
//iruntime = (int)time(NULL);
|
|
|
|
|
|
|
|
iruntime = get_msec();
|
|
|
|
|
|
|
|
if ((iruntime - ictime > 120000) || (iruntime - ictime < 0))
|
|
|
|
|
|
|
|
ictime = iruntime;
|
|
|
|
|
|
|
|
if (iruntime - ictime > 20000)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
memset(szbuf, 0, sizeof(szbuf));
|
|
|
|
|
|
|
|
sprintf(szbuf, "气象采样时间=%0.3f秒,停止采样!", (iruntime - ictime) / 1000.0);
|
|
|
|
|
|
|
|
LOGE("%s", szbuf);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (1 == serialport.RevCmdFlag)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
set485WriteMode();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
len = write(fd, sendbuf, sizeof(sendbuf));/* 向串囗发送字符串 */
|
|
|
|
|
|
|
|
serialport.RevCmdFlag = 0;
|
|
|
|
|
|
|
|
LOGE("发送命令时间差%ld毫秒", get_msec() - isendtime);
|
|
|
|
|
|
|
|
//isendtime = time(NULL);
|
|
|
|
|
|
|
|
isendtime = get_msec();
|
|
|
|
|
|
|
|
if (len < 0) {
|
|
|
|
|
|
|
|
LOGE("write data error \n");
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
memset(szbuf, 0, sizeof(szbuf));
|
|
|
|
|
|
|
|
sprintf(szbuf, "Send:");
|
|
|
|
|
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
|
|
|
|
sprintf(szbuf, "%s %02X", szbuf, sendbuf[i]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
LOGE("%s", szbuf);
|
|
|
|
|
|
|
|
//icnt = 0;
|
|
|
|
|
|
|
|
//inum++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
tcdrain(fd);
|
|
|
|
|
|
|
|
//usleep(50000);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//irecvtime = time(NULL);
|
|
|
|
|
|
|
|
irecvtime = get_msec();
|
|
|
|
|
|
|
|
if ((irecvtime - isendtime > 6000) || (irecvtime - isendtime < 0))
|
|
|
|
|
|
|
|
isendtime = irecvtime;
|
|
|
|
|
|
|
|
if (irecvtime - isendtime > 300)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
LOGE("传感器超过%ld毫秒未应答", irecvtime - isendtime);
|
|
|
|
|
|
|
|
serialport.RevCmdFlag = 1;
|
|
|
|
|
|
|
|
serialport.m_iRecvLen = 0;
|
|
|
|
|
|
|
|
serialport.m_iRevStatus = 0;
|
|
|
|
|
|
|
|
close(fd);
|
|
|
|
|
|
|
|
fd = -1;
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
set485ReadMode();
|
|
|
|
|
|
|
|
memset(recvbuf, 0, sizeof(recvbuf));
|
|
|
|
|
|
|
|
len = read(fd, recvbuf, sizeof(recvbuf));/* 在串口读取字符串 */
|
|
|
|
|
|
|
|
if (len < 0) {
|
|
|
|
|
|
|
|
LOGE("serial read error \n");
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (0 == len)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//icnt++;
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(szbuf, 0, sizeof(szbuf));
|
|
|
|
|
|
|
|
sprintf(szbuf, "Recv:");
|
|
|
|
|
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
|
|
|
|
sprintf(szbuf, "%s %02X", szbuf, recvbuf[i]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
__android_log_print(ANDROID_LOG_INFO, "serial", "%s", szbuf);
|
|
|
|
|
|
|
|
RecvData((u_char*)recvbuf, len);
|
|
|
|
|
|
|
|
//LOGE("一周期空循环次数%d, 读取次数%d, 时间:%d %d", icnt, inum, (int)time(NULL), itimecnt);
|
|
|
|
|
|
|
|
icnt = 0;
|
|
|
|
|
|
|
|
//serialport.RevCmdFlag =1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
close(fd);
|
|
|
|
|
|
|
|
set12VEnable(false);
|
|
|
|
|
|
|
|
setCam3V3Enable(false);
|
|
|
|
|
|
|
|
setRS485Enable(false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//exit(-1);
|
|
|
|
|
|
|
|
return(0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int serial_port_comm()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
SERIAL_PARAM portparm;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//struct timeval tv;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//gettimeofday(&tv, NULL);
|
|
|
|
|
|
|
|
//int64_t time_in_microseconds = tv.tv_sec * 1000000 + tv.tv_usec;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//LOGE("Current time in microseconds: %ld\n", time_in_microseconds);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if 1
|
|
|
|
|
|
|
|
memset(portparm.pathname, 0, sizeof(portparm.pathname));
|
|
|
|
|
|
|
|
sprintf(portparm.pathname, "/dev/ttyS0");
|
|
|
|
|
|
|
|
portparm.parity = 'N';
|
|
|
|
|
|
|
|
portparm.databit = 8;
|
|
|
|
|
|
|
|
portparm.baudrate = B9600;
|
|
|
|
|
|
|
|
memset(portparm.stopbit, 0, sizeof(portparm.stopbit));
|
|
|
|
|
|
|
|
sprintf(portparm.stopbit, "1");
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//itimecnt = (int)time(NULL);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//for(;;)
|
|
|
|
|
|
|
|
weather_comm(portparm);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
extern int Gm_SetSerialPortParam(int commid);
|
|
|
|
extern int Gm_SetSerialPortParam(int commid);
|
|
|
|
static speed_t getBaudrate(unsigned int baudrate)
|
|
|
|
static speed_t getBaudrate(unsigned int baudrate)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -1094,7 +688,7 @@ void testComm()
|
|
|
|
CameraPhotoCmd(time(NULL), 1, 0, 6, 1, "/dev/ttyS0",38400, 1);
|
|
|
|
CameraPhotoCmd(time(NULL), 1, 0, 6, 1, "/dev/ttyS0",38400, 1);
|
|
|
|
sleep(5);
|
|
|
|
sleep(5);
|
|
|
|
|
|
|
|
|
|
|
|
CameraPhotoCmd(time(NULL), 1, 10017, 0, 2, "/dev/ttyS1",38400, 1);
|
|
|
|
CameraPhotoCmd(time(NULL), 1, MOVE_PRESETNO, 0, 2, "/dev/ttyS1",38400, 1);
|
|
|
|
sleep(5);
|
|
|
|
sleep(5);
|
|
|
|
|
|
|
|
|
|
|
|
CameraPhotoCmd(0, 1, MOVE_LEFT, 0, 0, "/dev/ttyS1",38400, 1);
|
|
|
|
CameraPhotoCmd(0, 1, MOVE_LEFT, 0, 0, "/dev/ttyS1",38400, 1);
|
|
|
@ -1105,7 +699,7 @@ void testComm()
|
|
|
|
sleep(5);
|
|
|
|
sleep(5);
|
|
|
|
CameraPhotoCmd(0, 1, MOVE_UP, 0, 0, "/dev/ttyS1",38400, 1);
|
|
|
|
CameraPhotoCmd(0, 1, MOVE_UP, 0, 0, "/dev/ttyS1",38400, 1);
|
|
|
|
sleep(5);
|
|
|
|
sleep(5);
|
|
|
|
CameraPhotoCmd(0, 1, 10017, 0, 1, "/dev/ttyS1",38400, 1);
|
|
|
|
CameraPhotoCmd(0, 1, MOVE_PRESETNO, 0, 1, "/dev/ttyS1",38400, 1);
|
|
|
|
sleep(5);
|
|
|
|
sleep(5);
|
|
|
|
sleep(5);
|
|
|
|
sleep(5);
|
|
|
|
//CameraPhotoCmd(0, 1, ZOOM_WIDE, 0, 0);
|
|
|
|
//CameraPhotoCmd(0, 1, ZOOM_WIDE, 0, 0);
|
|
|
@ -1849,7 +1443,9 @@ void CameraRecvData(SIO_PARAM_SERIAL_DEF *pPortParam, u_char *buf, int len)
|
|
|
|
void CameraPhotoPortDataProcess(SIO_PARAM_SERIAL_DEF *curserial)
|
|
|
|
void CameraPhotoPortDataProcess(SIO_PARAM_SERIAL_DEF *curserial)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
RTUMSG rtumsg;
|
|
|
|
RTUMSG rtumsg;
|
|
|
|
int img_file_size, packetnum, iNo, packsize, i = 0, presetno, iphototime, pidx;
|
|
|
|
int img_file_size, packetnum, iNo, packsize, i = 0, j = 0, presetno, iphototime, pidx;
|
|
|
|
|
|
|
|
int datanum;
|
|
|
|
|
|
|
|
float fvalue;
|
|
|
|
char szbuf[128];
|
|
|
|
char szbuf[128];
|
|
|
|
uint16_t uDevAddr, datalen=0;
|
|
|
|
uint16_t uDevAddr, datalen=0;
|
|
|
|
uint8_t cmdidx, recvend;
|
|
|
|
uint8_t cmdidx, recvend;
|
|
|
@ -1990,6 +1586,87 @@ void CameraPhotoPortDataProcess(SIO_PARAM_SERIAL_DEF *curserial)
|
|
|
|
curserial->RevCmdFlag = 1;
|
|
|
|
curserial->RevCmdFlag = 1;
|
|
|
|
curserial->FirstCmdTimeCnt = get_msec();
|
|
|
|
curserial->FirstCmdTimeCnt = get_msec();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0xA0:
|
|
|
|
|
|
|
|
sprintf(szbuf, "云台收到关电通知响应!");
|
|
|
|
|
|
|
|
DebugLog(0, szbuf, 'I');
|
|
|
|
|
|
|
|
curserial->SerialCmdidx = -1;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x08:
|
|
|
|
|
|
|
|
datanum = curserial->m_au8RecvBuf[6];
|
|
|
|
|
|
|
|
memset(szbuf, 0, sizeof(szbuf));
|
|
|
|
|
|
|
|
for (i = 0, j = 7; (i < datanum) && (j < 6 + datalen); i++, j += 5)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
fvalue = (curserial->m_au8RecvBuf[j + 1] << 24) + (curserial->m_au8RecvBuf[j + 2] << 16)
|
|
|
|
|
|
|
|
+ (curserial->m_au8RecvBuf[j + 3] << 8) + curserial->m_au8RecvBuf[j + 4];
|
|
|
|
|
|
|
|
switch (curserial->m_au8RecvBuf[j])
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
case 200: /* 云台状态*/
|
|
|
|
|
|
|
|
curserial->ptz_state.ptz_process = curserial->m_au8RecvBuf[j + 1];
|
|
|
|
|
|
|
|
curserial->ptz_state.ptz_status = curserial->m_au8RecvBuf[j+4];
|
|
|
|
|
|
|
|
switch (curserial->ptz_state.ptz_process)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
case 1: // 自检
|
|
|
|
|
|
|
|
if (0 == curserial->ptz_state.ptz_status)
|
|
|
|
|
|
|
|
sprintf(szbuf, "云台自检结束!");
|
|
|
|
|
|
|
|
else if (1 == curserial->ptz_state.ptz_status)
|
|
|
|
|
|
|
|
sprintf(szbuf, "云台正在自检!");
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
sprintf(szbuf, "云台自检发生错误!");
|
|
|
|
|
|
|
|
DebugLog(0, szbuf, 'I');
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2: // 调用预置点
|
|
|
|
|
|
|
|
if (0 == curserial->ptz_state.ptz_status)
|
|
|
|
|
|
|
|
sprintf(szbuf, "调用预置位结束,云台处于所调预置位!");
|
|
|
|
|
|
|
|
else if (1 == curserial->ptz_state.ptz_status)
|
|
|
|
|
|
|
|
sprintf(szbuf, "调用预置位,云台正在前往所调预置位位置!");
|
|
|
|
|
|
|
|
else if (2 == curserial->ptz_state.ptz_status)
|
|
|
|
|
|
|
|
sprintf(szbuf, "调用预置位时,机芯电源未打开!");
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
sprintf(szbuf, "调用预置位时,发生了错误,未正确执行!");
|
|
|
|
|
|
|
|
DebugLog(0, szbuf, 'I');
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3: // 一般状态
|
|
|
|
|
|
|
|
if (0 == curserial->ptz_state.ptz_status)
|
|
|
|
|
|
|
|
sprintf(szbuf, "云台处于静止状态!");
|
|
|
|
|
|
|
|
else if (1 == curserial->ptz_state.ptz_status)
|
|
|
|
|
|
|
|
sprintf(szbuf, "云台正在运动!");
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
sprintf(szbuf, "云台发生错误!");
|
|
|
|
|
|
|
|
DebugLog(0, szbuf, 'I');
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
sprintf(szbuf, "未知错误,云台应答错误!");
|
|
|
|
|
|
|
|
DebugLog(0, szbuf, 'I');
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 201: /* 云台预置点*/
|
|
|
|
|
|
|
|
curserial->ptz_state.presetno = (curserial->m_au8RecvBuf[j + 3] << 8) + curserial->m_au8RecvBuf[j + 4];
|
|
|
|
|
|
|
|
sprintf(szbuf, "云台预置点号=%d", curserial->ptz_state.presetno);
|
|
|
|
|
|
|
|
DebugLog(0, szbuf, 'I');
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 202: /* 云台坐标*/
|
|
|
|
|
|
|
|
fvalue = (uint16_t)((curserial->m_au8RecvBuf[j + 1] << 8) + (curserial->m_au8RecvBuf[j + 2]));
|
|
|
|
|
|
|
|
fvalue /=100.0;
|
|
|
|
|
|
|
|
curserial->ptz_state.x_coordinate = fvalue;
|
|
|
|
|
|
|
|
fvalue = (uint16_t)((curserial->m_au8RecvBuf[j + 3] << 8) + (curserial->m_au8RecvBuf[j + 4]));
|
|
|
|
|
|
|
|
fvalue /=100.0;
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
|
|
|
if(fvalue < 180)
|
|
|
|
|
|
|
|
fvalue *= -1;
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
fvalue = 360-fvalue;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if(fvalue > 180)
|
|
|
|
|
|
|
|
fvalue -= 360;
|
|
|
|
|
|
|
|
curserial->ptz_state.y_coordinate = fvalue;
|
|
|
|
|
|
|
|
sprintf(szbuf, "云台坐标水平(X)=%0.2f°, 垂直(Y)=%0.2f°", curserial->ptz_state.x_coordinate, curserial->ptz_state.y_coordinate);
|
|
|
|
|
|
|
|
DebugLog(0, szbuf, 'I');
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
curserial->SerialCmdidx = -1;
|
|
|
|
|
|
|
|
break;
|
|
|
|
case 0x15:
|
|
|
|
case 0x15:
|
|
|
|
if (0xFF == rtumsg.MsgData[6])
|
|
|
|
if (0xFF == rtumsg.MsgData[6])
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -2233,7 +1910,7 @@ int FindNextCameraPhotoCommand(SIO_PARAM_SERIAL_DEF *pPortParam)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
switch (cmdno)
|
|
|
|
switch (cmdno)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
case 0:/* 下发拍照指令*/
|
|
|
|
case TAKE_PHOTO:/* 下发拍照指令*/
|
|
|
|
if (lcurtime - pPortParam->FirstCmdTimeCnt < 3800)
|
|
|
|
if (lcurtime - pPortParam->FirstCmdTimeCnt < 3800)
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
if ((lcurtime - pPortParam->FirstCmdTimeCnt > 3 * 35 * 1000) || (lcurtime - pPortParam->FirstCmdTimeCnt < 0))
|
|
|
|
if ((lcurtime - pPortParam->FirstCmdTimeCnt > 3 * 35 * 1000) || (lcurtime - pPortParam->FirstCmdTimeCnt < 0))
|
|
|
@ -2260,7 +1937,7 @@ int FindNextCameraPhotoCommand(SIO_PARAM_SERIAL_DEF *pPortParam)
|
|
|
|
imagesize = srdt.bImageSize;
|
|
|
|
imagesize = srdt.bImageSize;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case 10000: /* 下发设置串口波特率命令*/
|
|
|
|
case SET_BAUD: /* 下发设置串口波特率命令*/
|
|
|
|
#if 0
|
|
|
|
#if 0
|
|
|
|
switch (devparam[devidx].baudrate)
|
|
|
|
switch (devparam[devidx].baudrate)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -2308,7 +1985,7 @@ int FindNextCameraPhotoCommand(SIO_PARAM_SERIAL_DEF *pPortParam)
|
|
|
|
packetsize = (uint16_t)MAX_PHOTO_FRAME_LEN;
|
|
|
|
packetsize = (uint16_t)MAX_PHOTO_FRAME_LEN;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case 10005: /* 关闭功能*/
|
|
|
|
case STOP_CMD: /* 关闭功能*/
|
|
|
|
//Gm_CtrlPtzCmd(1, P_MOVE_LEFT);
|
|
|
|
//Gm_CtrlPtzCmd(1, P_MOVE_LEFT);
|
|
|
|
//sleep(2);
|
|
|
|
//sleep(2);
|
|
|
|
Gm_CtrlPtzCmd(pPortParam, Cmd_Cancel);
|
|
|
|
Gm_CtrlPtzCmd(pPortParam, Cmd_Cancel);
|
|
|
@ -2317,25 +1994,25 @@ int FindNextCameraPhotoCommand(SIO_PARAM_SERIAL_DEF *pPortParam)
|
|
|
|
srdt.iLastGetPhotoNo = -1;
|
|
|
|
srdt.iLastGetPhotoNo = -1;
|
|
|
|
//sleep(20);
|
|
|
|
//sleep(20);
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
case 10006: /* 自动扫描功能控制(1/0 打开/关闭该功能)*/
|
|
|
|
case AUTO_SCAN: /* 自动扫描功能控制(1/0 打开/关闭该功能)*/
|
|
|
|
Gm_CtrlPtzCmd(pPortParam, P_Auto_Scan);
|
|
|
|
Gm_CtrlPtzCmd(pPortParam, P_Auto_Scan);
|
|
|
|
usleep(100000);
|
|
|
|
usleep(100000);
|
|
|
|
pPortParam->SerialCmdidx = srdt.iLastGetPhotoNo;
|
|
|
|
pPortParam->SerialCmdidx = srdt.iLastGetPhotoNo;
|
|
|
|
srdt.iLastGetPhotoNo = -1;
|
|
|
|
srdt.iLastGetPhotoNo = -1;
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
case 10007: /* 光圈缩小(1 有效)*/
|
|
|
|
case IRIS_CLOSE: /* 光圈缩小(1 有效)*/
|
|
|
|
Gm_CtrlPtzCmd(pPortParam, P_IRIS_CLOSE);
|
|
|
|
Gm_CtrlPtzCmd(pPortParam, P_IRIS_CLOSE);
|
|
|
|
usleep(100000);
|
|
|
|
usleep(100000);
|
|
|
|
pPortParam->SerialCmdidx = srdt.iLastGetPhotoNo;
|
|
|
|
pPortParam->SerialCmdidx = srdt.iLastGetPhotoNo;
|
|
|
|
srdt.iLastGetPhotoNo = -1;
|
|
|
|
srdt.iLastGetPhotoNo = -1;
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
case 10008: /* 光圈放大(1 有效)*/
|
|
|
|
case IRIS_OPEN: /* 光圈放大(1 有效)*/
|
|
|
|
Gm_CtrlPtzCmd(pPortParam, P_IRIS_OPEN);
|
|
|
|
Gm_CtrlPtzCmd(pPortParam, P_IRIS_OPEN);
|
|
|
|
usleep(100000);
|
|
|
|
usleep(100000);
|
|
|
|
pPortParam->SerialCmdidx = srdt.iLastGetPhotoNo;
|
|
|
|
pPortParam->SerialCmdidx = srdt.iLastGetPhotoNo;
|
|
|
|
srdt.iLastGetPhotoNo = -1;
|
|
|
|
srdt.iLastGetPhotoNo = -1;
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
case 10009: /* 近距离聚焦(1 有效)*/
|
|
|
|
case FOCUS_NEAR: /* 近距离聚焦(1 有效)*/
|
|
|
|
Gm_CtrlPtzCmd(pPortParam, P_FOCUS_NEAR);
|
|
|
|
Gm_CtrlPtzCmd(pPortParam, P_FOCUS_NEAR);
|
|
|
|
usleep(500000);
|
|
|
|
usleep(500000);
|
|
|
|
Gm_CtrlPtzCmd(pPortParam, Cmd_Cancel);
|
|
|
|
Gm_CtrlPtzCmd(pPortParam, Cmd_Cancel);
|
|
|
@ -2343,7 +2020,7 @@ int FindNextCameraPhotoCommand(SIO_PARAM_SERIAL_DEF *pPortParam)
|
|
|
|
pPortParam->SerialCmdidx = srdt.iLastGetPhotoNo;
|
|
|
|
pPortParam->SerialCmdidx = srdt.iLastGetPhotoNo;
|
|
|
|
srdt.iLastGetPhotoNo = -1;
|
|
|
|
srdt.iLastGetPhotoNo = -1;
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
case 10010: /* 远距离聚焦(1 有效)*/
|
|
|
|
case FOCUS_FAR: /* 远距离聚焦(1 有效)*/
|
|
|
|
Gm_CtrlPtzCmd(pPortParam, P_FOCUS_FAR);
|
|
|
|
Gm_CtrlPtzCmd(pPortParam, P_FOCUS_FAR);
|
|
|
|
usleep(500000);
|
|
|
|
usleep(500000);
|
|
|
|
Gm_CtrlPtzCmd(pPortParam, Cmd_Cancel);
|
|
|
|
Gm_CtrlPtzCmd(pPortParam, Cmd_Cancel);
|
|
|
@ -2351,7 +2028,7 @@ int FindNextCameraPhotoCommand(SIO_PARAM_SERIAL_DEF *pPortParam)
|
|
|
|
pPortParam->SerialCmdidx = srdt.iLastGetPhotoNo;
|
|
|
|
pPortParam->SerialCmdidx = srdt.iLastGetPhotoNo;
|
|
|
|
srdt.iLastGetPhotoNo = -1;
|
|
|
|
srdt.iLastGetPhotoNo = -1;
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
case 10011: /* 远离物体(1 有效)*/
|
|
|
|
case ZOOM_WIDE: /* 远离物体(1 有效)*/
|
|
|
|
Gm_CtrlPtzCmd(pPortParam, P_ZOOM_WIDE);
|
|
|
|
Gm_CtrlPtzCmd(pPortParam, P_ZOOM_WIDE);
|
|
|
|
usleep(500000);
|
|
|
|
usleep(500000);
|
|
|
|
Gm_CtrlPtzCmd(pPortParam, Cmd_Cancel);
|
|
|
|
Gm_CtrlPtzCmd(pPortParam, Cmd_Cancel);
|
|
|
@ -2359,7 +2036,7 @@ int FindNextCameraPhotoCommand(SIO_PARAM_SERIAL_DEF *pPortParam)
|
|
|
|
pPortParam->SerialCmdidx = srdt.iLastGetPhotoNo;
|
|
|
|
pPortParam->SerialCmdidx = srdt.iLastGetPhotoNo;
|
|
|
|
srdt.iLastGetPhotoNo = -1;
|
|
|
|
srdt.iLastGetPhotoNo = -1;
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
case 10012: /* 接近物体(1 有效)*/
|
|
|
|
case ZOOM_TELE: /* 接近物体(1 有效)*/
|
|
|
|
Gm_CtrlPtzCmd(pPortParam, P_ZOOM_TELE);
|
|
|
|
Gm_CtrlPtzCmd(pPortParam, P_ZOOM_TELE);
|
|
|
|
usleep(500000);
|
|
|
|
usleep(500000);
|
|
|
|
Gm_CtrlPtzCmd(pPortParam, Cmd_Cancel);
|
|
|
|
Gm_CtrlPtzCmd(pPortParam, Cmd_Cancel);
|
|
|
@ -2367,7 +2044,7 @@ int FindNextCameraPhotoCommand(SIO_PARAM_SERIAL_DEF *pPortParam)
|
|
|
|
pPortParam->SerialCmdidx = srdt.iLastGetPhotoNo;
|
|
|
|
pPortParam->SerialCmdidx = srdt.iLastGetPhotoNo;
|
|
|
|
srdt.iLastGetPhotoNo = -1;
|
|
|
|
srdt.iLastGetPhotoNo = -1;
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
case 10013: /* 向下移动镜头(1 有效)*/
|
|
|
|
case MOVE_DOWN: /* 向下移动镜头(1 有效)*/
|
|
|
|
Gm_CtrlPtzCmd(pPortParam, P_MOVE_DOWN);
|
|
|
|
Gm_CtrlPtzCmd(pPortParam, P_MOVE_DOWN);
|
|
|
|
sleep(1);
|
|
|
|
sleep(1);
|
|
|
|
Gm_CtrlPtzCmd(pPortParam, Cmd_Cancel);
|
|
|
|
Gm_CtrlPtzCmd(pPortParam, Cmd_Cancel);
|
|
|
@ -2375,7 +2052,7 @@ int FindNextCameraPhotoCommand(SIO_PARAM_SERIAL_DEF *pPortParam)
|
|
|
|
pPortParam->SerialCmdidx = srdt.iLastGetPhotoNo;
|
|
|
|
pPortParam->SerialCmdidx = srdt.iLastGetPhotoNo;
|
|
|
|
srdt.iLastGetPhotoNo = -1;
|
|
|
|
srdt.iLastGetPhotoNo = -1;
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
case 10014: /* 向上移动镜头(1 有效)*/
|
|
|
|
case MOVE_UP: /* 向上移动镜头(1 有效)*/
|
|
|
|
Gm_CtrlPtzCmd(pPortParam, P_MOVE_UP);
|
|
|
|
Gm_CtrlPtzCmd(pPortParam, P_MOVE_UP);
|
|
|
|
sleep(1);
|
|
|
|
sleep(1);
|
|
|
|
Gm_CtrlPtzCmd(pPortParam, Cmd_Cancel);
|
|
|
|
Gm_CtrlPtzCmd(pPortParam, Cmd_Cancel);
|
|
|
@ -2383,7 +2060,7 @@ int FindNextCameraPhotoCommand(SIO_PARAM_SERIAL_DEF *pPortParam)
|
|
|
|
pPortParam->SerialCmdidx = srdt.iLastGetPhotoNo;
|
|
|
|
pPortParam->SerialCmdidx = srdt.iLastGetPhotoNo;
|
|
|
|
srdt.iLastGetPhotoNo = -1;
|
|
|
|
srdt.iLastGetPhotoNo = -1;
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
case 10015: /* 向左移动镜头(1 有效)*/
|
|
|
|
case MOVE_LEFT: /* 向左移动镜头(1 有效)*/
|
|
|
|
Gm_CtrlPtzCmd(pPortParam, P_MOVE_LEFT);
|
|
|
|
Gm_CtrlPtzCmd(pPortParam, P_MOVE_LEFT);
|
|
|
|
sleep(1);
|
|
|
|
sleep(1);
|
|
|
|
Gm_CtrlPtzCmd(pPortParam, Cmd_Cancel);
|
|
|
|
Gm_CtrlPtzCmd(pPortParam, Cmd_Cancel);
|
|
|
@ -2391,7 +2068,7 @@ int FindNextCameraPhotoCommand(SIO_PARAM_SERIAL_DEF *pPortParam)
|
|
|
|
pPortParam->SerialCmdidx = srdt.iLastGetPhotoNo;
|
|
|
|
pPortParam->SerialCmdidx = srdt.iLastGetPhotoNo;
|
|
|
|
srdt.iLastGetPhotoNo = -1;
|
|
|
|
srdt.iLastGetPhotoNo = -1;
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
case 10016: /* 向右移动镜头(1 有效)*/
|
|
|
|
case MOVE_RIGHT: /* 向右移动镜头(1 有效)*/
|
|
|
|
Gm_CtrlPtzCmd(pPortParam, P_MOVE_RIGHT);
|
|
|
|
Gm_CtrlPtzCmd(pPortParam, P_MOVE_RIGHT);
|
|
|
|
sleep(1);
|
|
|
|
sleep(1);
|
|
|
|
Gm_CtrlPtzCmd(pPortParam, Cmd_Cancel);
|
|
|
|
Gm_CtrlPtzCmd(pPortParam, Cmd_Cancel);
|
|
|
@ -2399,26 +2076,55 @@ int FindNextCameraPhotoCommand(SIO_PARAM_SERIAL_DEF *pPortParam)
|
|
|
|
pPortParam->SerialCmdidx = srdt.iLastGetPhotoNo;
|
|
|
|
pPortParam->SerialCmdidx = srdt.iLastGetPhotoNo;
|
|
|
|
srdt.iLastGetPhotoNo = -1;
|
|
|
|
srdt.iLastGetPhotoNo = -1;
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
case 10017: /* 调用预置点*/
|
|
|
|
case MOVE_PRESETNO: /* 调用预置点*/
|
|
|
|
//srdt.presetno = 2;
|
|
|
|
//srdt.presetno = 2;
|
|
|
|
Gm_CtrlPtzCmd(pPortParam, MOVE_TO_PRESETNO + srdt.presetno);
|
|
|
|
Gm_CtrlPtzCmd(pPortParam, MOVE_TO_PRESETNO + srdt.presetno);
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
sleep(2);
|
|
|
|
sleep(2);
|
|
|
|
if (0 == srdt.IsSleep)
|
|
|
|
if (0 == srdt.IsSleep)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
pPortParam->SerialCmdidx = 10017;
|
|
|
|
pPortParam->SerialCmdidx = MOVE_PRESETNO;
|
|
|
|
srdt.IsSleep++;
|
|
|
|
srdt.IsSleep++;
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
pPortParam->SerialCmdidx = srdt.iLastGetPhotoNo;
|
|
|
|
pPortParam->SerialCmdidx = srdt.iLastGetPhotoNo;
|
|
|
|
srdt.iLastGetPhotoNo = -1;
|
|
|
|
srdt.iLastGetPhotoNo = -1;
|
|
|
|
srdt.IsSleep = 0;
|
|
|
|
srdt.IsSleep = 0;
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
case 10018: /* 设置预置点*/
|
|
|
|
case SAVE_PRESETNO: /* 设置预置点*/
|
|
|
|
Gm_CtrlPtzCmd(pPortParam, SET_PRESETNO + srdt.presetno);
|
|
|
|
Gm_CtrlPtzCmd(pPortParam, SET_PRESETNO + srdt.presetno);
|
|
|
|
usleep(100000);
|
|
|
|
usleep(100000);
|
|
|
|
pPortParam->SerialCmdidx = srdt.iLastGetPhotoNo;
|
|
|
|
pPortParam->SerialCmdidx = srdt.iLastGetPhotoNo;
|
|
|
|
srdt.iLastGetPhotoNo = -1;
|
|
|
|
srdt.iLastGetPhotoNo = -1;
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
case NOTIFY_PTZ_CLOSE: /* 通知云台关闭电源*/
|
|
|
|
|
|
|
|
if (pPortParam->sendptzstatecmd > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
pPortParam->SerialCmdidx = -2;
|
|
|
|
|
|
|
|
pPortParam->sendptzstatecmd = 0;
|
|
|
|
|
|
|
|
strcpy(szbuf, "云台未接或故障!结束通知!");
|
|
|
|
|
|
|
|
DebugLog(0, szbuf, 'I');
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
cmdidx = 0xA0;
|
|
|
|
|
|
|
|
pPortParam->sendptzstatecmd++;
|
|
|
|
|
|
|
|
//pPortParam->SerialCmdidx = -1;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case QUERY_PTZ_STATE: /* 查询云台状态信息*/
|
|
|
|
|
|
|
|
if (pPortParam->sendptzstatecmd > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
pPortParam->SerialCmdidx = -2;
|
|
|
|
|
|
|
|
pPortParam->sendptzstatecmd = 0;
|
|
|
|
|
|
|
|
strcpy(szbuf, "云台未接或故障!结束查询!");
|
|
|
|
|
|
|
|
DebugLog(0, szbuf, 'I');
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
pPortParam->sendptzstatecmd++;
|
|
|
|
|
|
|
|
cmdidx = 0x08;
|
|
|
|
|
|
|
|
//pPortParam->SerialCmdidx = -1;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
imagesize = 0xFF;
|
|
|
|
imagesize = 0xFF;
|
|
|
|
packetsize = (uint16_t)pPortParam->SerialCmdidx;
|
|
|
|
packetsize = (uint16_t)pPortParam->SerialCmdidx;
|
|
|
@ -3077,8 +2783,8 @@ void ShxyProtocolDataProcess(int devno)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
pPortParam->aiValue[AirTempNo].EuValue = fvalue;/*pPortParam->aiValue[0].AiParam.fFactor + pPortParam->aiValue[0].AiParam.EuValueDelta;*/
|
|
|
|
pPortParam->aiValue[AirTempNo].EuValue = fvalue;
|
|
|
|
weatherpntmsg[AirTempNo].EuValue = fvalue;/*weatherpntmsg[AirTempNo].AiParam.fFactor + weatherpntmsg[AirTempNo].AiParam.EuValueDelta;*/
|
|
|
|
weatherpntmsg[AirTempNo].EuValue = fvalue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pPortParam->aiValue[AirTempNo].AiState = SER_SAMPLE;
|
|
|
|
pPortParam->aiValue[AirTempNo].AiState = SER_SAMPLE;
|
|
|
|
weatherpntmsg[AirTempNo].AiState = SER_SAMPLE;
|
|
|
|
weatherpntmsg[AirTempNo].AiState = SER_SAMPLE;
|
|
|
@ -3086,7 +2792,7 @@ void ShxyProtocolDataProcess(int devno)
|
|
|
|
//if ((gDisSunRain & 0x80) == 0x80)
|
|
|
|
//if ((gDisSunRain & 0x80) == 0x80)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
sprintf(szbuf, "ID:%d 温度:%0.3f ", devparam[devno].devaddr, fvalue);
|
|
|
|
sprintf(szbuf, "ID:%d 温度:%0.3f ", devparam[devno].devaddr, fvalue);
|
|
|
|
//DebugLog(devparam[devno].commid, szbuf, 'V');
|
|
|
|
DebugLog(devparam[devno].commid, szbuf, 'V');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 2: /*气压*/
|
|
|
|
case 2: /*气压*/
|
|
|
@ -3098,16 +2804,16 @@ void ShxyProtocolDataProcess(int devno)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
pPortParam->aiValue[AtmosNo].EuValue = fvalue;/*pPortParam->aiValue[5].AiParam.fFactor + pPortParam->aiValue[5].AiParam.EuValueDelta;*/
|
|
|
|
pPortParam->aiValue[AtmosNo].EuValue = fvalue;
|
|
|
|
weatherpntmsg[AtmosNo].EuValue = fvalue;/*weatherpntmsg[AtmosNo].AiParam.fFactor + weatherpntmsg[AtmosNo].AiParam.EuValueDelta;*/
|
|
|
|
weatherpntmsg[AtmosNo].EuValue = fvalue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pPortParam->aiValue[AtmosNo].AiState = SER_SAMPLE;
|
|
|
|
pPortParam->aiValue[AtmosNo].AiState = SER_SAMPLE;
|
|
|
|
weatherpntmsg[AtmosNo].AiState = SER_SAMPLE;
|
|
|
|
weatherpntmsg[AtmosNo].AiState = SER_SAMPLE;
|
|
|
|
//g_SelfTest.SensorsFault |= (0x10);
|
|
|
|
//g_SelfTest.SensorsFault |= (0x10);
|
|
|
|
//if ((gDisSunRain & 0x80) == 0x80)
|
|
|
|
//if ((gDisSunRain & 0x80) == 0x80)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
sprintf(szbuf, "%s气压:%0.3f ", szbuf, fvalue);
|
|
|
|
sprintf(szbuf, "气压:%0.3f ", fvalue);
|
|
|
|
//DebugLog(devparam[devno].commid, szbuf, 'V');
|
|
|
|
DebugLog(devparam[devno].commid, szbuf, 'V');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 3: /*湿度*/
|
|
|
|
case 3: /*湿度*/
|
|
|
@ -3127,9 +2833,8 @@ void ShxyProtocolDataProcess(int devno)
|
|
|
|
//g_SelfTest.SensorsFault |= (0x02);
|
|
|
|
//g_SelfTest.SensorsFault |= (0x02);
|
|
|
|
//if ((gDisSunRain & 0x80) == 0x80)
|
|
|
|
//if ((gDisSunRain & 0x80) == 0x80)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
sprintf(szbuf, "%s湿度:%0.3f ", szbuf, fvalue);
|
|
|
|
sprintf(szbuf, "湿度:%0.3f ", fvalue);
|
|
|
|
if(datanum < 6)
|
|
|
|
DebugLog(devparam[devno].commid, szbuf, 'V');
|
|
|
|
DebugLog(devparam[devno].commid, szbuf, 'V');
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 4: /*雨量*/
|
|
|
|
case 4: /*雨量*/
|
|
|
@ -3149,9 +2854,8 @@ void ShxyProtocolDataProcess(int devno)
|
|
|
|
//g_SelfTest.SensorsFault |= (0x02);
|
|
|
|
//g_SelfTest.SensorsFault |= (0x02);
|
|
|
|
//if ((gDisSunRain & 0x80) == 0x80)
|
|
|
|
//if ((gDisSunRain & 0x80) == 0x80)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
sprintf(szbuf, "%s雨量:%0.3f ", szbuf, fvalue);
|
|
|
|
sprintf(szbuf, "雨量:%0.3f ", fvalue);
|
|
|
|
if(datanum < 7)
|
|
|
|
DebugLog(devparam[devno].commid, szbuf, 'V');
|
|
|
|
DebugLog(devparam[devno].commid, szbuf, 'V');
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 5: /*日照*/
|
|
|
|
case 5: /*日照*/
|
|
|
@ -3169,7 +2873,7 @@ void ShxyProtocolDataProcess(int devno)
|
|
|
|
pPortParam->aiValue[OpticalRadiationNo].AiState = SER_SAMPLE;
|
|
|
|
pPortParam->aiValue[OpticalRadiationNo].AiState = SER_SAMPLE;
|
|
|
|
weatherpntmsg[OpticalRadiationNo].AiState = SER_SAMPLE;
|
|
|
|
weatherpntmsg[OpticalRadiationNo].AiState = SER_SAMPLE;
|
|
|
|
{
|
|
|
|
{
|
|
|
|
sprintf(szbuf, "%s日照:%0.3f ", szbuf, fvalue);
|
|
|
|
sprintf(szbuf, "日照:%0.3f ", fvalue);
|
|
|
|
DebugLog(devparam[devno].commid, szbuf, 'V');
|
|
|
|
DebugLog(devparam[devno].commid, szbuf, 'V');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
@ -3638,13 +3342,13 @@ int GM_IsCloseCamera(SIO_PARAM_SERIAL_DEF *pPortParam)
|
|
|
|
|
|
|
|
|
|
|
|
lctime = get_msec();
|
|
|
|
lctime = get_msec();
|
|
|
|
memset(buf, 0, sizeof(buf));
|
|
|
|
memset(buf, 0, sizeof(buf));
|
|
|
|
if (-1 == pPortParam->SerialCmdidx)
|
|
|
|
if (0 > pPortParam->SerialCmdidx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if ((SER_STARTSAMPLE == pPortParam->image.state) || (SER_SAMPLE == pPortParam->image.state))
|
|
|
|
if ((SER_STARTSAMPLE == pPortParam->image.state) || (SER_SAMPLE == pPortParam->image.state))
|
|
|
|
pPortParam->image.state = SER_SAMPLEFAIL;
|
|
|
|
pPortParam->image.state = SER_SAMPLEFAIL;
|
|
|
|
else if (PHOTO_SAVE_SUCC == pPortParam->image.state)
|
|
|
|
else if (PHOTO_SAVE_SUCC == pPortParam->image.state)
|
|
|
|
pPortParam->image.state = PHOTO_SAVE_SUCC;
|
|
|
|
pPortParam->image.state = PHOTO_SAVE_SUCC;
|
|
|
|
strcpy(buf, "通道1摄像机使用完毕!可以关闭摄像机电源!");
|
|
|
|
strcpy(buf, "摄像机使用完毕!可以关闭摄像机电源!");
|
|
|
|
DebugLog(0, buf, 'I');
|
|
|
|
DebugLog(0, buf, 'I');
|
|
|
|
memset(&serialport[0].image, 0, sizeof(PHOTO_DEF));
|
|
|
|
memset(&serialport[0].image, 0, sizeof(PHOTO_DEF));
|
|
|
|
memmove((void *)&serialport[0].image, (void*)&pPortParam->image, sizeof(PHOTO_DEF));
|
|
|
|
memmove((void *)&serialport[0].image, (void*)&pPortParam->image, sizeof(PHOTO_DEF));
|
|
|
@ -3695,9 +3399,9 @@ int GM_CameraSerialTimer(SIO_PARAM_SERIAL_DEF *pPortParam)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int flag = -1;
|
|
|
|
int flag = -1;
|
|
|
|
|
|
|
|
|
|
|
|
GM_CameraSerialComRecv(pPortParam);
|
|
|
|
|
|
|
|
Gm_FindCameraCommand(pPortParam);
|
|
|
|
|
|
|
|
//GM_CameraSerialComRecv(pPortParam);
|
|
|
|
//GM_CameraSerialComRecv(pPortParam);
|
|
|
|
|
|
|
|
Gm_FindCameraCommand(pPortParam);
|
|
|
|
|
|
|
|
GM_CameraSerialComRecv(pPortParam);
|
|
|
|
flag = GM_IsCloseCamera(pPortParam);
|
|
|
|
flag = GM_IsCloseCamera(pPortParam);
|
|
|
|
return flag;
|
|
|
|
return flag;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -3729,11 +3433,11 @@ int GM_StartSerialCameraPhoto(int phototime, unsigned char channel, int cmdidx,
|
|
|
|
#if 1
|
|
|
|
#if 1
|
|
|
|
memset(szbuf, 0, sizeof(szbuf));
|
|
|
|
memset(szbuf, 0, sizeof(szbuf));
|
|
|
|
srdt.iLastGetPhotoNo = -1;
|
|
|
|
srdt.iLastGetPhotoNo = -1;
|
|
|
|
if (0 == cmdidx)
|
|
|
|
if (TAKE_PHOTO == cmdidx)
|
|
|
|
cameraport->image.state = SER_STARTSAMPLE;
|
|
|
|
cameraport->image.state = SER_STARTSAMPLE;
|
|
|
|
if ((0 == cmdidx) && (srdt.presetno > 0))
|
|
|
|
if ((TAKE_PHOTO == cmdidx) && (srdt.presetno > 0))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
cameraport->SerialCmdidx = 10017;
|
|
|
|
cameraport->SerialCmdidx = MOVE_PRESETNO;
|
|
|
|
srdt.iLastGetPhotoNo = cmdidx;
|
|
|
|
srdt.iLastGetPhotoNo = cmdidx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
@ -3774,7 +3478,7 @@ int GM_StartSerialCameraPhoto(int phototime, unsigned char channel, int cmdidx,
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//LOGE("12V state=%d", getInt(CMD_SET_12V_EN_STATE));
|
|
|
|
//LOGE("12V state=%d", getInt(CMD_SET_12V_EN_STATE));
|
|
|
|
DebugLog(8, "退出操作摄像机流程!", 'V');
|
|
|
|
DebugLog(8, "退出操作摄像机流程!", 'V');
|
|
|
|
sleep(3);
|
|
|
|
//sleep(3);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -3800,6 +3504,84 @@ int CameraPhotoCmd(int phototime, unsigned char channel, int cmdidx, unsigned ch
|
|
|
|
pthread_mutex_unlock(&camera_mutex); // 解锁
|
|
|
|
pthread_mutex_unlock(&camera_mutex); // 解锁
|
|
|
|
return flag;
|
|
|
|
return flag;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int QueryPtzState(PTZ_STATE *ptz_state, int cmdidx, const char *serfile, unsigned int baud, int addr)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
pthread_mutex_lock(&camera_mutex);
|
|
|
|
|
|
|
|
int flag = 0;
|
|
|
|
|
|
|
|
char szbuf[128], logbuf[128];
|
|
|
|
|
|
|
|
SIO_PARAM_SERIAL_DEF *cameraport=NULL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(NULL == ptz_state)
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if((NOTIFY_PTZ_CLOSE == cmdidx) || (QUERY_PTZ_STATE == cmdidx))
|
|
|
|
|
|
|
|
;
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
cameraport = (SIO_PARAM_SERIAL_DEF*)malloc(sizeof(SIO_PARAM_SERIAL_DEF));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cameraport->cameraaddr = addr;
|
|
|
|
|
|
|
|
cameraport->Retry = 0;
|
|
|
|
|
|
|
|
cameraport->RetryTime = 1000;
|
|
|
|
|
|
|
|
cameraport->WaitTime = 0;
|
|
|
|
|
|
|
|
cameraport->m_iRevStatus = 0;
|
|
|
|
|
|
|
|
cameraport->m_iRecvLen = 0;
|
|
|
|
|
|
|
|
cameraport->m_iNeedRevLength = 0;
|
|
|
|
|
|
|
|
cameraport->fd = -1;
|
|
|
|
|
|
|
|
memset(cameraport->m_au8RecvBuf, 0, RECVDATA_MAXLENTH); // 接收数据缓存区
|
|
|
|
|
|
|
|
ClearCameraCmdFormPollCmdBuf(cameraport);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
flag = Gm_OpenCameraSerial(cameraport, serfile, baud);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if 1
|
|
|
|
|
|
|
|
memset(szbuf, 0, sizeof(szbuf));
|
|
|
|
|
|
|
|
srdt.iLastGetPhotoNo = -1;
|
|
|
|
|
|
|
|
cameraport->SerialCmdidx = cmdidx;
|
|
|
|
|
|
|
|
cameraport->FirstCmdTimeCnt = get_msec();
|
|
|
|
|
|
|
|
cameraport->sendptzstatecmd = 0;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if(-1 == flag)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(NULL != cameraport)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
free(cameraport);
|
|
|
|
|
|
|
|
cameraport = NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (0x00 == flag)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
sprintf(szbuf, "云台状态查询启动串口定时器!");
|
|
|
|
|
|
|
|
DebugLog(8, szbuf, 'I');
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
usleep(10);
|
|
|
|
|
|
|
|
//LOGW("polltime=%ldms", get_msec()-polltime);
|
|
|
|
|
|
|
|
//polltime = get_msec();
|
|
|
|
|
|
|
|
flag = GM_CameraSerialTimer(cameraport);
|
|
|
|
|
|
|
|
if (flag < 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//LOGE("12V state=%d", getInt(CMD_SET_12V_EN_STATE));
|
|
|
|
|
|
|
|
DebugLog(8, "退出查询云台状态流程!", 'V');
|
|
|
|
|
|
|
|
memmove((void*)ptz_state, &cameraport->ptz_state, sizeof(PTZ_STATE));
|
|
|
|
|
|
|
|
if(flag == -2)
|
|
|
|
|
|
|
|
flag = -1;
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
flag = 0;
|
|
|
|
|
|
|
|
//sleep(3);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(NULL != cameraport)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
free(cameraport);
|
|
|
|
|
|
|
|
cameraport = NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
pthread_mutex_unlock(&camera_mutex); // 解锁
|
|
|
|
|
|
|
|
return flag;
|
|
|
|
|
|
|
|
}
|
|
|
|
/* 串口启动接口函数 结束*/
|
|
|
|
/* 串口启动接口函数 结束*/
|
|
|
|
|
|
|
|
|
|
|
|
/* 数据和图片采集数据返回函数 开始*/
|
|
|
|
/* 数据和图片采集数据返回函数 开始*/
|
|
|
|