Svccrccalc() - VeriFone MX800 series Programmer's Manual

Hide thumbs Also See for MX800 series:
Table of Contents

Advertisement

S
F
ERVICE
UNCTIONS

svcCrcCalc()

svcCrcCalc()
144
M
X
800 S
P
ERIES
ROGRAMMERS
Prototype
checksum = svcCrcCalc(type, buffer, size)
int checksum, type, size;
char*buffer;
Parameters
This routine returns the cyclic redundancy check for a string contained in buffer
of a length specified by size. Each type is now specified by referring to a
standard CRC description model which can be found by searching the Internet for
"A Painless Guide to CRC Error Detection Algorithms" (August 1993) by Ross N.
Williams.
The model has the following description parameters: width (of CRC/LRC in bits),
poly(nomial), (init)ialization value generally 0 or -1, refin (whether each input byte
is reflected about its center before being applied to the algorithm), refot (whether
the calculated CRC gets reflected about its center), xorot (the value generally 0 or
-1 that gets exclusive-ored to the final result before being returned to the caller,
check (the CRC/LRC produced by applying this algorithm to the 9-character ascii
string "0123456789".
The type parameter specifies what type of calculation is to be employed:
0
Longitudinal Redundancy Check. This is simply the exclusive OR'ing of all
bytes in the string. The result of the LRC will be stored in the lower byte. The
upper byte will be set to zero.
Model: width=8,poly=0x01,init=0,refin=0,refot=0,xorot=0,check=0x31.
1
Cyclic Redundancy Check, based on the standard CRC16 polynomial,
X^16+X^15+X^2+1. Bits are read least-significant-bit first, as is traditional in
hardware implementations. The CRC1 value is returned in the low byte and
the CRC2 value is returned in the high byte.
Model: width=16,poly=0xA001,init=0,refin=0,refot=0,xorot=0,check=0xA47b
2
CRC16, most-significant-bit first, as is often used in software implementations.
The CRC1 value is returned in the high byte and the CRC2 value is returned in
the low byte.
Model: width=16,poly=0x8005,init=0,refin=0,refot=0,xorot=0,check=0xFEE8
3
CCITT polynomial, X^16+X^12+X^5+1, lsb-first
Model: width=16,poly=0x8408,init=-1,refin=0,refot=0,xorot=0,check=0x0520
4
CCITT, msb-first
Model: width=16,poly=0x1021,init=-1,refin=0,refot=0,xorot=0,check=0x29B1
G
UIDE

Advertisement

Table of Contents
loading

Table of Contents