📄 com.h.bak
字号:
/****************************************************************************/
/* */
/* Copyright (c) 2005, 老树工作室 */
/* All rights reserved. */
/* */
/* http://www.saintone.net Email:hxm0902@163.com */
/* QQ:112431149 Tel:010-62966630 */
/* */
/****************************************************************************/
/****************************************************************************/
/* 文件名:com.h */
/* 版 本:Version 1.0 */
/* 描 述:串口通信代码的头文件,该文件包括通信协议数据位的定义; */
/* 定时器ID及定时时长的定义;串口缓冲区及系统消息变量的定义 */
/* 作 者:spot */
/* */
/* 数据结构: */
/* */
/* 历史记录: */
/* spot 2005-07-10 Creat Inital version. (Version 1.0) */
/****************************************************************************/
#ifndef COM_H
#define COM_H
#include "../includes/types.h"
#define SYN 0x16 /* 通讯同步位*/
#define STX 0x02 /* 通讯起始位*/
#define ETX 0x03 /* 通讯结束位*/
#define ACK 0x06
#define NAK 0x15
#define MSG_TIMER 1 /* 系统定时器 */
#define MSG_ACK 2 /* 正确应答信息 */
#define MSG_NAK 3 /* 错误应答信息 */
#define MSG_GET_LIMIT 4 /* 请求当前报警阈值 */
#define MSG_WRITE_DATE 5 /* 修改当前时间信息 */
#define MSG_READ_DATE 6 /* 读取当前时间信息 */
#define MSG_CUR_DATA 7 /* 请求当前数据 */
#define MSG_WATCHDOG 8 /* 请求看门狗信息 */
#define MSG_ALARM_STATE 9 /* 请求报警情况 */
#define MSG_GET_ADDRESS 10 /* 请求设备地址 */
#define MAX_MSGNUM 6 /* 最大消息数 */
#define MAX_TNUM 3 /* 最大定时器数目 */
#define MAX_RINTL 16 /* 串口接收缓冲 */
#define MAX_COMMAND_LEN 16 /* 串口接受命令长度 */
#define WD_TIMER_LEN 20 /* 喂狗定时器时长1秒 */
#define T_WATCHDOG 1 /* 喂狗定时器ID */
#define QUERY_TIMER_LEN 100 /* 查询定时器时长 5秒 */
#define T_SAMPLE 2 /* 采样湿度定时器ID */
#define LUMIN_TIMER_LEN 50 /* 采样光强定时时长2.5秒*/
#define T_LUMIN 3 /* 采样光强定时器ID */
/* 定义报警阈值结构类型 */
typedef struct {
u_char temp_uthreshold; /* 超低温度 */
u_char temp_othreshold; /* 超高温度 */
u_char humid_uthreshold; /* 超低湿度 */
u_char humid_othreshold; /* 超高湿度 */
u_char lumin_uthreshold; /* 超低光强 */
u_char lumin_othreshold; /* 超高光强 */
} ALARM_DATA_INFO;
/* 系统消息进入栈首 */
void msg_first_push(u_char type, u_char value);
/* 系统消息进入栈尾 */
void msg_last_push(u_char type, u_char value);
/* 该子程序可根据需要修改 搜索系统消息 */
void message_loop(void);
/* 主消息处理子程序 */
void main_message_process(void);
/* 设置定时 */
void set_timer(u_int time_len, u_char type, u_char id);
/* 清定时器 */
void clear_timer(u_char id);
/* 系统上电初始化 */
void system_init(void);
/* 串行接收处理 */
void com_command_receive(void);
/* 串口发送一个字节 */
void com_send_command(u_char push_byte);
/* 串口发送命令 */
void send_command(u_char command);
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -