private byte[] Crc16ccitt(byte[] bytes){ const ushort poly = 4129; ushort[] table = new ushort[256]; ushort initialValue = 0; ushort temp, a; ushort crc = initialValue; for (int i = 0; i < table.Length; ++i) { temp = 0; a = (ushort)(i << 8); for (int j = 0; j < 8; ++j) { if (((temp ^ a) & 0x8000) != 0) temp = (ushort)((temp << 1) ^ poly); else temp <<= 1; a <<= 1; } table[i] = temp; } for (int i = 0; i < bytes.Length; ++i) { crc = (ushort)((crc << 8) ^ table[((crc >> 8) ^ (0xff & bytes[i]))]); } byte[] _crc = BitConverter.GetBytes(crc); Array.Reverse(_crc); return (_crc);}
public byte[] arrInt1 = new byte[128]; public byte[] arrBool1 = new byte[128]; public byte[] arrBool2 = new byte[128]; public byte[] arrBool3 = new byte[128]; public byte[] arrBool4 = new byte[128]; public byte[] arrString1 = new byte[256]; public byte[] arrString2 = new byte[256]; public byte[] arrBool5 = new byte[128]; public byte[] arrBool6 = new byte[128]; public byte[] arrBool7 = new byte[128]; public byte[] arrCrc = new byte[128];
memStream.Seek( 0, SeekOrigin.Begin );