public void makeResMsg(ref __ST_RES_MSG stResMsg, ref byte[] szMsg) { int nDstIndx; int nSrcLen; //byte[] szBuff = new byte[512]; nDstIndx = 0; nSrcLen = sizeof(byte); Buffer.SetByte(szMsg, nDstIndx, (byte)stResMsg.hxSTX); nDstIndx = nSrcLen; nSrcLen = stResMsg.strResMsg.Length; Buffer.BlockCopy(stResMsg.strResMsg, 0, szMsg, nDstIndx, nSrcLen); nDstIndx += nSrcLen; nSrcLen = sizeof(byte); Buffer.SetByte(szMsg, nDstIndx, (byte)stResMsg.hxETX); //if(BitConverter.IsLittleEndian) //Array.Reverse(szMsg); //szMsg = IPAddress.HostToNetworkOrder(szMsg); //szMsg = BitConverter.GetBytes(szMsg); // //szBuff = BitConverter.GetBytes(szMsg); //Console.WriteLine("{0}", Encoding.ASCII.GetString(szMsg)); //Buffer.BlockCopy(stTimeSync.hxSTX, 0, ) }
public void setResMsg(ref __ST_RES_MSG stResMsg, string strResMsg) { stResMsg.hxSTX = 0x02; stResMsg.strResMsg = Encoding.ASCII.GetBytes(strResMsg); //stResMsg.strResMsg = BitConverter.GetBytes(strResMsg); //Buffer.SetByte(stResMsg.strResMsg, strResMsg.Length, (char)"|"); stResMsg.hxETX = 0x03; }