《MODBUS通讯+C语言源代码》由会员分享,可在线阅读,更多相关《MODBUS通讯+C语言源代码(36页珍藏版)》请在金锄头文库上搜索。
1、/*/ /*函数名称: strmcpy() *输入参数: 共 个参数; *输出参数: 共 个参数; *返回值: *需储存的参数: 共 个参数; *功能介绍: (1)字符数组拷贝; *修改日志: *2006-3-6 17:07 Ver. 1.00 开始编写; 完成; /* */ /*/ void strmcpy(unsigned char dest, unsigned char src, int count) int i; for(i = 0; i count; i +) desti = srci; desti = 0; /*/ /*/ /*函数名称: bitmcpy() *输入参数: 共 个参
2、数; *输出参数: 共 个参数; *返回值: *需储存的参数: 共 个参数; *功能介绍: (1)开关量数组拷贝; *修改日志: *2006-3-7 14:59 Ver. 1.00 开始编写; 完成; /* */ /*/ void bitmcpy(int dest, int src, int count) int i; for(i = 0; i count; i +) desti = srci; /*/ /*/ /*函数名称: strmcmp() *输入参数: 共 个参数; *输出参数: 共 个参数; *返回值: *需储存的参数: 共 个参数; *功能介绍: (1)字符数组比较;相同则返回0,
3、不相同则返回1; *修改日志: *2006-3-6 17:41 Ver. 1.00 开始编写; 完成; /* */ /*/ int strmcmp(unsigned char str1, unsigned char str2, int count) int i; for(i = 0; i count; i +) if(str1i != str2i) return 1; return 0; /*/ /*/ /*函数名称: Datamcmp() *输入参数: 共 个参数; *输出参数: 共 个参数; *返回值: *需储存的参数: 共 个参数; *功能介绍: (1)浮点数组比较;相同则返回0,不相同
4、则返回1; *修改日志: *2006-3-6 18:05 Ver. 1.00 开始编写; 完成; *2006-3-9 13:52 加了一层括号,以前是错误的 if(!(data1i - data2i -0.0001) /* */ /*/ int Datamcmp(float data1, float data2, int count) int i; for(i = 0; i count; i +) if(!(data1i - data2i -0.0001) return 1; return 0; /*/ /*/ /*函数名称: Bitmcmp() *输入参数: 共 个参数; *输出参数: 共
5、个参数; *返回值: *需储存的参数: 共 个参数; *功能介绍: (1)开关量数组比较;相同则返回0,不相同则返回1; *修改日志: *2006-3-6 18:10 Ver. 1.00 开始编写; 完成; /* */ /*/ int Bitmcmp(int data1, int data2, int count) int i; for(i = 0; i count; i +) if(data1i != data2i) return 1; return 0; /*/ /*/ /*函数名称: GetCRC16() *输入参数: 共 个参数; *输出参数: 共 个参数; *返回值: *需储存的参数: 共 个参数; *功能介绍: (1)CRC16校验; 返回校验码; *修改日志: *2005-11-28 16:40 Ver. 1.00 开始编写; 完成; /* */ /*/ unsigned short GetCRC16(unsigned char *puchMsg, unsigned short usDataLen) /* CRC 高位字节值表 */ unsigned char auchCRCH