public RequestItem(byte[] requestContent, bool withCrc) { _data = new byte[requestContent.Length + 2]; requestContent.CopyTo(_data, 0); byte[] crcTmp = new byte[2]; if (CommProtocol.CalculateCRCHelper(requestContent, requestContent.Length, ref crcTmp)) { _data[requestContent.Length] = crcTmp[0]; _data[requestContent.Length + 1] = crcTmp[1]; } }
public RequestItem(string requestContent, bool withCrc) { //_data = System.Text.Encoding.Default.GetBytes(requestContent); _requestString = requestContent; if (withCrc) { var temp = HexStringToToHexBytes(requestContent); _data = new byte[temp.Length + 2]; temp.CopyTo(_data, 0); byte[] crcTmp = new byte[2]; if (CommProtocol.CalculateCRCHelper(temp, temp.Length, ref crcTmp)) { _data[temp.Length] = crcTmp[0]; _data[temp.Length + 1] = crcTmp[1]; } } else { _data = HexStringToToHexBytes(requestContent); } }