|
|
|
@ -22,12 +22,15 @@
|
|
|
|
|
#include "GPIOControl.h"
|
|
|
|
|
#include "SerialComm.h"
|
|
|
|
|
#include <sys/time.h>
|
|
|
|
|
#include <pthread.h>
|
|
|
|
|
|
|
|
|
|
#include <AndroidHelper.h>
|
|
|
|
|
#include <Client/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];
|
|
|
|
|
|
|
|
|
@ -1897,13 +1900,13 @@ void CameraPhotoPortDataProcess(SIO_PARAM_SERIAL_DEF *curserial)
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
memset(&serialport[0].image, 0, sizeof(PHOTO_DEF));
|
|
|
|
|
memmove((void *)&serialport[0].image, (void*)&curserial->image, sizeof(PHOTO_DEF));
|
|
|
|
|
if ((1 == SaveImageDataTofile(curserial)) && (SER_SAMPLE == curserial->image.state))
|
|
|
|
|
{
|
|
|
|
|
curserial->image.state = PHOTO_SAVE_SUCC;
|
|
|
|
|
}
|
|
|
|
|
recvend = 1;
|
|
|
|
|
memset(&serialport[0].image, 0, sizeof(PHOTO_DEF));
|
|
|
|
|
memmove((void *)&serialport[0].image, (void*)&curserial->image, sizeof(PHOTO_DEF));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
@ -3349,11 +3352,15 @@ 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);
|
|
|
|
@ -3366,6 +3373,7 @@ void Collect_sensor_data()
|
|
|
|
|
ideletefile = 0;
|
|
|
|
|
#endif
|
|
|
|
|
GM_StartSerialComm();
|
|
|
|
|
pthread_mutex_unlock(&serial_mutex); // 解锁
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int Gm_SetCameraSerialPortParam(int fd, unsigned int baud)
|
|
|
|
@ -3400,7 +3408,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);
|
|
|
|
@ -3568,6 +3576,11 @@ int GM_IsCloseCamera(SIO_PARAM_SERIAL_DEF *pPortParam)
|
|
|
|
|
pPortParam->image.state = SAMPLINGSUCCESS;
|
|
|
|
|
strcpy(buf, "通道1摄像机使用完毕!可以关闭摄像机电源!");
|
|
|
|
|
DebugLog(0, buf, 'I');
|
|
|
|
|
if(pPortParam->fd >= 0)
|
|
|
|
|
{
|
|
|
|
|
close(pPortParam->fd);
|
|
|
|
|
pPortParam->fd = -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return pPortParam->SerialCmdidx;
|
|
|
|
|
}
|
|
|
|
@ -3590,7 +3603,7 @@ void GM_CameraSerialComRecv(SIO_PARAM_SERIAL_DEF *pPortParam)
|
|
|
|
|
i += recvlen;
|
|
|
|
|
recvlen = read(pPortParam->fd, &recvbuf[i], sizeof(recvbuf)-i);/* 在串口读取字符串 */
|
|
|
|
|
t1 = get_msec();
|
|
|
|
|
if(t1-t0 >= 500)
|
|
|
|
|
if(t1-t0 >= 350)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -3666,7 +3679,14 @@ int GM_StartSerialCameraPhoto(int phototime, unsigned char channel, int cmdidx,
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
if(-1 == flag)
|
|
|
|
|
{
|
|
|
|
|
if(NULL != cameraport)
|
|
|
|
|
{
|
|
|
|
|
free(cameraport);
|
|
|
|
|
cameraport = NULL;
|
|
|
|
|
}
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (0x00 == flag)
|
|
|
|
|
{
|
|
|
|
@ -3686,18 +3706,25 @@ int GM_StartSerialCameraPhoto(int phototime, unsigned char channel, int cmdidx,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(NULL != cameraport)
|
|
|
|
|
{
|
|
|
|
|
free(cameraport);
|
|
|
|
|
cameraport = NULL;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
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(phototime, channel, cmdidx, bImageSize, presetno, serfile, baud, addr);
|
|
|
|
|
pthread_mutex_unlock(&camera_mutex); // 解锁
|
|
|
|
|
return flag;
|
|
|
|
|
}
|
|
|
|
|
/* 串口启动接口函数 结束*/
|
|
|
|
|