📄 samsung.c
字号:
/**************************************************************************** * Resource of the protocol switch. * Name: protocol.c * Author: EdgarLiu * Date: 2004/9/6****************************************************************************/#include <stdio.h>#include "protocol.h"#ifndef BASE_ID#define BASE_ID SPECIAL_COMMAND_BASE_ID#endif// samsung 命令 #define ACTION_NUMERIC_KEY BASE_ID#define ACTION_SCAN BASE_ID + 1#define ACTION_PRESET_MOVE BASE_ID + 2#define ACTION_AUTO_PAN BASE_ID + 3#define ACTION_RESET BASE_ID + 4#define ACTION_PRESET_SAVE BASE_ID + 5#define ACTION_PRESET_DELETE BASE_ID + 6struct TDVSSS_command samsung_cmd[] = { {ACTION_SCAN, "scan"}, {ACTION_PRESET_MOVE, "pm"}, {ACTION_AUTO_PAN, "ap"}, {ACTION_RESET, "rs"}, {ACTION_PRESET_SAVE, "ps"}, {ACTION_PRESET_DELETE, "pd"}, {ACTION_NUMERIC_KEY, "nk"}, {0,0}};static unsigned char g_pan_speed_samsung = 0x20;static unsigned char g_tilt_speed_samsung = 0x20;//The implement of samsung protocolstatic unsigned char checksum_lsb(struct TDVSSS_protocol* tp,int start,int end){ int sum = 0,i; for(i = start;i <= end;i++) sum += tp->out[i]; return (unsigned char)sum % 256;}static int samsung_cmd_PanTilt(struct TDVSSS_protocol* tp ){ tp->out[3] = 0x01; switch (tp->user_input.cmd_id) { case ACTION_LEFT: tp->out[4] = 0x00; tp->out[5] = 0x01; break; case ACTION_RIGHT: tp->out[4] = 0x00; tp->out[5] = 0x02; break; case ACTION_UP: tp->out[4] = 0x00; tp->out[5] = 0x04; break; case ACTION_DOWN: tp->out[4] = 0x00; tp->out[5] = 0x08; break; case ACTION_ZOOM_OUT: tp->out[4] = 0x40; tp->out[5] = 0x00; break; case ACTION_ZOOM_IN: tp->out[4] = 0x20; tp->out[5] = 0x00; break; case ACTION_FOCUS_NEAR: tp->out[4] = 0x02; tp->out[5] = 0x00; break; case ACTION_FOCUS_FAR: tp->out[4] = 0x01; tp->out[5] = 0x00; break; case ACTION_IRIS_OPEN: tp->out[4] = 0x08; tp->out[5] = 0x00; break; case ACTION_IRIS_CLOSE: tp->out[4] = 0x10; tp->out[5] = 0x00; break; } tp->out[6] = g_pan_speed_samsung; tp->out[7] = g_tilt_speed_samsung; return SUCCESSFULLY;}static int samsung_cmd_System(struct TDVSSS_protocol* tp ){ tp->out[3] = 0x03; tp->out[5] = 0xff; tp->out[6] = 0xff; tp->out[7] = 0xff; switch (tp->user_input.cmd_id) { case ACTION_STOP: tp->out[4] = 0x1a; tp->out[5] = 0x00; break; case ACTION_NUMERIC_KEY: if(tp->user_input.param1[1] > 0x0a) return INVALID_ARGUMENT; tp->out[4] = tp->user_input.param1[1]; break; case ACTION_SCAN: if(tp->user_input.param1[1] != 0 && tp->user_input.param1[1] != 1) return INVALID_ARGUMENT; tp->out[4] = 0x13; tp->out[5] = tp->user_input.param1[1]; //01H start 00H stop break; case ACTION_PRESET_MOVE: if(tp->user_input.param1[1] > 127) return INVALID_ARGUMENT; tp->out[4] = 0x19; tp->out[5] = tp->user_input.param1[1]; //0 -- 127 break; case ACTION_AUTO_PAN: if(tp->user_input.param1[1] != 0 && tp->user_input.param1[1] != 1) return INVALID_ARGUMENT; tp->out[4] = 0x1a; tp->out[5] = tp->user_input.param1[1]; //01H start 00H stop break; case ACTION_RESET: tp->out[4] = 0x1e; break; case ACTION_PRESET_SAVE: if(tp->user_input.param1[1] > 127) return INVALID_ARGUMENT; tp->out[4] = 0x50; tp->out[5] = tp->user_input.param1[1]; //0 -- 127 break; case ACTION_PRESET_DELETE: if(tp->user_input.param1[1] > 127) return INVALID_ARGUMENT; tp->out[4] = 0x51; tp->out[5] = tp->user_input.param1[1]; //0 -- 127 break; } return SUCCESSFULLY;}int samsung_protocol(struct TDVSSS_protocol* tp ){ int ret; tp->out_len = 9; tp->out[0] = 0xa0; tp->out[1] = tp->address; tp->out[2] = tp->address; switch (tp->user_input.cmd_id) { case ACTION_LEFT: case ACTION_RIGHT: case ACTION_UP: case ACTION_DOWN: case ACTION_ZOOM_OUT: case ACTION_ZOOM_IN: case ACTION_FOCUS_NEAR: case ACTION_FOCUS_FAR: case ACTION_IRIS_OPEN: case ACTION_IRIS_CLOSE: ret = samsung_cmd_PanTilt(tp); break; case ACTION_STOP: case ACTION_NUMERIC_KEY: case ACTION_SCAN: case ACTION_PRESET_MOVE: case ACTION_AUTO_PAN: case ACTION_RESET: case ACTION_PRESET_SAVE: case ACTION_PRESET_DELETE: ret = samsung_cmd_System(tp); break; default: return NO_SUCH_COMMAND; } if(ret == SUCCESSFULLY) tp->out[8] = checksum_lsb(tp,0,7); return ret;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -