private void BtGetVersion_Click(object sender, EventArgs e)
{
if (!bEanble || bThread) // Eanble =true bThread =false
return; byte[] bSerial = new byte[6];
byte[] bVersion = new byte[1]; if (Public.RmuGetVersion(phCom, bSerial, bVersion, pflag))
{
MessageBox.Show("硬件版本号:" + Public.HexByteToString(bSerial, 6) + "\n" + "软件版本号:v" + Convert.ToString(bVersion[0] >> 4) + "." + Convert.ToString(bVersion[0] & 0x0F));
}
else
MessageBox.Show("读取版本信息失败");
}
public static string HexByteToString(byte[] InPutByte, int ConvertLen)
{
string OutPutStr = "";
try
{
for (int i = 0; i < ConvertLen; i++)
{
OutPutStr += Convert.ToString((InPutByte[i] >> 4), 16);
OutPutStr += Convert.ToString((InPutByte[i] & 0x0F), 16);
}
return OutPutStr;// 真心不懂、这个OutPutStr的输出怎么来的,为什么?麻烦高手给讲解下。越详细越好
}
catch (Exception)
{
return "";
}
}
{
if (!bEanble || bThread) // Eanble =true bThread =false
return; byte[] bSerial = new byte[6];
byte[] bVersion = new byte[1]; if (Public.RmuGetVersion(phCom, bSerial, bVersion, pflag))
{
MessageBox.Show("硬件版本号:" + Public.HexByteToString(bSerial, 6) + "\n" + "软件版本号:v" + Convert.ToString(bVersion[0] >> 4) + "." + Convert.ToString(bVersion[0] & 0x0F));
}
else
MessageBox.Show("读取版本信息失败");
}
public static string HexByteToString(byte[] InPutByte, int ConvertLen)
{
string OutPutStr = "";
try
{
for (int i = 0; i < ConvertLen; i++)
{
OutPutStr += Convert.ToString((InPutByte[i] >> 4), 16);
OutPutStr += Convert.ToString((InPutByte[i] & 0x0F), 16);
}
return OutPutStr;// 真心不懂、这个OutPutStr的输出怎么来的,为什么?麻烦高手给讲解下。越详细越好
}
catch (Exception)
{
return "";
}
}
>>4相当于除以16