资源描述:
《源代码分析(modbus通讯协议)和通讯原理分析档》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、文件:C:DOCUME-1sir5LOCALS-1TempRar$DI00.984mbrtu.c2008-11-15,7:44:4747/**FreeModbusLibary:AportableModbusimplementationforModbusASCII/RTU.*Copyright(c)2006ChristianWalter*Allrightsreserved.**Redistributionanduseinsourceandbinaiyforms,withorwithout*modi
2、fication,arepermittedprovidedthatthefollowingconditions*aremet:*1.Redistributionsofsourcecodemustretaintheabovecopyright*notice,thislistofconditionsandthefollowingdisclaime匚*2.Redistributionsinbinaryformmustreproducetheabovecopyright*notice,thislistofconditionsandthefol
3、lowingdisclaimerinthe*documentationand/orothermaterialsprovidedwiththedistribution.*3.Thenameoftheauthormaynotbeusedtoendorseorpromoteproducts*derivedfromthissoftwarewithoutspecificpriorwrittenpermission.**THISSOFTWAREISPROVIDEDBYTHEAUTHOR'、ASIS”ANDANYEXPRESSOR*IMPLIEDW
4、ARRANTIES,INCLUDING,BUTNOTLIMITEDTO,THEIMPLIEDWARRANTIES*OFMERCHANTABILITYANDFITNESSFORAPARTICULARPURPOSEAREDISCLAIMED.*INNOEVENTSHALLTHEAUTHORBELIABLEFORANYDIRECT,INDIRECT,*INCIDENTAL,SPECIAL,EXEMPLARY,ORCONSEQUENTIALDAMAGES(INCLUDING,BUT*NOTLIMITEDTO,PROCUREMENTOFSUBS
5、TITUTEGOODSORSERVICES;LOSSOFUSE,*DATA,ORPROFITS;ORBUSINESSINTERRUPTION)HOWEVERCAUSEDANDONANY*THEORYOFLIABILITY,WHETHERINCONTRACT,STRICTLIABILITY,ORTORT*(INCLUDINGNEGLIGENCEOROTHERWISE)ARISINGINANYWAYOUTOFTHEUSEOF*THISSOFTWARE,EVENIFADVISEDOFTHEPOSSIBILITYOFSUCHDAMAGE.**
6、File:$Id:mbrtu.c,v1.182007/09/1210:15:56woltiExp$*//*Systemincludes*/#include"stdlib.h"#include"string.h"/*Platformincludes*/#include"port.h"Modbusincludes*/#include"mb.h"#include"mbrtu.h"#include"mbframe.hu#include"mbcrc.h"#include"mbport.h"/*Defines*/volatileUCHARucRT
7、UBuf[MB_SER_PDU_SIZE_MAX];staticvolatileUCHAR*pucSndBufferCur;#defineMB_SER_PDU_SIZE_MIN4/*!8、-1TempRar$DI00.984mbrtu.c2008-11-15,7:44:4747#defineMB_SER_PDU_ADDR_OFFSer-PDU.*/#defineMB_SER_PDU_PDU_OFF*