|
|
|
@ -22,12 +22,15 @@
|
|
|
|
|
#include "GPIOControl.h"
|
|
|
|
|
#include "serialComm.h"
|
|
|
|
|
#include <sys/time.h>
|
|
|
|
|
#include <pthread.h>
|
|
|
|
|
|
|
|
|
|
//#include <AndroidHelper.h>
|
|
|
|
|
#include "SensorsProtocol.h"
|
|
|
|
|
//#include "Eint.h"
|
|
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
pthread_mutex_t serial_mutex = PTHREAD_MUTEX_INITIALIZER; // 定义一个互斥锁
|
|
|
|
|
pthread_mutex_t camera_mutex = PTHREAD_MUTEX_INITIALIZER; // 定义一个互斥锁
|
|
|
|
|
|
|
|
|
|
SIO_PARAM_SERIAL_DEF serialport[MAX_SERIAL_PORT_NUM];
|
|
|
|
|
|
|
|
|
@ -75,17 +78,6 @@ static void setRS485Enable(bool z) {
|
|
|
|
|
setInt(CMD_SET_485_EN_STATE, z ? 1 : 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void set485WriteMode() {
|
|
|
|
|
setInt(CMD_SET_485_STATE, 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void set485ReadMode() {
|
|
|
|
|
setInt(CMD_SET_485_STATE, 0);
|
|
|
|
|
}
|
|
|
|
|
static void set12VEnable(bool z) {
|
|
|
|
|
setInt(CMD_SET_12V_EN_STATE, z ? 1 : 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void setCam3V3Enable(bool enabled)
|
|
|
|
|
{
|
|
|
|
|
setInt(CMD_SET_CAM_3V3_EN_STATE, enabled ? 1 : 0);
|
|
|
|
@ -535,7 +527,7 @@ static speed_t getBaudrate(unsigned int baudrate)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int64_t get_msec()
|
|
|
|
|
int64_t get_msec()
|
|
|
|
|
{
|
|
|
|
|
struct timeval tv;
|
|
|
|
|
int64_t time_in_msec = 0;
|
|
|
|
@ -573,7 +565,7 @@ void Gm_CloseSensorsPower()
|
|
|
|
|
/* 关闭电源*/
|
|
|
|
|
//switch(port)
|
|
|
|
|
/* 根据硬件具体布置最后调整,目前是微拍板子的来控制*/
|
|
|
|
|
set12VEnable(false);
|
|
|
|
|
/* set12VEnable(false);
|
|
|
|
|
setCam3V3Enable(false);
|
|
|
|
|
setRS485Enable(false);
|
|
|
|
|
|
|
|
|
@ -593,46 +585,43 @@ void Gm_CloseSensorsPower()
|
|
|
|
|
#endif
|
|
|
|
|
#if 1
|
|
|
|
|
setInt(CMD_SET_SPI_POWER, 1);
|
|
|
|
|
setInt(CMD_SET_485_en0, 1);
|
|
|
|
|
setInt(CMD_SET_485_en1, 1);
|
|
|
|
|
setInt(CMD_SET_485_en2, 1);
|
|
|
|
|
setInt(CMD_SET_485_en3, 1);
|
|
|
|
|
setInt(CMD_SET_485_en4, 1);
|
|
|
|
|
setInt(CMD_SET_485_EN0, 1);
|
|
|
|
|
setInt(CMD_SET_485_EN1, 1);
|
|
|
|
|
setInt(CMD_SET_485_EN2, 1);
|
|
|
|
|
setInt(CMD_SET_485_EN3, 1);
|
|
|
|
|
setInt(CMD_SET_485_EN4, 1);
|
|
|
|
|
#else
|
|
|
|
|
setInt(CMD_SET_SPI_POWER, 0);
|
|
|
|
|
setInt(CMD_SET_485_en0, 0);
|
|
|
|
|
setInt(CMD_SET_485_en1, 0);
|
|
|
|
|
setInt(CMD_SET_485_en2, 0);
|
|
|
|
|
setInt(CMD_SET_485_en3, 0);
|
|
|
|
|
setInt(CMD_SET_485_en4, 0);
|
|
|
|
|
setInt(CMD_SET_485_EN0, 0);
|
|
|
|
|
setInt(CMD_SET_485_EN1, 0);
|
|
|
|
|
setInt(CMD_SET_485_EN2, 0);
|
|
|
|
|
setInt(CMD_SET_485_EN3, 0);
|
|
|
|
|
setInt(CMD_SET_485_EN4, 0);
|
|
|
|
|
sleep(3);
|
|
|
|
|
igpio = getInt(CMD_SET_SPI_POWER);
|
|
|
|
|
igpio = getInt(CMD_SET_485_en0);
|
|
|
|
|
igpio = getInt(CMD_SET_485_en1);
|
|
|
|
|
igpio = getInt(CMD_SET_485_en2);
|
|
|
|
|
igpio = getInt(CMD_SET_485_en3);
|
|
|
|
|
igpio = getInt(CMD_SET_485_en4);
|
|
|
|
|
igpio = getInt(CMD_SET_485_EN0);
|
|
|
|
|
igpio = getInt(CMD_SET_485_EN1);
|
|
|
|
|
igpio = getInt(CMD_SET_485_EN2);
|
|
|
|
|
igpio = getInt(CMD_SET_485_EN3);
|
|
|
|
|
igpio = getInt(CMD_SET_485_EN4);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 打开传感器电源
|
|
|
|
|
void Gm_OpenSensorsPower()
|
|
|
|
|
{
|
|
|
|
|
//char iIoNo;
|
|
|
|
|
int igpio;
|
|
|
|
|
/* int igpio;
|
|
|
|
|
char szbuf[128];
|
|
|
|
|
|
|
|
|
|
//if(0 == port)
|
|
|
|
|
// return;
|
|
|
|
|
//sprintf(szbuf, "Open Sensors port %d Power!", port);
|
|
|
|
|
|
|
|
|
|
set12VEnable(true);
|
|
|
|
|
//set12VEnable(true);
|
|
|
|
|
setCam3V3Enable(true);
|
|
|
|
|
setRS485Enable(true);
|
|
|
|
|
setInt(CMD_SET_485_ENABLE, 1); // 打开RS485电源
|
|
|
|
|
setInt(CMD_SET_3V3_PWR_ENABLE, 1); // 打开3.3V电压
|
|
|
|
|
setInt(CMD_SET_PTZ_PWR_ENABLE, 1);
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
setInt(CMD_SET_WTH_POWER, 0);
|
|
|
|
@ -656,31 +645,31 @@ void Gm_OpenSensorsPower()
|
|
|
|
|
#endif
|
|
|
|
|
#if 1
|
|
|
|
|
setInt(CMD_SET_SPI_POWER, 1);
|
|
|
|
|
setInt(CMD_SET_485_en0, 1);
|
|
|
|
|
setInt(CMD_SET_485_en1, 1);
|
|
|
|
|
setInt(CMD_SET_485_en2, 1);
|
|
|
|
|
setInt(CMD_SET_485_en3, 1);
|
|
|
|
|
setInt(CMD_SET_485_en4, 1);
|
|
|
|
|
setInt(CMD_SET_485_EN0, 1);
|
|
|
|
|
setInt(CMD_SET_485_EN1, 1);
|
|
|
|
|
setInt(CMD_SET_485_EN2, 1);
|
|
|
|
|
setInt(CMD_SET_485_EN3, 1);
|
|
|
|
|
setInt(CMD_SET_485_EN4, 1);
|
|
|
|
|
|
|
|
|
|
//sleep(3);
|
|
|
|
|
igpio = getInt(CMD_SET_SPI_POWER);
|
|
|
|
|
igpio = getInt(CMD_SET_485_en0);
|
|
|
|
|
igpio = getInt(CMD_SET_485_en1);
|
|
|
|
|
igpio = getInt(CMD_SET_485_en2);
|
|
|
|
|
igpio = getInt(CMD_SET_485_en3);
|
|
|
|
|
igpio = getInt(CMD_SET_485_en4);
|
|
|
|
|
igpio = getInt(CMD_SET_485_EN0);
|
|
|
|
|
igpio = getInt(CMD_SET_485_EN1);
|
|
|
|
|
igpio = getInt(CMD_SET_485_EN2);
|
|
|
|
|
igpio = getInt(CMD_SET_485_EN3);
|
|
|
|
|
igpio = getInt(CMD_SET_485_EN4);
|
|
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
setInt(CMD_SET_485_en0, 0);
|
|
|
|
|
setInt(CMD_SET_485_en1, 0);
|
|
|
|
|
setInt(CMD_SET_485_en2, 0);
|
|
|
|
|
setInt(CMD_SET_485_en3, 0);
|
|
|
|
|
setInt(CMD_SET_485_en4, 0);
|
|
|
|
|
setInt(CMD_SET_485_EN0, 0);
|
|
|
|
|
setInt(CMD_SET_485_EN1, 0);
|
|
|
|
|
setInt(CMD_SET_485_EN2, 0);
|
|
|
|
|
setInt(CMD_SET_485_EN3, 0);
|
|
|
|
|
setInt(CMD_SET_485_EN4, 0);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// 打开电源
|
|
|
|
|
//switch(port)
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 查询传感器电源状态
|
|
|
|
@ -699,7 +688,7 @@ char Gm_GetSensorsPowerState(int port)
|
|
|
|
|
void BytestreamLOG(int commid, char* describe, u_char* buf, int len, char flag)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
char szbuf[4096];
|
|
|
|
|
char szbuf[8192];
|
|
|
|
|
|
|
|
|
|
memset(szbuf, 0, sizeof(szbuf));
|
|
|
|
|
if (NULL != describe)
|
|
|
|
@ -764,7 +753,7 @@ void Gm_CloseSerialPort()
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_SERIAL_PORT_NUM; i++)
|
|
|
|
|
for (i = 1; i < MAX_SERIAL_PORT_NUM; i++)
|
|
|
|
|
{
|
|
|
|
|
if (serialport[i].fd > 0)
|
|
|
|
|
{
|
|
|
|
@ -866,7 +855,7 @@ void Gm_InitSerialComm_Test()
|
|
|
|
|
sensorParam[0].IsNoInsta = 1;
|
|
|
|
|
sensorParam[0].devaddr = 4;
|
|
|
|
|
memset(sensorParam[0].pathname, 0, sizeof(sensorParam[0].pathname));
|
|
|
|
|
sprintf(sensorParam[0].pathname, "/dev/ttysWK3");
|
|
|
|
|
strcpy(sensorParam[0].pathname, "/dev/ttysWK3");
|
|
|
|
|
|
|
|
|
|
sensorParam[1].SensorsType = WEATHER_PROTOCOL;
|
|
|
|
|
sensorParam[1].baudrate = 9600;
|
|
|
|
@ -878,7 +867,7 @@ void Gm_InitSerialComm_Test()
|
|
|
|
|
sensorParam[1].IsNoInsta = 1;
|
|
|
|
|
sensorParam[1].devaddr = 1;
|
|
|
|
|
memset(sensorParam[1].pathname, 0, sizeof(sensorParam[1].pathname));
|
|
|
|
|
sprintf(sensorParam[1].pathname, "/dev/ttysWK3");
|
|
|
|
|
strcpy(sensorParam[1].pathname, "/dev/ttysWK3");
|
|
|
|
|
|
|
|
|
|
sensorParam[2].SensorsType = RALLY_PROTOCOL;
|
|
|
|
|
sensorParam[2].baudrate = 9600;
|
|
|
|
@ -892,7 +881,7 @@ void Gm_InitSerialComm_Test()
|
|
|
|
|
//sensorParam[2].devaddr = 13;
|
|
|
|
|
sensorParam[2].devaddr = 13;
|
|
|
|
|
memset(sensorParam[2].pathname, 0, sizeof(sensorParam[2].pathname));
|
|
|
|
|
sprintf(sensorParam[2].pathname, "/dev/ttysWK1");
|
|
|
|
|
strcpy(sensorParam[2].pathname, "/dev/ttysWK1");
|
|
|
|
|
|
|
|
|
|
sensorParam[5].SensorsType = RALLY_PROTOCOL;
|
|
|
|
|
sensorParam[5].baudrate = 9600;
|
|
|
|
@ -904,7 +893,7 @@ void Gm_InitSerialComm_Test()
|
|
|
|
|
sensorParam[5].IsNoInsta = 1;
|
|
|
|
|
sensorParam[5].devaddr = 10;
|
|
|
|
|
memset(sensorParam[5].pathname, 0, sizeof(sensorParam[3].pathname));
|
|
|
|
|
sprintf(sensorParam[5].pathname, "/dev/ttysWK1");
|
|
|
|
|
strcpy(sensorParam[5].pathname, "/dev/ttysWK1");
|
|
|
|
|
|
|
|
|
|
sensorParam[4].SensorsType = RALLY_PROTOCOL;
|
|
|
|
|
sensorParam[4].baudrate = 9600;
|
|
|
|
@ -918,7 +907,7 @@ void Gm_InitSerialComm_Test()
|
|
|
|
|
//sensorParam[2].devaddr = 13;
|
|
|
|
|
sensorParam[4].devaddr = 12;
|
|
|
|
|
memset(sensorParam[4].pathname, 0, sizeof(sensorParam[4].pathname));
|
|
|
|
|
sprintf(sensorParam[4].pathname, "/dev/ttysWK1");
|
|
|
|
|
strcpy(sensorParam[4].pathname, "/dev/ttysWK1");
|
|
|
|
|
|
|
|
|
|
sensorParam[6].SensorsType = SLANT_PROTOCOL;
|
|
|
|
|
sensorParam[6].baudrate = 9600;
|
|
|
|
@ -931,7 +920,7 @@ void Gm_InitSerialComm_Test()
|
|
|
|
|
sensorParam[6].IsNoInsta = 1;
|
|
|
|
|
sensorParam[6].devaddr = 2;
|
|
|
|
|
memset(sensorParam[6].pathname, 0, sizeof(sensorParam[6].pathname));
|
|
|
|
|
sprintf(sensorParam[6].pathname, "/dev/ttysWK0");
|
|
|
|
|
strcpy(sensorParam[6].pathname, "/dev/ttysWK0");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sensorParam[7].SensorsType = SLANT_PROTOCOL;
|
|
|
|
@ -945,7 +934,7 @@ void Gm_InitSerialComm_Test()
|
|
|
|
|
sensorParam[7].IsNoInsta = 1;
|
|
|
|
|
sensorParam[7].devaddr = 3;
|
|
|
|
|
memset(sensorParam[7].pathname, 0, sizeof(sensorParam[7].pathname));
|
|
|
|
|
sprintf(sensorParam[7].pathname, "/dev/ttysWK0");
|
|
|
|
|
strcpy(sensorParam[7].pathname, "/dev/ttysWK0");
|
|
|
|
|
|
|
|
|
|
sensorParam[13].SensorsType = SLANT_PROTOCOL;
|
|
|
|
|
sensorParam[13].baudrate = 9600;
|
|
|
|
@ -958,7 +947,7 @@ void Gm_InitSerialComm_Test()
|
|
|
|
|
sensorParam[13].IsNoInsta = 1;
|
|
|
|
|
sensorParam[13].devaddr = 5;
|
|
|
|
|
memset(sensorParam[13].pathname, 0, sizeof(sensorParam[13].pathname));
|
|
|
|
|
sprintf(sensorParam[13].pathname, "/dev/ttysWK0");
|
|
|
|
|
strcpy(sensorParam[13].pathname, "/dev/ttysWK0");
|
|
|
|
|
#if 0
|
|
|
|
|
devparam[14].ProtocolIdx = SLANT_PROTOCOL;
|
|
|
|
|
devparam[14].baudrate = 1200;
|
|
|
|
@ -992,11 +981,15 @@ void Gm_InitSerialComm_Test()
|
|
|
|
|
sensorParam[3].CameraChannel = 1;
|
|
|
|
|
sensorParam[3].devaddr = 0;
|
|
|
|
|
memset(sensorParam[3].pathname, 0, sizeof(sensorParam[3].pathname));
|
|
|
|
|
sprintf(sensorParam[3].pathname, "/dev/ttyS1");
|
|
|
|
|
strcpy(sensorParam[3].pathname, "/dev/ttyS1");
|
|
|
|
|
//#endif
|
|
|
|
|
Gm_InitSerialComm(sensorParam, "/sdcard/photo/");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint8_t getdevtype(int devno)
|
|
|
|
|
{
|
|
|
|
|
return devparam[devno].ProtocolIdx;
|
|
|
|
|
}
|
|
|
|
|
// 初始化所有串口及所接传感器的配置
|
|
|
|
|
void Gm_InitSerialComm(SENSOR_PARAM *sensorParam, char *filedir)
|
|
|
|
|
{
|
|
|
|
@ -1076,7 +1069,7 @@ void Gm_InitSerialComm(SENSOR_PARAM *sensorParam, char *filedir)
|
|
|
|
|
|
|
|
|
|
sprintf(szbuf, "%s 地址%d!;", szbuf, sensorParam[i].devaddr);
|
|
|
|
|
if (0 == sensorParam[i].IsNoInsta)
|
|
|
|
|
sprintf(szbuf, "没有启用!;");
|
|
|
|
|
sprintf(szbuf, "%s", "没有启用!;");
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sprintf(szbuf, "%s 已启用!;", szbuf);
|
|
|
|
@ -1312,6 +1305,8 @@ void GM_StartSerialComm()
|
|
|
|
|
#endif
|
|
|
|
|
for (i = 0; i < MAX_SERIAL_DEV_NUM; i++)
|
|
|
|
|
{
|
|
|
|
|
memset(srdt.ms_dev[i].aiValue, 0, sizeof(AI_DEF)*MAX_DEV_VALUE_NUM);
|
|
|
|
|
memset(weatherpntmsg, 0, sizeof(AI_DEF)*WEATHER_DATA_NUM);
|
|
|
|
|
if (0 == devparam[i].IsNoInsta)
|
|
|
|
|
{
|
|
|
|
|
srdt.ms_dev[i].IsNeedSerial = 0;
|
|
|
|
@ -1321,15 +1316,18 @@ void GM_StartSerialComm()
|
|
|
|
|
switch (devparam[i].ProtocolIdx)
|
|
|
|
|
{
|
|
|
|
|
case WEATHER_PROTOCOL: // 气象
|
|
|
|
|
sprintf(szbuf, "气象");
|
|
|
|
|
sprintf(szbuf, "%s", "气象");
|
|
|
|
|
srdt.ms_dev[i].IsNeedSerial = 1;
|
|
|
|
|
srdt.ms_dev[i].FirstCmdTimeCnt = get_msec();
|
|
|
|
|
srdt.ms_dev[i].recvdatacnt = 0;
|
|
|
|
|
for (j = 0; j < WEATHER_DATA_NUM; j++)
|
|
|
|
|
{
|
|
|
|
|
srdt.ms_dev[i].aiValue[j].AiState = SER_STARTSAMPLE;
|
|
|
|
|
weatherpntmsg[j].AiState = SER_STARTSAMPLE;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case RALLY_PROTOCOL: /* 拉力*/
|
|
|
|
|
sprintf(szbuf, "拉力");
|
|
|
|
|
sprintf(szbuf, "%s", "拉力");
|
|
|
|
|
srdt.ms_dev[i].IsNeedSerial = 1;
|
|
|
|
|
srdt.ms_dev[i].FirstCmdTimeCnt = get_msec();
|
|
|
|
|
srdt.ms_dev[i].recvdatacnt = 0;
|
|
|
|
@ -1337,14 +1335,17 @@ void GM_StartSerialComm()
|
|
|
|
|
srdt.ms_dev[i].aiValue[j].AiState = SER_STARTSAMPLE;
|
|
|
|
|
break;
|
|
|
|
|
case WIND_PROTOCOL: /* 风速风向*/
|
|
|
|
|
sprintf(szbuf, "风速风向");
|
|
|
|
|
sprintf(szbuf, "%s", "风速风向");
|
|
|
|
|
srdt.ms_dev[i].IsNeedSerial = 1;
|
|
|
|
|
srdt.ms_dev[i].FirstCmdTimeCnt = get_msec();
|
|
|
|
|
for (j = 0; j < WEATHER_DATA_NUM; j++)
|
|
|
|
|
{
|
|
|
|
|
srdt.ms_dev[i].aiValue[j].AiState = SER_STARTSAMPLE;
|
|
|
|
|
weatherpntmsg[j].AiState = SER_STARTSAMPLE;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case SLANT_PROTOCOL: /* 倾角*/
|
|
|
|
|
sprintf(szbuf, "倾角");
|
|
|
|
|
sprintf(szbuf, "%s", "倾角");
|
|
|
|
|
srdt.ms_dev[i].IsNeedSerial = 1;
|
|
|
|
|
srdt.ms_dev[i].FirstCmdTimeCnt = get_msec();
|
|
|
|
|
srdt.ms_dev[i].recvdatacnt = 0;
|
|
|
|
@ -1354,11 +1355,12 @@ void GM_StartSerialComm()
|
|
|
|
|
case PELCO_D_PROTOCOL: /* 摄像机协议*/
|
|
|
|
|
case PELCO_P_PROTOCOL: /* 摄像机协议*/
|
|
|
|
|
case SERIALCAMERA_PROTOCOL: /* 串口摄像机协议*/
|
|
|
|
|
sprintf(szbuf, "摄像机");
|
|
|
|
|
sprintf(szbuf, "%s", "摄像机");
|
|
|
|
|
srdt.ms_dev[i].IsNeedSerial = 0;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
srdt.ms_dev[i].IsNeedSerial = 0;
|
|
|
|
|
sprintf(szbuf, "无效传感器");
|
|
|
|
|
sprintf(szbuf, "%s", "无效传感器");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
// 测试查询传感器电源状态
|
|
|
|
@ -1617,11 +1619,11 @@ int GM_CloseTimer()
|
|
|
|
|
else // 关闭所有串口及电源
|
|
|
|
|
{
|
|
|
|
|
Gm_CloseSerialPort();
|
|
|
|
|
for (j = 0; j < MAX_SERIAL_DEV_NUM; j++)
|
|
|
|
|
Gm_CloseSensorsPower();
|
|
|
|
|
for (j = 0; j < MAX_SERIAL_PORT_NUM; j++)
|
|
|
|
|
//for (j = 0; j < MAX_SERIAL_DEV_NUM; j++)
|
|
|
|
|
//Gm_CloseSensorsPower();
|
|
|
|
|
for (j = 1; j < MAX_SERIAL_PORT_NUM; j++)
|
|
|
|
|
ClearCmdFormPollCmdBuf(j);
|
|
|
|
|
sprintf(buf, "关闭串口定时器!");
|
|
|
|
|
sprintf(buf, "%s", "关闭串口定时器!");
|
|
|
|
|
DebugLog(8, buf, 'I');
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
@ -1692,7 +1694,7 @@ int SaveLogTofile(int commid, char *szbuf)
|
|
|
|
|
gettimeofday(&tv, NULL);
|
|
|
|
|
|
|
|
|
|
memset(filedir, 0, sizeof(filedir));
|
|
|
|
|
sprintf(filedir, "/sdcard/log/");
|
|
|
|
|
strcpy(filedir, "/sdcard/log/");
|
|
|
|
|
|
|
|
|
|
if (access(filedir, 0) == 0)
|
|
|
|
|
;//LOGI("文件路径已经存在!");
|
|
|
|
@ -1709,11 +1711,11 @@ int SaveLogTofile(int commid, char *szbuf)
|
|
|
|
|
if (NULL == fp)
|
|
|
|
|
return -1;
|
|
|
|
|
memset(buf, 0, sizeof(buf));
|
|
|
|
|
sprintf(buf, "%d-%d-%d %d:%d:%d-%d ", t0.tm_year + 1900, t0.tm_mon + 1, t0.tm_mday, t0.tm_hour, t0.tm_min, t0.tm_sec, tv.tv_usec / 1000);
|
|
|
|
|
sprintf(buf, "%d-%d-%d %d:%d:%d-%d ", t0.tm_year + 1900, t0.tm_mon + 1, t0.tm_mday, t0.tm_hour, t0.tm_min, t0.tm_sec, (int)(tv.tv_usec / 1000));
|
|
|
|
|
fwrite(buf, 1, strlen(buf), fp);
|
|
|
|
|
fwrite(szbuf, 1, strlen(szbuf), fp);
|
|
|
|
|
memset(buf, 0, sizeof(buf));
|
|
|
|
|
sprintf(buf, "\n");
|
|
|
|
|
strcpy(buf, "\n");
|
|
|
|
|
fwrite(buf, 1, strlen(buf), fp);
|
|
|
|
|
|
|
|
|
|
fclose(fp);
|
|
|
|
@ -1953,10 +1955,10 @@ void CameraPhotoPortDataProcess(SIO_PARAM_SERIAL_DEF *curserial)
|
|
|
|
|
if ((1 == SaveImageDataTofile(curserial)) && (SER_SAMPLE == curserial->image.state))
|
|
|
|
|
{
|
|
|
|
|
curserial->image.state = PHOTO_SAVE_SUCC;
|
|
|
|
|
memset(&serialport[0].image, 0, sizeof(PHOTO_DEF));
|
|
|
|
|
memmove((void *)&serialport[0].image, (void*)&curserial->image, sizeof(PHOTO_DEF));
|
|
|
|
|
}
|
|
|
|
|
recvend = 1;
|
|
|
|
|
memset(&serialport[0].image, 0, sizeof(PHOTO_DEF));
|
|
|
|
|
memmove((void *)&serialport[0].image, (void*)&curserial->image, sizeof(PHOTO_DEF));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
@ -2013,7 +2015,7 @@ void CameraPhotoPortDataProcess(SIO_PARAM_SERIAL_DEF *curserial)
|
|
|
|
|
if (0xFF == rtumsg.MsgData[6])
|
|
|
|
|
{
|
|
|
|
|
curserial->SerialCmdidx = -1;
|
|
|
|
|
sprintf(szbuf, "没有历史图片!结束读取图片!");
|
|
|
|
|
strcpy(szbuf, "没有历史图片!结束读取图片!");
|
|
|
|
|
DebugLog(0, szbuf, 'I');
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
@ -2040,7 +2042,7 @@ void CameraPhotoPortDataProcess(SIO_PARAM_SERIAL_DEF *curserial)
|
|
|
|
|
if (0xFF == rtumsg.MsgData[10])
|
|
|
|
|
{
|
|
|
|
|
curserial->SerialCmdidx = -1;
|
|
|
|
|
sprintf(szbuf, "摄像机图片保存失败!");
|
|
|
|
|
strcpy(szbuf, "摄像机图片保存失败!");
|
|
|
|
|
DebugLog(0, szbuf, 'E');
|
|
|
|
|
}
|
|
|
|
|
curserial->SerialCmdidx = -1;
|
|
|
|
@ -2147,13 +2149,13 @@ void SendCmdFormPollCmdBuf(int port)
|
|
|
|
|
serialport[devparam[srdt.curdevidx[port]].commid].m_iRevStatus = 0;
|
|
|
|
|
if (serialport[port].fd < 0)
|
|
|
|
|
return;
|
|
|
|
|
//ret = Gm_SetSerialPortParam(port);
|
|
|
|
|
//if (ret < 0)
|
|
|
|
|
// return;
|
|
|
|
|
ret = Gm_SetSerialPortParam(port);
|
|
|
|
|
if (ret < 0)
|
|
|
|
|
return;
|
|
|
|
|
len = GM_SerialComSend(&pPortParam->PollCmd[2], pPortParam->cmdlen - 2, port);
|
|
|
|
|
if (len < 1)
|
|
|
|
|
{
|
|
|
|
|
sprintf(buf, "串口%d, 发送命令失败!", port + 1);
|
|
|
|
|
sprintf(buf, "串口%d, 发送命令失败! fd = %d", port + 1, serialport[port].fd);
|
|
|
|
|
DebugLog(port, buf, 'E');
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
@ -2264,7 +2266,7 @@ int FindNextCameraPhotoCommand(SIO_PARAM_SERIAL_DEF *pPortParam)
|
|
|
|
|
if (lcurtime - pPortParam->FirstCmdTimeCnt > 35 * 1000)
|
|
|
|
|
{
|
|
|
|
|
pPortParam->SerialCmdidx = -1;
|
|
|
|
|
sprintf(szbuf, "串口摄像机未接或故障!结束拍照!");
|
|
|
|
|
strcpy(szbuf, "串口摄像机未接或故障!结束拍照!");
|
|
|
|
|
DebugLog(0, szbuf, 'I');
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
@ -2742,7 +2744,7 @@ void Gm_SendPelco_DCommand(SIO_PARAM_SERIAL_DEF *pPortParam, uint32_t cmdtype)
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sprintf(buf, "发送像机Pelco_D命令:");
|
|
|
|
|
strcpy(buf, "发送像机Pelco_D命令:");
|
|
|
|
|
BytestreamLOG(0, buf, commandbuf, len, 'D');
|
|
|
|
|
}
|
|
|
|
|
ClearCameraCmdFormPollCmdBuf(pPortParam);
|
|
|
|
@ -2767,7 +2769,7 @@ uint8_t Gm_Pelco_DCheck(uint8_t *msg, int len)
|
|
|
|
|
**********************************************************************************/
|
|
|
|
|
int FindNextShxyProtocolCommand(int devidx)
|
|
|
|
|
{
|
|
|
|
|
int cmdno = 0;
|
|
|
|
|
int cmdno = 1;
|
|
|
|
|
|
|
|
|
|
//如果命令缓冲区仍有命令,则退出本函数
|
|
|
|
|
if ((devparam[devidx].commid + 1 < 1) || (devparam[devidx].commid + 1 > MAX_SERIAL_PORT_NUM))
|
|
|
|
@ -3104,7 +3106,7 @@ void ShxyProtocolDataProcess(int devno)
|
|
|
|
|
//g_SelfTest.SensorsFault |= (0x01);
|
|
|
|
|
//if ((gDisSunRain & 0x80) == 0x80)
|
|
|
|
|
{
|
|
|
|
|
sprintf(szbuf, "ID:%d 温度:%0.3f ", devparam[devno].devaddr, fvalue);
|
|
|
|
|
sprintf(szbuf, "ID:%d 温度:%0.3f state=%d", devparam[devno].devaddr, fvalue, weatherpntmsg[AirTempNo]);
|
|
|
|
|
//DebugLog(devparam[devno].commid, szbuf, 'V');
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
@ -3282,7 +3284,7 @@ void delete_old_files(const char *path, int days)
|
|
|
|
|
if (stat(fullpath, &file_stat) == -1)
|
|
|
|
|
{
|
|
|
|
|
perror("stat");
|
|
|
|
|
sprintf(szbuf, "stat");
|
|
|
|
|
strcpy(szbuf, "stat");
|
|
|
|
|
DebugLog(8, szbuf, 'E');
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
@ -3402,12 +3404,17 @@ void Collect_sensor_data()
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#if 1
|
|
|
|
|
pthread_mutex_lock(&serial_mutex); // 加锁
|
|
|
|
|
static int ideletefile = 0;
|
|
|
|
|
char logbuf[64];
|
|
|
|
|
time_t now;
|
|
|
|
|
struct tm t0;
|
|
|
|
|
const char *path = "/sdcard/log"; // 指定目录路径
|
|
|
|
|
int days = 15; // 删除15天前的log文件
|
|
|
|
|
|
|
|
|
|
sprintf(logbuf, "进入程序时间:%lld, ideletefile=%d", get_msec(), ideletefile);
|
|
|
|
|
DebugLog(8, logbuf, 'I');
|
|
|
|
|
|
|
|
|
|
now = time(NULL);
|
|
|
|
|
localtime_r(&now, &t0);
|
|
|
|
|
if ((0 == t0.tm_hour) && (0 == ideletefile))
|
|
|
|
@ -3419,6 +3426,7 @@ void Collect_sensor_data()
|
|
|
|
|
ideletefile = 0;
|
|
|
|
|
#endif
|
|
|
|
|
GM_StartSerialComm();
|
|
|
|
|
pthread_mutex_unlock(&serial_mutex); // 解锁
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int Gm_SetCameraSerialPortParam(int fd, unsigned int baud)
|
|
|
|
@ -3430,7 +3438,7 @@ int Gm_SetCameraSerialPortParam(int fd, unsigned int baud)
|
|
|
|
|
if (ret < 0)
|
|
|
|
|
{
|
|
|
|
|
memset(szbuf, 0, sizeof(szbuf));
|
|
|
|
|
sprintf(szbuf, "摄像机串口波特率等参数设置错误!");
|
|
|
|
|
strcpy(szbuf, "摄像机串口波特率等参数设置错误!");
|
|
|
|
|
DebugLog(0, szbuf, 'E');
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
@ -3453,7 +3461,7 @@ int Gm_OpenCameraSerial(SIO_PARAM_SERIAL_DEF *pPortParam, char *serfile, unsigne
|
|
|
|
|
DebugLog(0, szbuf, 'E');
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
sprintf(szbuf, "摄像机打开串口%s成功!fd=%d", serfile, fd);
|
|
|
|
|
sprintf(szbuf, "摄像机打开串口%s成功!fd=%d 波特率:%d", serfile, fd, baud);
|
|
|
|
|
DebugLog(0, szbuf, 'I');
|
|
|
|
|
pPortParam->fd = fd;
|
|
|
|
|
serbaud = getBaudrate(baud);
|
|
|
|
@ -3474,7 +3482,7 @@ int GM_CameraComSend(unsigned char * cSendBuf, size_t nSendLen, int fd)
|
|
|
|
|
len = write(fd, cSendBuf, (size_t)nSendLen);/* 向串囗发送字符串 */
|
|
|
|
|
if (len < 0)
|
|
|
|
|
{
|
|
|
|
|
sprintf(szbuf, "write data error ");
|
|
|
|
|
strcpy(szbuf, "write data error ");
|
|
|
|
|
DebugLog(0, szbuf, 'E');
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
@ -3563,15 +3571,15 @@ void SendCameraCmdFormPollCmdBuf(SIO_PARAM_SERIAL_DEF *pPortParam)
|
|
|
|
|
len = GM_CameraComSend(&pPortParam->PollCmd[2], pPortParam->cmdlen - 2, pPortParam->fd);
|
|
|
|
|
if (len < 1)
|
|
|
|
|
{
|
|
|
|
|
sprintf(buf, "摄像机串口, 发送命令失败!");
|
|
|
|
|
strcpy(buf, "摄像机串口, 发送命令失败!");
|
|
|
|
|
DebugLog(0, buf, 'E');
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
sprintf(buf, "摄像机串口命令:");
|
|
|
|
|
strcpy(buf, "摄像机串口命令:");
|
|
|
|
|
BytestreamLOG(0, buf, &pPortParam->PollCmd[2], len, 'D');
|
|
|
|
|
sprintf(buf, "sendtimeconst= %lld", lctime - pPortParam->lsendtime);
|
|
|
|
|
sprintf(buf, "sendtimeconst= %lld", (long long)(lctime - pPortParam->lsendtime));
|
|
|
|
|
DebugLog(0, buf, 'W');
|
|
|
|
|
pPortParam->lsendtime = lctime;
|
|
|
|
|
}
|
|
|
|
@ -3619,24 +3627,41 @@ int GM_IsCloseCamera(SIO_PARAM_SERIAL_DEF *pPortParam)
|
|
|
|
|
pPortParam->image.state = SER_SAMPLEFAIL;
|
|
|
|
|
else if (PHOTO_SAVE_SUCC == pPortParam->image.state)
|
|
|
|
|
pPortParam->image.state = SAMPLINGSUCCESS;
|
|
|
|
|
sprintf(buf, "通道1摄像机使用完毕!可以关闭摄像机电源!");
|
|
|
|
|
strcpy(buf, "通道1摄像机使用完毕!可以关闭摄像机电源!");
|
|
|
|
|
DebugLog(0, buf, 'I');
|
|
|
|
|
if(pPortParam->fd >= 0)
|
|
|
|
|
{
|
|
|
|
|
close(pPortParam->fd);
|
|
|
|
|
pPortParam->fd = -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return pPortParam->SerialCmdidx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GM_CameraSerialComRecv(SIO_PARAM_SERIAL_DEF *pPortParam)
|
|
|
|
|
{
|
|
|
|
|
int recvlen;
|
|
|
|
|
int i, recvlen;
|
|
|
|
|
u_char recvbuf[RECVDATA_MAXLENTH];
|
|
|
|
|
char buf[256];
|
|
|
|
|
int64_t t0, t1;
|
|
|
|
|
|
|
|
|
|
t0 = get_msec();
|
|
|
|
|
|
|
|
|
|
memset(recvbuf, 0, sizeof(recvbuf));
|
|
|
|
|
if (pPortParam->fd <= 0)
|
|
|
|
|
return;
|
|
|
|
|
//for(;;)
|
|
|
|
|
recvlen = read(pPortParam->fd, recvbuf, sizeof(recvbuf));/* 在串口读取字符串 */
|
|
|
|
|
i=0;
|
|
|
|
|
recvlen = 0;
|
|
|
|
|
for(;;)
|
|
|
|
|
{
|
|
|
|
|
i += recvlen;
|
|
|
|
|
recvlen = read(pPortParam->fd, &recvbuf[i], sizeof(recvbuf)-i);/* 在串口读取字符串 */
|
|
|
|
|
t1 = get_msec();
|
|
|
|
|
if(t1-t0 >= 350)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
recvlen = i;
|
|
|
|
|
if (recvlen < 1)
|
|
|
|
|
return;
|
|
|
|
|
#if 1
|
|
|
|
@ -3653,47 +3678,48 @@ int GM_CameraSerialTimer(SIO_PARAM_SERIAL_DEF *pPortParam)
|
|
|
|
|
|
|
|
|
|
GM_CameraSerialComRecv(pPortParam);
|
|
|
|
|
Gm_FindCameraCommand(pPortParam);
|
|
|
|
|
GM_CameraSerialComRecv(pPortParam);
|
|
|
|
|
//GM_CameraSerialComRecv(pPortParam);
|
|
|
|
|
flag = GM_IsCloseCamera(pPortParam);
|
|
|
|
|
return flag;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if 1
|
|
|
|
|
// 启动使用串口拍照
|
|
|
|
|
int GM_StartSerialCameraPhoto(uint8_t channel, int cmdidx, u_char bImageSize, int phototime, u_char presetno, char *serfile, unsigned int baud, int addr)
|
|
|
|
|
int GM_StartSerialCameraPhoto(int phototime, unsigned char channel, int cmdidx, unsigned char bImageSize, unsigned char presetno, char *serfile, unsigned int baud, int addr)
|
|
|
|
|
{
|
|
|
|
|
int flag = 0;
|
|
|
|
|
char szbuf[128], logbuf[128];
|
|
|
|
|
SIO_PARAM_SERIAL_DEF cameraport;
|
|
|
|
|
SIO_PARAM_SERIAL_DEF *cameraport;
|
|
|
|
|
|
|
|
|
|
cameraport = (SIO_PARAM_SERIAL_DEF*)malloc(sizeof(SIO_PARAM_SERIAL_DEF));
|
|
|
|
|
srdt.RephotographCnt = 0;
|
|
|
|
|
|
|
|
|
|
cameraport.cameraaddr = addr;
|
|
|
|
|
cameraport.Retry = 0;
|
|
|
|
|
cameraport.RetryTime = 2000;
|
|
|
|
|
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);
|
|
|
|
|
cameraport->cameraaddr = addr;
|
|
|
|
|
cameraport->Retry = 0;
|
|
|
|
|
cameraport->RetryTime = 2000;
|
|
|
|
|
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);
|
|
|
|
|
Gm_OpenSensorsPower();
|
|
|
|
|
flag = Gm_OpenCameraSerial(&cameraport, serfile, baud);
|
|
|
|
|
flag = Gm_OpenCameraSerial(cameraport, serfile, baud);
|
|
|
|
|
|
|
|
|
|
#if 1
|
|
|
|
|
memset(szbuf, 0, sizeof(szbuf));
|
|
|
|
|
srdt.iLastGetPhotoNo = -1;
|
|
|
|
|
if (0 == cmdidx)
|
|
|
|
|
cameraport.image.state = SER_STARTSAMPLE;
|
|
|
|
|
cameraport->image.state = SER_STARTSAMPLE;
|
|
|
|
|
if ((0 == cmdidx) && (srdt.presetno > 0))
|
|
|
|
|
{
|
|
|
|
|
cameraport.SerialCmdidx = 10017;
|
|
|
|
|
cameraport->SerialCmdidx = 10017;
|
|
|
|
|
srdt.iLastGetPhotoNo = cmdidx;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
cameraport.SerialCmdidx = cmdidx;
|
|
|
|
|
cameraport.FirstCmdTimeCnt = get_msec();
|
|
|
|
|
cameraport->SerialCmdidx = cmdidx;
|
|
|
|
|
cameraport->FirstCmdTimeCnt = get_msec();
|
|
|
|
|
srdt.sendphotocmdcnt = 0;
|
|
|
|
|
//sprintf(szbuf, "摄像机");
|
|
|
|
|
//flag = 1;
|
|
|
|
@ -3707,7 +3733,14 @@ int GM_StartSerialCameraPhoto(uint8_t channel, int cmdidx, u_char bImageSize, in
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
if(-1 == flag)
|
|
|
|
|
{
|
|
|
|
|
if(NULL != cameraport)
|
|
|
|
|
{
|
|
|
|
|
free(cameraport);
|
|
|
|
|
cameraport = NULL;
|
|
|
|
|
}
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (0x00 == flag)
|
|
|
|
|
{
|
|
|
|
@ -3718,7 +3751,7 @@ int GM_StartSerialCameraPhoto(uint8_t channel, int cmdidx, u_char bImageSize, in
|
|
|
|
|
usleep(10);
|
|
|
|
|
//LOGW("polltime=%ldms", get_msec()-polltime);
|
|
|
|
|
//polltime = get_msec();
|
|
|
|
|
if (GM_CameraSerialTimer(&cameraport) < 0)
|
|
|
|
|
if (GM_CameraSerialTimer(cameraport) < 0)
|
|
|
|
|
{
|
|
|
|
|
//LOGE("12V state=%d", getInt(CMD_SET_12V_EN_STATE));
|
|
|
|
|
DebugLog(8, "退出操作摄像机流程!", 'V');
|
|
|
|
@ -3727,18 +3760,25 @@ int GM_StartSerialCameraPhoto(uint8_t channel, int cmdidx, u_char bImageSize, in
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(NULL != cameraport)
|
|
|
|
|
{
|
|
|
|
|
free(cameraport);
|
|
|
|
|
cameraport = NULL;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
int CameraPhotoCmd(int phototime, u_char channel, int cmdidx, u_char bImageSize, u_char presetno, char *serfile, unsigned int baud, int addr)
|
|
|
|
|
int CameraPhotoCmd(int phototime, unsigned char channel, int cmdidx, unsigned char bImageSize, unsigned char presetno, char *serfile, unsigned int baud, int addr)
|
|
|
|
|
{
|
|
|
|
|
pthread_mutex_lock(&camera_mutex);
|
|
|
|
|
int flag = 0;
|
|
|
|
|
|
|
|
|
|
srdt.bImageSize = bImageSize;
|
|
|
|
|
srdt.presetno = presetno;
|
|
|
|
|
srdt.sendphototime = phototime;
|
|
|
|
|
flag = GM_StartSerialCameraPhoto(channel, cmdidx, bImageSize, phototime, presetno, serfile, baud, addr);
|
|
|
|
|
flag = GM_StartSerialCameraPhoto(phototime, channel, cmdidx, bImageSize, presetno, serfile, baud, addr);
|
|
|
|
|
pthread_mutex_unlock(&camera_mutex); // 解锁
|
|
|
|
|
return flag;
|
|
|
|
|
}
|
|
|
|
|
/* 串口启动接口函数 结束*/
|
|
|
|
@ -3747,6 +3787,7 @@ int CameraPhotoCmd(int phototime, u_char channel, int cmdidx, u_char bImageSize,
|
|
|
|
|
int GetWeatherData(Data_DEF *data, int datano)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
char logbuf[512], szbuf[128];
|
|
|
|
|
|
|
|
|
|
if (NULL == data)
|
|
|
|
|
return -1;
|
|
|
|
@ -3754,6 +3795,36 @@ int GetWeatherData(Data_DEF *data, int datano)
|
|
|
|
|
return -1;
|
|
|
|
|
data->EuValue = weatherpntmsg[datano].EuValue;
|
|
|
|
|
data->AiState = weatherpntmsg[datano].AiState;
|
|
|
|
|
memset(szbuf, 0, sizeof(szbuf));
|
|
|
|
|
switch (datano)
|
|
|
|
|
{
|
|
|
|
|
case AirTempNo:
|
|
|
|
|
sprintf(szbuf, "温度");
|
|
|
|
|
break;
|
|
|
|
|
case HumidityNo:
|
|
|
|
|
sprintf(szbuf, "湿度");
|
|
|
|
|
break;
|
|
|
|
|
case WindSpeedNo:
|
|
|
|
|
sprintf(szbuf, "风速");
|
|
|
|
|
break;
|
|
|
|
|
case WindDirectionNo:
|
|
|
|
|
sprintf(szbuf, "风向");
|
|
|
|
|
break;
|
|
|
|
|
case RainfallNo:
|
|
|
|
|
sprintf(szbuf, "雨量");
|
|
|
|
|
break;
|
|
|
|
|
case AtmosNo:
|
|
|
|
|
sprintf(szbuf, "大气压");
|
|
|
|
|
break;
|
|
|
|
|
case OpticalRadiationNo:
|
|
|
|
|
sprintf(szbuf, "大气压");
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
sprintf(szbuf, "未知");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
sprintf(logbuf, "data_state=%d, %svalue=%0.3f", data->AiState, szbuf,data->EuValue);
|
|
|
|
|
DebugLog(8, logbuf, 'I');
|
|
|
|
|
if ((SER_SAMPLEFAIL == data->AiState) || (SAMPLINGSUCCESS == data->AiState))
|
|
|
|
|
{
|
|
|
|
|
weatherpntmsg[datano].AiState = SER_IDLE;
|
|
|
|
@ -3764,10 +3835,14 @@ int GetWeatherData(Data_DEF *data, int datano)
|
|
|
|
|
|
|
|
|
|
int GetAirTempData(Data_DEF *airt)
|
|
|
|
|
{
|
|
|
|
|
char logbuf[512];
|
|
|
|
|
|
|
|
|
|
if (NULL == airt)
|
|
|
|
|
return -1;
|
|
|
|
|
airt->EuValue = weatherpntmsg[AirTempNo].EuValue;
|
|
|
|
|
airt->AiState = weatherpntmsg[AirTempNo].AiState;
|
|
|
|
|
sprintf(logbuf, "data_state=%d, 温度value=%0.3f", airt->AiState, airt->EuValue);
|
|
|
|
|
DebugLog(8, logbuf, 'I');
|
|
|
|
|
if ((SER_SAMPLEFAIL == airt->AiState) || (SAMPLINGSUCCESS == airt->AiState))
|
|
|
|
|
{
|
|
|
|
|
weatherpntmsg[AirTempNo].AiState = SER_IDLE;
|
|
|
|
@ -3778,10 +3853,14 @@ int GetAirTempData(Data_DEF *airt)
|
|
|
|
|
|
|
|
|
|
int GetHumidityData(Data_DEF *airt)
|
|
|
|
|
{
|
|
|
|
|
char logbuf[512];
|
|
|
|
|
|
|
|
|
|
if (NULL == airt)
|
|
|
|
|
return -1;
|
|
|
|
|
airt->EuValue = weatherpntmsg[HumidityNo].EuValue;
|
|
|
|
|
airt->AiState = weatherpntmsg[HumidityNo].AiState;
|
|
|
|
|
sprintf(logbuf, "data_state=%d, 湿度value=%0.3f", airt->AiState, airt->EuValue);
|
|
|
|
|
DebugLog(8, logbuf, 'I');
|
|
|
|
|
if ((SER_SAMPLEFAIL == airt->AiState) || (SAMPLINGSUCCESS == airt->AiState))
|
|
|
|
|
{
|
|
|
|
|
weatherpntmsg[HumidityNo].AiState = SER_IDLE;
|
|
|
|
@ -3792,10 +3871,14 @@ int GetHumidityData(Data_DEF *airt)
|
|
|
|
|
|
|
|
|
|
int GetWindSpeedData(Data_DEF *airt)
|
|
|
|
|
{
|
|
|
|
|
char logbuf[512];
|
|
|
|
|
|
|
|
|
|
if (NULL == airt)
|
|
|
|
|
return -1;
|
|
|
|
|
airt->EuValue = weatherpntmsg[WindSpeedNo].EuValue;
|
|
|
|
|
airt->AiState = weatherpntmsg[WindSpeedNo].AiState;
|
|
|
|
|
sprintf(logbuf, "data_state=%d, 风速value=%0.3f", airt->AiState, airt->EuValue);
|
|
|
|
|
DebugLog(8, logbuf, 'I');
|
|
|
|
|
if ((SER_SAMPLEFAIL == airt->AiState) || (SAMPLINGSUCCESS == airt->AiState))
|
|
|
|
|
{
|
|
|
|
|
weatherpntmsg[WindSpeedNo].AiState = SER_IDLE;
|
|
|
|
@ -3806,10 +3889,14 @@ int GetWindSpeedData(Data_DEF *airt)
|
|
|
|
|
|
|
|
|
|
int GetWindDirectionData(Data_DEF *airt)
|
|
|
|
|
{
|
|
|
|
|
char logbuf[512];
|
|
|
|
|
|
|
|
|
|
if (NULL == airt)
|
|
|
|
|
return -1;
|
|
|
|
|
airt->EuValue = weatherpntmsg[WindDirectionNo].EuValue;
|
|
|
|
|
airt->AiState = weatherpntmsg[WindDirectionNo].AiState;
|
|
|
|
|
sprintf(logbuf, "data_state=%d, 风向value=%0.3f", airt->AiState, airt->EuValue);
|
|
|
|
|
DebugLog(8, logbuf, 'I');
|
|
|
|
|
if ((SER_SAMPLEFAIL == airt->AiState) || (SAMPLINGSUCCESS == airt->AiState))
|
|
|
|
|
{
|
|
|
|
|
weatherpntmsg[WindDirectionNo].AiState = SER_IDLE;
|
|
|
|
@ -3820,10 +3907,14 @@ int GetWindDirectionData(Data_DEF *airt)
|
|
|
|
|
|
|
|
|
|
int GetRainfallData(Data_DEF *airt)
|
|
|
|
|
{
|
|
|
|
|
char logbuf[512];
|
|
|
|
|
|
|
|
|
|
if (NULL == airt)
|
|
|
|
|
return -1;
|
|
|
|
|
airt->EuValue = weatherpntmsg[RainfallNo].EuValue;
|
|
|
|
|
airt->AiState = weatherpntmsg[RainfallNo].AiState;
|
|
|
|
|
sprintf(logbuf, "data_state=%d, 雨量value=%0.3f", airt->AiState, airt->EuValue);
|
|
|
|
|
DebugLog(8, logbuf, 'I');
|
|
|
|
|
if ((SER_SAMPLEFAIL == airt->AiState) || (SAMPLINGSUCCESS == airt->AiState))
|
|
|
|
|
{
|
|
|
|
|
weatherpntmsg[RainfallNo].AiState = SER_IDLE;
|
|
|
|
@ -3834,10 +3925,14 @@ int GetRainfallData(Data_DEF *airt)
|
|
|
|
|
|
|
|
|
|
int GetAtmosData(Data_DEF *airt)
|
|
|
|
|
{
|
|
|
|
|
char logbuf[512];
|
|
|
|
|
|
|
|
|
|
if (NULL == airt)
|
|
|
|
|
return -1;
|
|
|
|
|
airt->EuValue = weatherpntmsg[AtmosNo].EuValue;
|
|
|
|
|
airt->AiState = weatherpntmsg[AtmosNo].AiState;
|
|
|
|
|
sprintf(logbuf, "data_state=%d, 大气压value=%0.3f", airt->AiState, airt->EuValue);
|
|
|
|
|
DebugLog(8, logbuf, 'I');
|
|
|
|
|
if ((SER_SAMPLEFAIL == airt->AiState) || (SAMPLINGSUCCESS == airt->AiState))
|
|
|
|
|
{
|
|
|
|
|
weatherpntmsg[AtmosNo].AiState = SER_IDLE;
|
|
|
|
@ -3848,10 +3943,14 @@ int GetAtmosData(Data_DEF *airt)
|
|
|
|
|
|
|
|
|
|
int GetOpticalRadiationData(Data_DEF *airt)
|
|
|
|
|
{
|
|
|
|
|
char logbuf[512];
|
|
|
|
|
|
|
|
|
|
if (NULL == airt)
|
|
|
|
|
return -1;
|
|
|
|
|
airt->EuValue = weatherpntmsg[OpticalRadiationNo].EuValue;
|
|
|
|
|
airt->AiState = weatherpntmsg[OpticalRadiationNo].AiState;
|
|
|
|
|
sprintf(logbuf, "data_state=%d, 日照value=%0.3f", airt->AiState, airt->EuValue);
|
|
|
|
|
DebugLog(8, logbuf, 'I');
|
|
|
|
|
if ((SER_SAMPLEFAIL == airt->AiState) || (SAMPLINGSUCCESS == airt->AiState))
|
|
|
|
|
{
|
|
|
|
|
weatherpntmsg[OpticalRadiationNo].AiState = SER_IDLE;
|
|
|
|
@ -3862,6 +3961,8 @@ int GetOpticalRadiationData(Data_DEF *airt)
|
|
|
|
|
|
|
|
|
|
int GetPullValue(int devno, Data_DEF *data)
|
|
|
|
|
{
|
|
|
|
|
char logbuf[512];
|
|
|
|
|
|
|
|
|
|
if (NULL == data)
|
|
|
|
|
return -1;
|
|
|
|
|
if ((0 > devno) || (MAX_SERIAL_DEV_NUM < devno))
|
|
|
|
@ -3870,6 +3971,8 @@ int GetPullValue(int devno, Data_DEF *data)
|
|
|
|
|
return -1;
|
|
|
|
|
data->EuValue = srdt.ms_dev[devno].aiValue[0].EuValue;
|
|
|
|
|
data->AiState = srdt.ms_dev[devno].aiValue[0].AiState;
|
|
|
|
|
sprintf(logbuf, "装置%d, ID=%d, data_state=%d, 拉力value=%0.3f", devno + 1, devparam[devno].devaddr, data->AiState, data->EuValue);
|
|
|
|
|
DebugLog(8, logbuf, 'I');
|
|
|
|
|
if ((SER_SAMPLEFAIL == data->AiState) || (SAMPLINGSUCCESS == data->AiState))
|
|
|
|
|
{
|
|
|
|
|
srdt.ms_dev[devno].aiValue[0].AiState = SER_IDLE;
|
|
|
|
@ -3880,6 +3983,8 @@ int GetPullValue(int devno, Data_DEF *data)
|
|
|
|
|
|
|
|
|
|
int GetAngleValue(int devno, Data_DEF *data, int Xy)
|
|
|
|
|
{
|
|
|
|
|
char logbuf[512];
|
|
|
|
|
|
|
|
|
|
if (NULL == data)
|
|
|
|
|
return -1;
|
|
|
|
|
if ((0 > devno) || (MAX_SERIAL_DEV_NUM < devno))
|
|
|
|
@ -3891,6 +3996,8 @@ int GetAngleValue(int devno, Data_DEF *data, int Xy)
|
|
|
|
|
|
|
|
|
|
data->EuValue = srdt.ms_dev[devno].aiValue[Xy].EuValue;
|
|
|
|
|
data->AiState = srdt.ms_dev[devno].aiValue[Xy].AiState;
|
|
|
|
|
sprintf(logbuf, "装置%d, ID=%d, data_state=%d, 倾角value[%d]=%0.3f", devno + 1, devparam[devno].devaddr, data->AiState, Xy, data->EuValue);
|
|
|
|
|
DebugLog(8, logbuf, 'I');
|
|
|
|
|
if ((SER_SAMPLEFAIL == data->AiState) || (SAMPLINGSUCCESS == data->AiState))
|
|
|
|
|
{
|
|
|
|
|
srdt.ms_dev[devno].aiValue[Xy].AiState = SER_IDLE;
|
|
|
|
@ -3901,6 +4008,8 @@ int GetAngleValue(int devno, Data_DEF *data, int Xy)
|
|
|
|
|
|
|
|
|
|
int GetImage(int devno, IMAGE_DEF *photo)
|
|
|
|
|
{
|
|
|
|
|
char logbuf[512];
|
|
|
|
|
|
|
|
|
|
if (NULL == photo)
|
|
|
|
|
return -1;
|
|
|
|
|
photo->presetno = serialport[0].image.presetno;
|
|
|
|
@ -3909,6 +4018,9 @@ int GetImage(int devno, IMAGE_DEF *photo)
|
|
|
|
|
memmove(photo->photoname, serialport[0].image.photoname, sizeof(photo->photoname));
|
|
|
|
|
photo->imagelen = serialport[0].image.imagelen;
|
|
|
|
|
photo->state = serialport[0].image.state;
|
|
|
|
|
|
|
|
|
|
sprintf(logbuf, "装置%d, image_state=%d, 预置点:%d,拍照时间:%d, pic_name:%s", devno + 1, photo->state, photo->presetno, photo->phototime, photo->photoname);
|
|
|
|
|
DebugLog(8, logbuf, 'I');
|
|
|
|
|
if ((SER_SAMPLEFAIL == photo->state) || (SAMPLINGSUCCESS == photo->state))
|
|
|
|
|
{
|
|
|
|
|
serialport[0].image.state = SER_IDLE;
|
|
|
|
|