private static void Transmit(TCPClientStream stream, byte[] txBytes) { short length = (short)(txBytes.Length); byte[] lengthBytes = new byte[] { (byte)(length / 256), (byte)(length % 256) }; byte[] txBytesTCP = Formatting.ConcatArrays(lengthBytes, txBytes); Logger.Log("Sending: [" + Formatting.ConvertToInt16(lengthBytes) + "]" + "[" + Formatting.ByteArrayToHexString(txBytes) + "]"); stream.Write(txBytesTCP); }
private static void Transmit(TCPClientStream stream, byte[] txBytes) { byte chrSTX = 0x02; // Start of Text byte chrETX = 0x03; // End of Text //byte[] LRC; short length = (short)(txBytes.Length + 2); byte[] lengthBytes = new byte[] { (byte)(length / 256), (byte)(length % 256) }; byte[] txBytesTCP = Formatting.ConcatArrays(lengthBytes, new byte[] { chrSTX }, txBytes, new byte[] { chrETX }); Logger.Log("Sending: [" + Formatting.ConvertToInt16(lengthBytes) + "]" + "[" + Formatting.ByteArrayToHexString(new byte[] { chrSTX }) + "]" + "[" + Formatting.ByteArrayToASCIIString(txBytes) + "]" + "[" + Formatting.ByteArrayToHexString(new byte[] { chrETX }) + "]"); stream.Write(txBytesTCP); }