That is unlikely to be anything like what you want - because the
BitConverter.ToString Method (Byte[]) (System)[
^] mocverts an array of byte values to a string of hex digits, separated by hyphens:
00-01-02-04-08-10-20-40-80
And it's a lot, lot more likely that you destination needs the raw hex values - which you already have inside the byte array.
Try this:
private const byte start = 0x68;
private const byte end = 0x16;
private byte[] Enpack(byte[] data)
{
int packetLength = 1 + data.Length + 1;
byte[] packet = new byte[packetLength];
packet[0] = start;
packet[packetLength - 1] = end;
Array.Copy(data, 0, packet, 1, packetLength - 2);
return packet;
}
And you might want to replace the Default encoding with a specific set: Ascii perhaps, or UTF8 depending on the destination.