使用BCD

时间:2014-09-25 13:27:08

标签: c# byte bytearray offset

我试图从FSUIPC的偏移量中获取字节[]。 FSUIPC在Flight Simulator X中获取和设置信息。 偏移量:

private Offset<byte[]> RadioNav1Set = new Offset<byte[]>(0x311E, 4); //not sure about the 4

文档:

NAV1 standby frequency, 4 digits in BCD format. A frequency of 113.45 is represented by 0x1345. The leading 1 is assumed.

所以我需要在x后面加4位数。我试过这两个,两个都没有运气,价值是115.70,test1的结果是112,而test2 = 5488

byte[] test1 = RadioNav1Set.Value;
            short test2 = BitConverter.ToInt16(RadioNav1Set.Value,0);
            txtSetCourse.Text = Convert.ToString(test1[0] + " " + test2);

test1仅在从.70更改115.70时更改,而test2随机增量更改。

提前致谢!

0 个答案:

没有答案