The capability of directly generating X.25 Frame Checking Sequence using the GENERATE method of CRC.GENERATOR object is not available in Communications Toolbox 4.4 (R2009b).
However, the X.25 standard can be implemented using the crc.generator object. By default, crc.generator object is a CRC-CCITT generator, which is what X.25 implementation uses. However, X.25 does something extra, which is described in Section 2.2.7.4 of the X.25 documentation:
The FCS field shall be a 16-bit sequence. It shall be the ones complement of the sum (modulo 2) of:
1) the remainder of xk (x15 + x14 + x13 + x12 + x11 + x10 + x9 + x8 + x7 + x6 + x5 + x4 + x3 + x2 + x + 1) divided (modulo 2) by the generator polynomial x16 + x12 + x5 + 1, where k is the number of bits in the frame existing between, but not including, the final bit of the opening flag and the first bit of the FCS, excluding bits (synchronous transmission) or octets (start/stop transmission) inserted for transparency, and bits inserted for transmission timing (i.e. start or stop bits); and
2) the remainder of the division (modulo 2) by the generator polynomial x16 + x12 + x5 + 1 of the product of x16 by the content of the frame, existing between but not including, the final bit of the opening flag and the first bit of the FCS, excluding bits (synchronous transmission) or octets (start/stop transmission) inserted for transparency and bits inserted for transmission timing (i.e. start or stop bits).
As a workaround, the following code implements X.25 standard using crc.generator object:
Address = [1 1 0 0 0 0 0 0];
UA = [1 1 0 0 1 1 1 0];
Input = [Address UA]';
FCS = [1 1 0 0 1 1 0 0 0 0 1 0 0 1 1 0];
k = length(Input);
h = crc.generator;
cw1 = generate(h,[ones(16, 1); zeros(k-16,1)]);
cw2 = generate(h,Input);
Workaround_FCS = not(mod(cw1(end-16+1:end) + cw2(end-16+1:end),2))';
isequal(FCS,Workaround_FCS)
Best Answer