コード例 #1
0
ファイル: Program.cs プロジェクト: TechJect/DragonFly_SDK
        static void TJDragonfly_PacketReceived(TJPacket packet)
        {
            
            count += 1;

            // Print hexadecimal string representation of the raw packet
            string hex = BitConverter.ToString(packet.RawPacket).Replace("-", "");
            Console.WriteLine("[{0}] Got packet with ID = {1} and Seq# = {2}:\n{3}\n\n", packet.Timestamp, packet.PID, packet.Seq, hex);

            // Create a packet to send to the dragonfly
            byte[] txpacket = new byte[32];

            // Fill packet with data (we will be releasing a command specification in the future)
            txpacket[0] = (byte)(count & 0xff);
            txpacket[1] = (byte)((count >> 8 ) & 0xff);
            txpacket[2] = 0xaa;
            txpacket[3] = 0xbb;
            txpacket[4] = 0xcc;
            txpacket[5] = 0xdd;
            txpacket[6] = 0xee;
            txpacket[7] = 0xff;
            // txpacket[...] = ...;

            // Place packet in TX queue
            TJDragonfly.EnqueueTXPacket(txpacket);
        }
コード例 #2
0
 static byte[] PacketToBinary(TJPacket packet)
 {
     return packet.RawPacket;
 }
コード例 #3
0
 static byte[] PacketToCSV(TJPacket packet)
 {
     return packet.ToCSVBytes();
 }
コード例 #4
0
        /// <summary>
        /// Called every time a packet has been received. Packet is placed in a buffer and progress events are fired
        /// when it is filled.
        /// </summary>
        /// <param name="packet">The received packet</param>
        void TJDragonfly_PacketReceived(TJPacket packet)
        {
            numProcessedPackets += 1;
            numBytesInMemory += packet.RawPacket.Length;
            bufferedPackets.AddLast(packet);

            if (numBytesInMemory > kBufferSize)
            {
                ExportPackets(bufferedPackets, outputStream, packetFormat);
                bufferedPackets.Clear();
                numBytesInMemory = 0;
                OnCaptureProgressChanged(new CaptureProgressEventArgs(numProcessedPackets, maxNumberOfPackets));
            }

            if (numProcessedPackets >= maxNumberOfPackets)
            {
                if (numBytesInMemory > 0)
                {
                    ExportPackets(bufferedPackets, outputStream, packetFormat);
                    OnCaptureProgressChanged(new CaptureProgressEventArgs(numProcessedPackets, maxNumberOfPackets)); 
                }

                StopRecording();
                numProcessedPackets = 0;
            }
            
        }
コード例 #5
0
        private static void ProcessPackets()
        {
            byte[] packetToProcess = null;
            TJPacket dfPacket;

            while (stopMonitoring != true || NewPackets.Count > 0)
            {
                if (NewPackets.TryDequeue(out packetToProcess))
                {
                    dfPacket = new TJPacket(packetToProcess);
                    OnPacketReceived(new PacketReceivedEventArgs(dfPacket));
                }

                // Add a time delay of 1 millisecond per iteration to reduce CPU usage.
                //Thread.Sleep(1);
            }
        }
コード例 #6
0
 public PacketReceivedEventArgs(TJPacket packet)
 {
     this.packet = packet;
 }