コード例 #1
0
        private UavDataObject DeserializeHeader(BinaryReader stream)
        {
            // Identifies the type of object and creates the proper object for further processing

            stream.ReadInt16(); // length
            UInt32        objId  = stream.ReadUInt32();
            UavDataObject result = ObjectSummary.CreateObject(objId);

            if (result == null)
            {
                // DAVE: add better handling: read length field and skip this packet, instead of stopping with an exception
                throw new Exception(string.Format("Unexpected ID: 0x{0:x8} at {1}", objId, stream.BaseStream.Position));
            }

            result.InstanceId = (result.IsSingleInstance) ? (UInt16)0 : stream.ReadUInt16();

            return(result);
        }
コード例 #2
0
        public UavDataObject GetNextObject(BinaryReader stream)
        {
            while (true)
            {
                UavTalk_MessageType mt = SyncStream(stream);

                switch (mt)
                {
                case UavTalk_MessageType.OBJ:
                    UavDataObject result = DeserializeHeader(stream);
                    DeserializeBody(stream, result);
                    return(result);

                case UavTalk_MessageType.OBJ_REQ:
                case UavTalk_MessageType.ACK:
                case UavTalk_MessageType.NACK:
                case UavTalk_MessageType.OBJ_ACK:
                    Console.WriteLine("Walker: " + mt.ToString());
                    break;
                }
            }
        }
コード例 #3
0
 protected void DeserializeBody(BinaryReader stream, UavDataObject target)
 {
     target.DeserializeBody(stream);
 }
コード例 #4
0
ファイル: Program.cs プロジェクト: VArcht/uavtalk.net
 static void OnSerialTelemetryMessage(UavDataObject obj)
 {
     Console.WriteLine(obj.ToString());
 }
コード例 #5
0
ファイル: UavTalkWalker.cs プロジェクト: VArcht/uavtalk.net
 protected void DeserializeBody(BinaryReader stream, UavDataObject target)
 {
     target.DeserializeBody(stream);
 }