|
|
|
@ -2,37 +2,26 @@
|
|
|
|
|
// Created by hyz on 2024/6/5.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#ifndef WEATHERCOMM_H
|
|
|
|
|
#define WEATHERCOMM_H
|
|
|
|
|
#ifndef __SENSOR_PROTOCOL_H__
|
|
|
|
|
#define __SENSOR_PROTOCOL_H__
|
|
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
#include "GPIOControl.h"
|
|
|
|
|
#include "termios.h"
|
|
|
|
|
|
|
|
|
|
#ifndef DWORD
|
|
|
|
|
typedef unsigned int DWORD;
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef WORD
|
|
|
|
|
typedef unsigned short WORD;
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef BYTE
|
|
|
|
|
typedef unsigned char BYTE;
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef LONG
|
|
|
|
|
typedef long long LONG;
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef FALSE
|
|
|
|
|
#define FALSE 0
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef TRUE
|
|
|
|
|
#define TRUE 1
|
|
|
|
|
#ifndef LOBYTE
|
|
|
|
|
#define LOBYTE(w) ((unsigned char)(w))
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#define LOBYTE(w) ((unsigned char)(w))
|
|
|
|
|
#ifndef HIBYTE
|
|
|
|
|
#define HIBYTE(w) ((unsigned char)(((unsigned short)(w) >> 8) & 0xFF))
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#define LOWORD(l) ((WORD)(l))
|
|
|
|
|
#define HIWORD(l) ((WORD)((DWORD)(l) >> 16))
|
|
|
|
|
#ifndef LOWORD
|
|
|
|
|
#define LOWORD(l) ((uint16_t)(l))
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef HIWORD
|
|
|
|
|
#define HIWORD(l) ((uint16_t)((uint32_t)(l) >> 16))
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#define min(a, b) ((a) < (b) ? (a) : (b))
|
|
|
|
|
#define MAX_STRING_LEN 32
|
|
|
|
@ -63,11 +52,11 @@ typedef long long LONG;
|
|
|
|
|
#define AtmosNo 5 /* 大气压数据存储序号*/
|
|
|
|
|
#define OpticalRadiationNo 6 /* 日照(光辐射)数据存储序号*/
|
|
|
|
|
|
|
|
|
|
#define Idle 0 /* 传感器处于空闲状态,未启动采样*/
|
|
|
|
|
#define Sample 1 /* 正在采样过程中*/
|
|
|
|
|
#define SamplingSuccess 2 /* 采样结束,正常读取到数据*/
|
|
|
|
|
#define StartSample 3 /* 启动采样*/
|
|
|
|
|
#define SampleFail -1 /* 采样失败,未采集到数据,传感器故障或未接*/
|
|
|
|
|
#define SER_IDLE 0 /* 传感器处于空闲状态,未启动采样*/
|
|
|
|
|
#define SER_SAMPLE 1 /* 正在采样过程中*/
|
|
|
|
|
#define SAMPLINGSUCCESS 2 /* 采样结束,正常读取到数据*/
|
|
|
|
|
#define SER_STARTSAMPLE 3 /* 启动采样*/
|
|
|
|
|
#define SER_SAMPLEFAIL -1 /* 采样失败,未采集到数据,传感器故障或未接*/
|
|
|
|
|
#define PHOTO_SAVE_SUCC 5 /* 图片保存成功*/
|
|
|
|
|
|
|
|
|
|
#define WEATHER_DATA_NUM 8 /* 气象数据最大数量(一般最多是6要素)*/
|
|
|
|
@ -138,7 +127,7 @@ typedef long long LONG;
|
|
|
|
|
#define SPEED_DOME_CAMERA 0 /* 球机摄像机*/
|
|
|
|
|
#define SERIAL_CAMERA 2 /* 串口摄像机a*/
|
|
|
|
|
|
|
|
|
|
#define COLLECT_DATA 1 /* 调试使用*/
|
|
|
|
|
#define COLLECT_DATA 0 /* 调试使用*/
|
|
|
|
|
|
|
|
|
|
#define LOGE(fmt, args...) __android_log_print(ANDROID_LOG_ERROR, "serial_port_comm", fmt, ##args) /* 红色*/
|
|
|
|
|
#define LOGI(fmt, args...) __android_log_print(ANDROID_LOG_INFO, "Sensors_Protocol", fmt, ##args) /* 草绿色*/
|
|
|
|
@ -152,17 +141,16 @@ typedef struct
|
|
|
|
|
int cmd;
|
|
|
|
|
int value;
|
|
|
|
|
int result;
|
|
|
|
|
LONG value2;
|
|
|
|
|
uint64_t value2;
|
|
|
|
|
char str[MAX_STRING_LEN];
|
|
|
|
|
}IOT_PARAM;
|
|
|
|
|
|
|
|
|
|
//SDS包类型结构
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
BYTE PortIdx; // 信息类型
|
|
|
|
|
WORD MsgType; // 信息类型
|
|
|
|
|
uint8_t PortIdx; // 信息类型
|
|
|
|
|
uint16_t MsgType; // 信息类型
|
|
|
|
|
int MsgLen; // 信息长度
|
|
|
|
|
u_char MsgData[RECVDATA_MAXLENTH];
|
|
|
|
|
uint8_t MsgData[RECVDATA_MAXLENTH];
|
|
|
|
|
} RTUMSG;
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
@ -180,7 +168,7 @@ typedef struct
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
BYTE AiState; // 数据标识(-1:采样失败;0:没有采样;1:正在采样;2:采样结束;3:启动采样;)
|
|
|
|
|
uint8_t AiState; // 数据标识(-1:采样失败;0:没有采样;1:正在采样;2:采样结束;3:启动采样;)
|
|
|
|
|
float EuValue; // 数据工程值
|
|
|
|
|
} Data_DEF;
|
|
|
|
|
|
|
|
|
@ -188,7 +176,7 @@ typedef struct
|
|
|
|
|
{
|
|
|
|
|
int imagelen; // 整个图片大小
|
|
|
|
|
int phototime; // 拍照时间
|
|
|
|
|
u_char presetno; // 拍照预置点
|
|
|
|
|
uint8_t presetno; // 拍照预置点
|
|
|
|
|
char photoname[512]; // 图片存储名称和路径
|
|
|
|
|
int state;// 标识(-1:拍照失败;0:没有拍照;1:正在取图;2:拍照成功;3:启动拍照;)
|
|
|
|
|
} IMAGE_DEF;
|
|
|
|
@ -198,15 +186,15 @@ typedef struct
|
|
|
|
|
int imagelen; // 整个图片大小
|
|
|
|
|
int imagenum; // 整个图片的总包数
|
|
|
|
|
int phototime; // 拍照时间
|
|
|
|
|
u_char presetno; // 拍照预置点
|
|
|
|
|
uint8_t presetno; // 拍照预置点
|
|
|
|
|
char photoname[512]; // 图片存储名称和路径
|
|
|
|
|
u_char buf[MAX_PHOTO_PACKET_NUM][MAX_PHOTO_FRAME_LEN]; // 图片数据缓存
|
|
|
|
|
uint8_t buf[MAX_PHOTO_PACKET_NUM][MAX_PHOTO_FRAME_LEN]; // 图片数据缓存
|
|
|
|
|
int ilen[MAX_PHOTO_PACKET_NUM]; // 相对应的每包图片数据的长度
|
|
|
|
|
int state;// 标识(-1:拍照失败;0:没有拍照;1:正在取图;2:拍照成功;3:启动拍照;)
|
|
|
|
|
} PHOTO_DEF;
|
|
|
|
|
|
|
|
|
|
// 上层调用采集传感器参数
|
|
|
|
|
typedef struct
|
|
|
|
|
typedef struct SENSOR_PARAM
|
|
|
|
|
{
|
|
|
|
|
unsigned int baudrate; /* 波特率*/
|
|
|
|
|
int databit; /* 数据位*/
|
|
|
|
@ -214,11 +202,11 @@ typedef struct
|
|
|
|
|
char parity; /* 校验位*/
|
|
|
|
|
char pathname[64]; /* 串口文件名及路径*/
|
|
|
|
|
//int commNo; /* 约定的串口序号,例如我们PC机上显示的COM1。。。*/
|
|
|
|
|
u_char SensorsType; /* 传感器类型索引,大于 0*/
|
|
|
|
|
uint8_t SensorsType; /* 传感器类型索引,大于 0*/
|
|
|
|
|
int devaddr; /* 装置(传感器)使用的地址*/
|
|
|
|
|
u_char IsNoInsta; /* 装置没有安装或者已经坏了(1:正常, 0:无效,坏了或没有安装)*/
|
|
|
|
|
u_char CameraChannel; /* 像机的通道号*/
|
|
|
|
|
u_char Phase; /* 传感器所安装相别,指拉力和倾角11表示A1....*/
|
|
|
|
|
uint8_t IsNoInsta; /* 装置没有安装或者已经坏了(1:正常, 0:无效,坏了或没有安装)*/
|
|
|
|
|
uint8_t CameraChannel; /* 像机的通道号*/
|
|
|
|
|
uint8_t Phase; /* 传感器所安装相别,指拉力和倾角11表示A1....*/
|
|
|
|
|
} SENSOR_PARAM;
|
|
|
|
|
|
|
|
|
|
// 需要配置的串口装置参数
|
|
|
|
@ -230,11 +218,11 @@ typedef struct
|
|
|
|
|
char parity; /* 校验位*/
|
|
|
|
|
char pathname[64]; /* 串口文件名及路径*/
|
|
|
|
|
int commid; /* 串口序号 注意:从0开始*/
|
|
|
|
|
u_char ProtocolIdx; /* 规约索引,大于 0*/
|
|
|
|
|
uint8_t ProtocolIdx; /* 规约索引,大于 0*/
|
|
|
|
|
int devaddr; /* 装置使用的地址*/
|
|
|
|
|
u_char IsNoInsta; /* 装置没有安装或者已经坏了(1:正常, 0:无效,坏了或没有安装)*/
|
|
|
|
|
u_char CameraChannel; /* 像机的通道号*/
|
|
|
|
|
u_char Phase; /* 传感器所安装相别,指拉力和倾角11表示A1....*/
|
|
|
|
|
uint8_t IsNoInsta; /* 装置没有安装或者已经坏了(1:正常, 0:无效,坏了或没有安装)*/
|
|
|
|
|
uint8_t CameraChannel; /* 像机的通道号*/
|
|
|
|
|
uint8_t Phase; /* 传感器所安装相别,指拉力和倾角11表示A1....*/
|
|
|
|
|
} SERIAL_PARAM;
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
@ -243,40 +231,45 @@ typedef struct
|
|
|
|
|
int m_iRecvLen; /* */
|
|
|
|
|
int m_iNeedRevLength; /* */
|
|
|
|
|
int iRecvTime; /* */
|
|
|
|
|
u_char m_au8RecvBuf[RECVDATA_MAXLENTH];/* */
|
|
|
|
|
uint8_t m_au8RecvBuf[RECVDATA_MAXLENTH];/* */
|
|
|
|
|
int fd; /* 串口打开的文件句柄*/
|
|
|
|
|
u_char PollCmd[SENDDATA_MAXLENTH];
|
|
|
|
|
uint8_t PollCmd[SENDDATA_MAXLENTH];
|
|
|
|
|
int cmdlen; // 发送缓冲区命令长度
|
|
|
|
|
//******************** Poll Cmd ****************************
|
|
|
|
|
u_char Retry; /* 重试命令次数 */
|
|
|
|
|
u_char RetryCnt; /* 重试命令计数*/
|
|
|
|
|
LONG RetryTime; /* 重试命令时间 */
|
|
|
|
|
LONG RetryTimeCnt; /* 重试命令时间计数*/
|
|
|
|
|
LONG WaitTime; /* 命令间隔时间 */
|
|
|
|
|
LONG WaitTimeCnt; /* 命令间隔时间计数*/
|
|
|
|
|
u_char ForceWaitFlag; /* 强制等待标志*/
|
|
|
|
|
u_short ForceWaitCnt; /* 强制等待计数*/
|
|
|
|
|
u_char ReSendCmdFlag; /* 重发命令标志 */
|
|
|
|
|
u_char SendCmdFlag; /* 命令发送标志 */
|
|
|
|
|
u_char RevCmdFlag; /* 命令正常接收标志*/
|
|
|
|
|
uint8_t Retry; /* 重试命令次数 */
|
|
|
|
|
uint8_t RetryCnt; /* 重试命令计数*/
|
|
|
|
|
int64_t RetryTime; /* 重试命令时间 */
|
|
|
|
|
int64_t RetryTimeCnt; /* 重试命令时间计数*/
|
|
|
|
|
int64_t WaitTime; /* 命令间隔时间 */
|
|
|
|
|
int64_t WaitTimeCnt; /* 命令间隔时间计数*/
|
|
|
|
|
uint8_t ForceWaitFlag; /* 强制等待标志*/
|
|
|
|
|
uint16_t ForceWaitCnt; /* 强制等待计数*/
|
|
|
|
|
uint8_t ReSendCmdFlag; /* 重发命令标志 */
|
|
|
|
|
uint8_t SendCmdFlag; /* 命令发送标志 */
|
|
|
|
|
uint8_t RevCmdFlag; /* 命令正常接收标志*/
|
|
|
|
|
//**********************************************************
|
|
|
|
|
LONG lsendtime; /* 命令发送绝对时间计时(毫秒)*/
|
|
|
|
|
int64_t lsendtime; /* 命令发送绝对时间计时(毫秒)*/
|
|
|
|
|
int cameraaddr; /* 摄像机地址*/
|
|
|
|
|
int SerialCmdidx; /* 正在使用的串口发送命令的命令序号(-1:表示没有命令发送)
|
|
|
|
|
摄像机使用命令序号存储*/
|
|
|
|
|
PHOTO_DEF image; /* 临时存储图片数据*/
|
|
|
|
|
int64_t FirstCmdTimeCnt; /* 串口读取数据起始时间*/
|
|
|
|
|
} SIO_PARAM_SERIAL_DEF;
|
|
|
|
|
|
|
|
|
|
//串口相关装置所有参数集中定义
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
//******************** 端口基本信息 ************************
|
|
|
|
|
u_char IsNeedSerial; /* 是否需要使用串口通讯*/
|
|
|
|
|
uint8_t IsNeedSerial; /* 是否需要使用串口通讯*/
|
|
|
|
|
int CmdWaitTime; /* 没有使用*/
|
|
|
|
|
u_char UseSerialidx; /* 使用的串口序号*/
|
|
|
|
|
uint8_t UseSerialidx; /* 使用的串口序号*/
|
|
|
|
|
int SerialCmdidx; /* 正在使用的串口发送命令的命令序号(-1:表示没有命令发送)
|
|
|
|
|
摄像机使用命令序号存储*/
|
|
|
|
|
int enrecvtime; /* 发送加密命令后接收到应答计时*/
|
|
|
|
|
LONG FirstCmdTimeCnt; /* 串口读取数据起始时间*/
|
|
|
|
|
u_char nextcmd; /* 第二次发送读取气象雨量命令 */
|
|
|
|
|
u_char SameTypeDevIdx; /* 相同类型装置顺序排列序号(从0开始)*/
|
|
|
|
|
u_char uOpenPowerFlag; /* 传感器上电标志(0:不需要打开; 1:需要打开)*/
|
|
|
|
|
int64_t FirstCmdTimeCnt; /* 串口读取数据起始时间*/
|
|
|
|
|
uint8_t nextcmd; /* 第二次发送读取气象雨量命令 */
|
|
|
|
|
uint8_t SameTypeDevIdx; /* 相同类型装置顺序排列序号(从0开始)*/
|
|
|
|
|
uint8_t uOpenPowerFlag; /* 传感器上电标志(0:不需要打开; 1:需要打开)*/
|
|
|
|
|
int recvdatacnt; /* 接收到有效数据*/
|
|
|
|
|
PHOTO_DEF image; /* 临时存储图片数据*/
|
|
|
|
|
AI_DEF aiValue[MAX_DEV_VALUE_NUM]; /* 传感器采样值*/
|
|
|
|
@ -285,17 +278,17 @@ typedef struct
|
|
|
|
|
//串口相关装置所有参数集中定义
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
u_char clcyesampling; /* 正在进行采样(0:没有进行采样;1:正在进行采样;)*/
|
|
|
|
|
u_char camerauseserial; /* 摄像机使用那个串口*/
|
|
|
|
|
DWORD PtzCmdType; /* 云台指令类型*/
|
|
|
|
|
uint8_t clcyesampling; /* 正在进行采样(0:没有进行采样;1:正在进行采样;)*/
|
|
|
|
|
uint8_t camerauseserial; /* 摄像机使用那个串口*/
|
|
|
|
|
uint32_t PtzCmdType; /* 云台指令类型*/
|
|
|
|
|
int usecameradevidx; /* 有像机指令需要执行*/
|
|
|
|
|
/* 执行指令的装置序号(-1:表示没有需要执行的指令;)*/
|
|
|
|
|
int SendStopPtzCmdTimeCnt; /* 发送云台停止指令*/
|
|
|
|
|
u_char serialstatus[MAX_SERIAL_PORT_NUM]; /* 串口是否可以使用状态分别对应串口1、2、3*/
|
|
|
|
|
int SendStopPtzCmdTimeCnt; /* 发送云台停止指令*/
|
|
|
|
|
uint8_t serialstatus[MAX_SERIAL_PORT_NUM]; /* 串口是否可以使用状态分别对应串口1、2、3*/
|
|
|
|
|
SERIAL_DEV_DEF ms_dev[MAX_SERIAL_DEV_NUM]; /* 装置所接传感器数量*/
|
|
|
|
|
int UseingSerialdev[MAX_SERIAL_PORT_NUM]; /* 正在使用串口通讯的装置序号(-1,表示串口空闲)*/
|
|
|
|
|
int curdevidx[MAX_SERIAL_PORT_NUM]; /* 当前正在通讯的装置序号(-1表示没有装置需要通讯)*/
|
|
|
|
|
u_char IsReadWireTem; /* 是否在开始读取测温数据(0:表示没有;1:是)*/
|
|
|
|
|
uint8_t IsReadWireTem; /* 是否在开始读取测温数据(0:表示没有;1:是)*/
|
|
|
|
|
//int proruntime; /* 程序运行时间*/
|
|
|
|
|
int IsSleep; /* 是否使程序休眠(1:不休眠;2:休眠)*/
|
|
|
|
|
int tempsamplingstartime; /* 测温启动距离采样启动时间间隔*/
|
|
|
|
@ -316,16 +309,16 @@ typedef struct
|
|
|
|
|
int sendphotocmdcnt; /* 一次拍照过程中发送拍照指令计数*/
|
|
|
|
|
int photographtime; /* 图片拍摄的时间*/
|
|
|
|
|
int iLastGetPhotoNo; /* 设置串口摄像机参数时暂存拍照命令序号*/
|
|
|
|
|
u_char bImageSize; /* 用于临时存储接收上层命令的图片大小*/
|
|
|
|
|
u_char presetno; /* 用于临时存储接收上层命令的预置点*/
|
|
|
|
|
uint8_t bImageSize; /* 用于临时存储接收上层命令的图片大小*/
|
|
|
|
|
uint8_t presetno; /* 用于临时存储接收上层命令的预置点*/
|
|
|
|
|
char filedir[512]; /* 用于摄像机拍照之后暂时存放的路径*/
|
|
|
|
|
#endif
|
|
|
|
|
u_char errorPhotoNoCnt; /* 串口摄像机拍照时回应错误包号计数(如:召第6包回应第3包)*/
|
|
|
|
|
u_char RephotographCnt; /* 串口摄像机重拍计数(只在读照片数据应答出错时才重拍)*/
|
|
|
|
|
uint8_t errorPhotoNoCnt; /* 串口摄像机拍照时回应错误包号计数(如:召第6包回应第3包)*/
|
|
|
|
|
uint8_t RephotographCnt; /* 串口摄像机重拍计数(只在读照片数据应答出错时才重拍)*/
|
|
|
|
|
} SRDT_DEF;
|
|
|
|
|
|
|
|
|
|
static void PortDataProcess( void );
|
|
|
|
|
static LONG get_msec();
|
|
|
|
|
static int64_t get_msec();
|
|
|
|
|
int serial_port_comm();
|
|
|
|
|
static int weather_comm(SERIAL_PARAM weatherport);
|
|
|
|
|
|
|
|
|
@ -352,12 +345,12 @@ void Gm_CloseSerialPort();
|
|
|
|
|
void DebugLog(int commid, char *szbuf, char flag);
|
|
|
|
|
int SaveLogTofile(int commid, char *szbuf);
|
|
|
|
|
// 功能说明:串口发送数据 返回实际发送的字节数
|
|
|
|
|
int GM_SerialComSend(const unsigned char * cSendBuf, LONG nSendLen, int commid);
|
|
|
|
|
int GM_SerialComSend(const unsigned char * cSendBuf, size_t nSendLen, int commid);
|
|
|
|
|
void Gm_InitSerialComm(SENSOR_PARAM *sensorParam, char *filedir);
|
|
|
|
|
// 启动串口通讯
|
|
|
|
|
void GM_StartSerialComm();
|
|
|
|
|
// 启动使用串口拍照
|
|
|
|
|
void GM_StartSerialCameraPhoto(BYTE channel, int cmdidx);
|
|
|
|
|
int GM_StartSerialCameraPhoto(uint8_t channel, int cmdidx, u_char bImageSize, int phototime, u_char presetno, char *serfile, unsigned int baud, int addr);
|
|
|
|
|
void delete_old_files(const char *path, int days);
|
|
|
|
|
|
|
|
|
|
// 串口轮询通讯定时器
|
|
|
|
@ -373,12 +366,12 @@ int GM_CloseTimer();
|
|
|
|
|
void testComm();
|
|
|
|
|
void Gm_InitSerialComm_Test();
|
|
|
|
|
// 串口接收数据处理
|
|
|
|
|
void SerialDataProcess(int devidx, u_char *buf, int len);
|
|
|
|
|
void SerialDataProcess(int devidx, uint8_t *buf, int len);
|
|
|
|
|
|
|
|
|
|
void CameraRecvData(int commid, u_char *buf, int len);
|
|
|
|
|
void CameraRecvData(SIO_PARAM_SERIAL_DEF *pPortParam, u_char *buf, int len);
|
|
|
|
|
|
|
|
|
|
// 串口摄像机数据处理
|
|
|
|
|
void CameraPhotoPortDataProcess( int port);
|
|
|
|
|
void CameraPhotoPortDataProcess(SIO_PARAM_SERIAL_DEF *curserial);
|
|
|
|
|
|
|
|
|
|
// 发送命令
|
|
|
|
|
void SendCmdFormPollCmdBuf( int port );
|
|
|
|
@ -387,29 +380,29 @@ void SendCmdFormPollCmdBuf( int port );
|
|
|
|
|
void ClearCmdAllFlag(int commid);
|
|
|
|
|
|
|
|
|
|
// 下发串口拍照指令控制
|
|
|
|
|
int FindNextCameraPhotoCommand(int devidx);
|
|
|
|
|
int FindNextCameraPhotoCommand(SIO_PARAM_SERIAL_DEF *pPortParam);
|
|
|
|
|
// 生成 CameraPhoto命令
|
|
|
|
|
void MakeCameraPhotoCommand( int portno, BYTE cmdidx, int OneParam, WORD TwoParam, BYTE Threep, int phototime);
|
|
|
|
|
void MakeCameraPhotoCommand(SIO_PARAM_SERIAL_DEF *pPortParam, uint8_t cmdidx, int OneParam, uint16_t TwoParam, uint8_t Threep, int phototime);
|
|
|
|
|
|
|
|
|
|
// 清除命令缓冲区
|
|
|
|
|
void ClearCmdFormPollCmdBuf(int port);
|
|
|
|
|
|
|
|
|
|
// 准备发送云台指令
|
|
|
|
|
int Gm_CtrlPtzCmd(u_char channel, DWORD ptzcmd);
|
|
|
|
|
int Gm_CtrlPtzCmd(SIO_PARAM_SERIAL_DEF *pPortParam, uint32_t ptzcmd);
|
|
|
|
|
|
|
|
|
|
// 发送转动摄像机云台命令定时器
|
|
|
|
|
int Gm_Camera_Timer();
|
|
|
|
|
|
|
|
|
|
// 生成 PELCO_P 命令 *
|
|
|
|
|
void Gm_SendPelco_pCommand( DWORD cmdtype);
|
|
|
|
|
void Gm_SendPelco_pCommand( uint32_t cmdtype);
|
|
|
|
|
|
|
|
|
|
// 计算Pelco_p校验
|
|
|
|
|
BYTE Gm_Pelco_pXORCheck( BYTE *msg, int len );
|
|
|
|
|
uint8_t Gm_Pelco_pXORCheck( uint8_t *msg, int len );
|
|
|
|
|
// 生成 PELCO_D 命令 *
|
|
|
|
|
void Gm_SendPelco_DCommand( DWORD cmdtype);
|
|
|
|
|
void Gm_SendPelco_DCommand(SIO_PARAM_SERIAL_DEF *pPortParam, uint32_t cmdtype);
|
|
|
|
|
|
|
|
|
|
// 计算Pelco_D校验
|
|
|
|
|
BYTE Gm_Pelco_DCheck( BYTE *msg, int len );
|
|
|
|
|
uint8_t Gm_Pelco_DCheck( uint8_t *msg, int len );
|
|
|
|
|
// 查询传感器电源状态
|
|
|
|
|
char Gm_GetSensorsPowerState(int port);
|
|
|
|
|
|
|
|
|
@ -421,15 +414,15 @@ int FindNextShxyProtocolCommand( int devidx );
|
|
|
|
|
// 倾角命令校验码计算
|
|
|
|
|
unsigned char CalLpc(unsigned char *msg, int len);
|
|
|
|
|
// 读上海欣影传感器协议数据
|
|
|
|
|
void ShxyProtocolRecvData(int commid, u_char *buf, int len);
|
|
|
|
|
void ShxyProtocolRecvData(int commid, uint8_t *buf, int len);
|
|
|
|
|
// 检查检验和是否正确
|
|
|
|
|
int CheckShxyProtocolLpcError( u_char* msg, int len );
|
|
|
|
|
int CheckShxyProtocolLpcError( uint8_t* msg, int len );
|
|
|
|
|
|
|
|
|
|
// 把16进制和10进制ASCII字符串转换成int整数
|
|
|
|
|
int ATOI(char *buf);
|
|
|
|
|
|
|
|
|
|
//生成倾角命令
|
|
|
|
|
void MakeShxyProtocolPollCommand(int portno, BYTE cmdidx);
|
|
|
|
|
void MakeShxyProtocolPollCommand(int portno, uint8_t cmdidx);
|
|
|
|
|
// 上海欣影传感器协议数据处理
|
|
|
|
|
void ShxyProtocolDataProcess( int commid);
|
|
|
|
|
// 控制关闭传感器电源
|
|
|
|
@ -439,8 +432,7 @@ void ShxyProtocolDataProcess( int commid);
|
|
|
|
|
int SaveImageDataTofile(int devno);
|
|
|
|
|
void Collect_sensor_data();
|
|
|
|
|
|
|
|
|
|
void CameraPhotoCmd(int phototime, u_char channel, int cmdidx, u_char bImageSize, u_char presetno);
|
|
|
|
|
|
|
|
|
|
int CameraPhotoCmd(int phototime, u_char channel, int cmdidx, u_char bImageSize, u_char presetno, char *serfile, unsigned int baud, int addr);
|
|
|
|
|
|
|
|
|
|
/* 数据和图片采集数据返回函数 开始*/
|
|
|
|
|
int GetWeatherData(Data_DEF *data, int datano);
|
|
|
|
@ -468,4 +460,26 @@ int GetImage(int devno, IMAGE_DEF *photo);
|
|
|
|
|
// 生成一个随机整数
|
|
|
|
|
int GeneratingRandomNumber();
|
|
|
|
|
|
|
|
|
|
#endif //WEATHERCOMM_H
|
|
|
|
|
void ClearCameraCmdAllFlag(SIO_PARAM_SERIAL_DEF *pPortParam);
|
|
|
|
|
|
|
|
|
|
void ClearCameraCmdFormPollCmdBuf(SIO_PARAM_SERIAL_DEF *pPortParam);
|
|
|
|
|
|
|
|
|
|
int Gm_OpenCameraSerial(SIO_PARAM_SERIAL_DEF *pPortParam, char *serfile, unsigned int baud);
|
|
|
|
|
|
|
|
|
|
int Gm_SetCameraSerialPortParam(int fd, unsigned int baud);
|
|
|
|
|
|
|
|
|
|
int GM_CameraComSend(unsigned char * cSendBuf, size_t nSendLen, int fd);
|
|
|
|
|
|
|
|
|
|
void SendCameraCmdFormPollCmdBuf(SIO_PARAM_SERIAL_DEF *pPortParam);
|
|
|
|
|
|
|
|
|
|
void Gm_FindCameraCommand(SIO_PARAM_SERIAL_DEF *pPortParam);
|
|
|
|
|
|
|
|
|
|
void GM_CameraSerialComRecv(SIO_PARAM_SERIAL_DEF *pPortParam);
|
|
|
|
|
|
|
|
|
|
int GM_IsCloseCamera(SIO_PARAM_SERIAL_DEF *pPortParam);
|
|
|
|
|
|
|
|
|
|
int GM_CameraSerialTimer(SIO_PARAM_SERIAL_DEF *pPortParam);
|
|
|
|
|
|
|
|
|
|
#endif // __SENSOR_PROTOCOL_H__
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|