/// <summary> /// 组写时钟芯片信号帧 /// </summary> /// <param name="complementCode">补偿秒信号的码</param> /// <returns></returns> public string GetWriteClockChipFrame(byte complementCode) { List <byte> sendBuffer = new List <byte>(); sendBuffer.AddRange(Microstar.Utility.Hex.FromString("68AAAAAAAAAAAA680409341333999999A330")); sendBuffer.Add(complementCode); byte cs = CSHelper.CalculateCS(sendBuffer.ToArray()); sendBuffer.Add(cs); sendBuffer.Add(0x16); return(Microstar.Utility.Hex.ToString(sendBuffer.ToArray())); }
/// <summary> /// 组补秒信号帧 /// </summary> /// <param name="complementCode">补偿秒信号的码</param> /// <returns></returns> private string GetCompensateClockSignalFrame(byte complementCode) { List <byte> sendBuffer = new List <byte>(); sendBuffer.AddRange(Microstar.Utility.Hex.FromString("68AAAAAAAAAAAA68040A341333999999173A")); sendBuffer.Add(complementCode); byte crc = CRC8Helper.CalculateCRC8((byte)(complementCode - 0x33), 0xFF); crc = (byte)(crc + 0x33); sendBuffer.Add(crc); //CRC8 byte cs = CSHelper.CalculateCS(sendBuffer.ToArray()); sendBuffer.Add(cs); sendBuffer.Add(0x16); return(Microstar.Utility.Hex.ToString(sendBuffer.ToArray())); }
public void CalculateCSTest() { byte cs = CSHelper.CalculateCS(new byte[] { 0x68, 0xFF, 0xFF, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, 0xCC }); Assert.AreEqual(cs, 0x2D); }