rs485通信程序文件.docxVIP

  • 15
  • 0
  • 约3.46千字
  • 约 5页
  • 2021-06-16 发布于内蒙古
  • 举报
#ifndef 485_C #define 485_C #include reg51.h #include string.h #define unsigned char uchar #define unsigned int uint /* 通信命令 */ #define ACTIVE_ 0x01 // 主机询问从机是否存在 #define GETDATA_ 0x02 // 主机发送读设备请求 #define OK_ 0x03 // 从机应答 #define STATUS_ 0x04 // 从机发送设备状态信息 #define MAXSIZE 0x08 // 缓冲区长度 #define ERRLEN 12 // 任何通信帧长度超过 12 则表示出错 uchar dbuf[ MAXSIZE]; // 该缓冲区用于保存设备状态信息 uchar dev; // 该字节用于保存本机设备号 sbit M_DE = P1^0; // 驱动器使能, 1 有效 sbit M_RE = P1^1; // 接收器使能, 0 有效 void get_status(); // 调用该函数获得设备状态信息,函数代码未给出 void send_data(uchar type, uchar len, uchar *buf); // 发送数据帧bit recv_cmd(uchar *t

文档评论(0)

1亿VIP精品文档

相关文档