Appendix E - LRC Calculation

Message data is preceded by an STX and followed by an EOT, ETX and LRC (Longitudinal Redundancy Checksum). The LRC is a 1 byte value calculated from the data, EOT and ETX (STX not included), as follows:

1.	 
2.	BYTE GetLRC(BYTE* pbData, //[in] data buffer including 
3.	                          //termination character (ETB/ETX/EOT)
4.	            int iCount)   //[in] size of data in bytes including
5.	                          //termination character
6.	{
7.	        BYTE chLRC = 0;
8.	        while(iCount > 0)
9.	        {
10.	          chLRC ^= *pbData++;
11.	          iCount--;
12.	          }
13.	        return chLRC;
14.	}