private string ToHexString(int nor, int len)
{
byte[] bytes = BitConverter.GetBytes(nor);
string hexString = "";
for (int i = 0; i < bytes.Length; i++)
{
hexString += bytes[i].ToString("X2");
}
if (len == 1)
return hexString.Substring(0, 2);
else if (len == 2)
return hexString.Substring(0, 4);
else if (len == 4)
return hexString;
return hexString;
}