⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 protocol.h

📁 本人写的linux下云台控制程序
💻 H
字号:
/***************************************************************************** * Header file of the protocol.  * Protocol of Terminal Devices in Vedio Security Surveillance Systema(TDVSSS) * Name: protocol.h * Author: EdgarLiu * Date: 2005/9/6 ****************************************************************************/#ifndef _PROTOCOL_H#define _PROTOCOL_Hstruct TDVSSS_protocol;typedef int (*protocol_start_func)(struct TDVSSS_protocol* tp);typedef int (*command_func)(struct TDVSSS_protocol* tp);// define command struct#define SPECIAL_COMMAND_BASE_ID  33struct TDVSSS_command{	int cmd_id;	char* command;	char* format;	command_func cmd_func;	char* help;};struct TDVSSS_entry{	char* protocol;	protocol_start_func  protocol_start;	struct TDVSSS_command* pantilt_cmd;	struct TDVSSS_command* function_cmd;};#define MAX_DEVICE_SIZE 32struct TDVSSS_device{	int type;  //1: /dev/ttyS  2: /dev/i2c	char name[MAX_DEVICE_SIZE];	int baudrate; //默认为9600	int parity; //0 无校验; 1奇校验; 2偶校验; 默认为无校验};#define MAX_USER_INPUT_SIZE  256#define MAX_COMMAND_SIZE  32struct user_command{	char input[MAX_USER_INPUT_SIZE];	unsigned char command[MAX_COMMAND_SIZE];	int cmd_id;	char* param;	unsigned short param1[2]; //param1[0] 0:param1[1] valid ; 1: param1[1] invalid	unsigned short param2[2]; //	command_func cmd_func; };// Protocol of Terminal Devices in Vedio Security Surveillance Systema(TDVSSS)#define MAX_PROTOCOL_SIZE  16#define MAX_OUT_SIZE  256struct TDVSSS_protocol{	//protocol attribute	char protocol[MAX_PROTOCOL_SIZE]; //	protocol_start_func  protocol_start;	struct TDVSSS_command* pantilt_cmd;   //	struct TDVSSS_command* function_cmd;	//device infomation	struct TDVSSS_device device;	int fd;	//static data	unsigned char magic;	unsigned char address;	unsigned char source_addr;	int millisecond;	int transparent;  		//dynamic data	struct user_command user_input;	unsigned char pan_speed;	unsigned char tilt_speed;	int continuous;	int response;	unsigned char out[MAX_OUT_SIZE];	int out_len;};#define IS_BETWEEN(num,min,max)  (((num) >= (min) && (num) <= (max))?1:0)#define SIGBGN  41#define SIGRESP 42extern struct TDVSSS_entry protocol_entry[];struct TDVSSS_protocol* protocol_init(char* protocol,int addr,struct TDVSSS_device* td);int command_loop(struct TDVSSS_protocol* tp);//for httpdint handle_control(char* control);/*命令ID宏定义,范围  1----255,其中:1-----32 : 基本的,通用的命令;33-----255:  各协议特有的功能性命令;*///1-----16  云台,摄像机基本命令  The action that need loop send#define ACTION_LEFT	         1   //云台左#define ACTION_RIGHT	         2   //云台右 #define ACTION_UP	         3   //云台上#define ACTION_DOWN	         4   //云台下#define ACTION_ZOOM_OUT	         5   //放大#define ACTION_ZOOM_IN	         6   //缩小#define ACTION_FOCUS_NEAR        7   //聚焦近#define ACTION_FOCUS_FAR         8   //聚焦远#define ACTION_IRIS_OPEN         9   //光圈开#define ACTION_IRIS_CLOSE        10   //光圈关//17 -------32 云台,摄像机停止命令  #define ACTION_STOP              17   //停止云台命令#define ACTION_STOP_CAMERA       18  //停止摄像机命令/*****************************************************************************///Error Code#define SUCCESSFULLY      0#define NO_SUCH_COMMAND  -1#define PARSE_CMD_ERROR  -2#define INVALID_ARGUMENT  -3#define INVALID_ADDRESS  -4#endif	/*_PORTOCOL_H */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -