예제 #1
0
        public void TestIntelHexEncode()
        {
            var l = new Parser.Line();

            l.Data    = new byte[] { 0x00, 0x0C, 0x01, 0x04, 0xBF, 0x04, 0xD9, 0x04, 0x7F, 0x00, 0x33, 0x01, 0x04, 0x9F, 0x04, 0x81 };
            l.Address = 0x0100;
            l.Type    = Parser.LineType.Data;

            var p   = new Parser();
            var str = p.EncodeLineWithFormat(l, Parser.HexFormat.INTEL_HEX);

            Assert.AreEqual(":10010000000C0104BF04D9047F003301049F048163\r\n", str);
        }
예제 #2
0
        public void TestSrecordEncode()
        {
            var l = new Parser.Line();

            l.Data    = new byte[] { 0x00, 0x0C, 0x01, 0x04, 0xBF, 0x04, 0xD9, 0x04, 0x7F, 0x00, 0x33, 0x01, 0x04, 0x9F, 0x04, 0x81 };
            l.Address = 0x0100;
            l.Type    = Parser.LineType.Data;

            var p   = new Parser();
            var str = p.EncodeLineWithFormat(l, Parser.HexFormat.S_RECORD);

            Assert.AreEqual("S214000100000C0104BF04D9047F003301049F04815E\r\n", str);
        }
예제 #3
0
        public void TestIntelHexRand()
        {
            var rnd = new Random();
            var dat = new byte[0x10];

            rnd.NextBytes(dat);

            var l_src = new Parser.Line();

            l_src.Data    = dat;
            l_src.Address = (rnd.Next() & 0xffff);
            l_src.Type    = Parser.LineType.Data;

            var p     = new Parser();
            var str   = p.EncodeLineWithFormat(l_src, Parser.HexFormat.INTEL_HEX);
            var l_dst = p.DecodeLineWithFormat(str);

            Assert.AreEqual(l_src.Address, l_dst.Address);
            CollectionAssert.AreEqual(l_src.Data, l_dst.Data);
        }