///<summary>
/// 字符串形式的十六进制转换成byte[]
///</summary>
///<param name="str"></param>
///<returns></returns>
private byte[] StringToHex(string str)
{
string[] strs = str.Split('');
byte[] bytes = new byte[strs.Length];
int index = 0;
foreach (string s in strs)
{
int hex = Convert.ToInt32(s, 16);
bytes[index++] = (byte)hex;
}
return bytes;
}
将测试数据包如5e 13 30 30 30 30 30 30 34 34 30 31 0b 20 30 35 30 32 31 31 30 34 35 35 5e 这样的原始数据发送出去
转换后