Example #1
0
        private void Button_Click_3(object sender, RoutedEventArgs e)
        {
            //打包协议到result;
            byte[] result = null;
            ProtocolConstant.USB_DOG_CONTENT = new byte[] { 0x0A, 0x0B, 0x0C };
            new MakerUSBDogFrame().PackData(ref result, new byte[] { 0xFF }, ProtocolConstant.USB_DOG_CONTENT);
            string a = ProtocolUtil.BytesToString(result);

            MessageBox.Show(a);

            //解析这个协议
            object rr = null;

            new ParserUSBDogFrame().Parser(ref rr, result);
            string b = ProtocolUtil.BytesToString((byte[])rr);

            //解析出的数据体
            MessageBox.Show(b);
            //是否和发送的数据体相等
            MessageBox.Show(ProtocolUtil.ArrayEqual((byte[])rr, ProtocolConstant.USB_DOG_CONTENT).ToString());
        }