Beispiel #1
0
        public void CDU_Get_data()
        {
            data_CM0 = new UInt32[data_size];
            data_CM1 = new UInt32[data_size];
            message_counter = 0;
            // Register for replies
            PcapConnection.pcap.addListener(this);

            // issue # of requests (256 words each)
            for (int i = 0; i < CM_address.Length; i++)
            {
                for (uint j = 0; j <= Number_of_Req; j++)
                {
                    // Note that zero, for length, is interpreted as 256
                    DAN_read_array_msg msg = new DAN_read_array_msg((CM_address[i]+(0x400*j)), 0);
                    System.Threading.Thread.Sleep(1);
                    PcapConnection.pcap.sendDanMsg(msg);
                }
            }
        }
Beispiel #2
0
        public void Memory_Get_data(uint Dump_Address, uint Dump_size)
        {
            data = new UInt32[Dump_size];
            
            message_counter = 0;
            Temp_Dump_Address = Dump_Address;
            Number_of_Req = (Dump_size / REQUEST_SIZE_WORDS);

            // Register for replies
            PcapConnection.pcap.addListener(this);

            // issue # of requests (256 words each)
            for (uint j = 0; j <= Number_of_Req; j++)
                {
                    // Note that zero, for length, is interpreted as 256
                    DAN_read_array_msg msg = new DAN_read_array_msg((Dump_Address + (0x400 * j)), 0);
                    System.Threading.Thread.Sleep(1);
                    PcapConnection.pcap.sendDanMsg(msg);
                }
        }
Beispiel #3
0
        private void buttonMemoryWrite_Click(object sender, EventArgs e)
        {
            // User has clicked OK after editing a memory location.
            UInt32 address, value;

            try
            {
                address = (uint)Convert.ToInt32(textBoxMemoryAddr.Text, 16);
            }
            catch (System.FormatException)
            {
                // TabControl selection only needed if this was an OK button handler
                //this.tabControlNodePropertyPages.SelectedIndex = MEM_VIEWER_PAGE;
                this.textBoxMemoryAddr.Focus();
                this.textBoxMemoryAddr.SelectAll();
                MessageBox.Show("Please enter a hexadecimal number", "Invalid Address",
                        MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            try
            {
                value = (uint)Convert.ToInt32(textBoxMemoryValue.Text, 16);
            }
            catch (System.FormatException)
            {
                //this.tabControlNodePropertyPages.SelectedIndex = MEM_VIEWER_PAGE;
                this.textBoxMemoryValue.Focus();
                this.textBoxMemoryValue.SelectAll();
                MessageBox.Show("Please enter a hexadecimal number", "Invalid Address",
                        MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            // Send the write...
            DAN_write_msg wMsg = new DAN_write_msg(address, value);
            PcapConnection.pcap.sendDanMsg(wMsg);

            // ... refresh the display with a new read...
            DAN_read_array_msg msg = new DAN_read_array_msg(address, 64);
            outstandingRequestSeq = msg.seq;
            PcapConnection.pcap.sendDanMsg(msg);

            // and restore button and control state to 'Not Editing'
            handleMemoryViewCancel(sender, e);
        }
Beispiel #4
0
 public void getNextValues()
 {
     for (int i = 0; i < BLOCK_COUNT; i++)
     {
         DAN_read_array_msg msg = new DAN_read_array_msg(blockAddrs[i], blockWordCounts[i]);
         PcapConnection.pcap.sendDanMsg(msg);
     }
 }
Beispiel #5
0
 public void getNextValues_GMAC1()
 {
     for (int i = 0; i < REG_COUNT1; i++)
     {
         DAN_read_array_msg msg = new DAN_read_array_msg(registers1[i], 1);
         PcapConnection.pcap.sendDanMsg(msg);
         DateTime t1 = DateTime.Now;
         Time_GMAC1[i] = t1;
     }
 }
Beispiel #6
0
 public void getNextValues()
 {
     // Responses are handled on another thread
     DAN_read_array_msg msg = new DAN_read_array_msg(CM_address[0], 1);
     PcapConnection.pcap.sendDanMsg(msg);
 }
Beispiel #7
0
         public void refreshData()
         {
             // Register for replies
             PcapConnection.pcap.addListener(this);
             // Mark the array invalid
             dataCollected = 0;
             ChannelGainReadFiles = true;
             // Note that zero, for length, is interpreted as 256
             for (int i = 0; i < CG_ADDRESS_OFFSETS.Length; i++)
             {
                 // Note that zero, for length, is interpreted as 256
                 DAN_read_array_msg msg = new DAN_read_array_msg(baseAddress + CG_ADDRESS_OFFSETS[i], 0);
                 PcapConnection.pcap.sendDanMsg(msg);
             }

         }
Beispiel #8
0
 public void ChannelGainEnableRead()
 {
     PcapConnection.pcap.addListener(this);
     DAN_read_array_msg msg = new DAN_read_array_msg(ChannelGainEnableAddress, 1);
     PcapConnection.pcap.sendDanMsg(msg);
     ChannelGainReadRegister = false;
 }
Beispiel #9
0
 public void refreshData()
 {
     // Register for replies
     PcapConnection.pcap.addListener(this);
     // Mark the array invalid
     dataCollected = 0;
     // issue eight requests (256 words each)
     for (int i = 0; i < ADDRESS_OFFSETS.Length; i++)
     {
         // Note that zero, for length, is interpreted as 256
         DAN_read_array_msg msg = new DAN_read_array_msg(baseAddress + ADDRESS_OFFSETS[i], 0);
         PcapConnection.pcap.sendDanMsg(msg);
     }
 }
Beispiel #10
0
        // TODO: Does not work, does not re-read device list.  
//        public void restart()
//        {
//            stopDevice();
//             
//            devices = SharpPcap.LibPcap.LibPcapLiveDeviceList.Instance;
//        }

        // Intended to be called on the GUI thread; shows a progress dialog as it
        // sends a message and verifies reply.
        // Returns 'true' if success.
        public bool connect()
        {
            bool rv = false;
            if (device == null || targetMAC == null)
            {
                Console.WriteLine("Missing adapter or MAC!");
                return rv;
            }
            try
            {
                device.Open(DeviceMode.Normal, 1500);  // 1.5 sec timeout
                // Set a filter for DAN GUI mgmt type messages
                string myMac = device.MacAddress.ToString();
                myMac = myMac.Insert(10, ":")
                .Insert(8, ":")
                .Insert(6, ":")
                .Insert(4, ":")
                .Insert(2, ":");
                string filter = "ip and ip[0]==21 and not ether src " + myMac;
                device.Filter = filter;

                // Even though this protocol works fine without IP addresses, they
                // are added to the IP packet.  It may help with debugging via Wireshark,
                // and may be needed for other capabilities, such as TFTP. 
                // pcap.sendDanMsg() expects them in ipSrcAddr and ipDestAddr
                string[] parsedDevDescr = parseDeviceDescription(device);
                ipSrcAddr = System.Net.IPAddress.Parse(parsedDevDescr[0]); // IP dotted notation
                ipDestAddr = System.Net.IPAddress.Parse("192.168.1.10"); // default EVB addr
                ethDstAddr = PhysicalAddress.Parse(targetMAC);// "02-DE-AD-BE-EF-03");

                // Send a test message
                {
                    //uint BaseaddressGMAC1 = 0xE577E000;
                    //uint RxBcastFramesRecdOffset = 0x18c;
                    UInt32 PHYbase = 0xe0458000; byte len = 8;
                    //UInt32 PHYdata = 0xd0000000; byte len = 0;
                    uint register = PHYbase; //BaseaddressGMAC1 + RxBcastFramesRecdOffset;
                    //Console.WriteLine("Requesting counter Gmac1.rxBroadcastFramesRecd at {0}", register.ToString("X2"));
                    // TESTING!!
                    //DAN_read_msg msg = new DAN_read_msg(register);
                    DAN_read_array_msg msg = new DAN_read_array_msg(register, len);  // 0 -> 256
                    DAN_gui_msg responseMsg = null;
                    pcap.sendDanMsg(msg);
                    for (int loopCounter = 0; loopCounter < 3; loopCounter++)
                    {  // due to capture filter not filtering out my own packets... repeat
                        SharpPcap.RawCapture rawCapture = pcap.device.GetNextPacket();
                        responseMsg = pcap.parsePacket(rawCapture);
                        if (responseMsg != null)
                        {
                            int msgSize = msg.size == 0 ? 256 : msg.size;
                            Console.WriteLine("Requested {1} 32-bit words at {0}", msg.address.ToString("X8"), msgSize);
                            for (int i = 0; i < msgSize; i += 4)
                            {
                                Console.WriteLine("{0:x8} {1:x8} {2:x8} {3:x8} ", responseMsg.data[i], responseMsg.data[i + 1], responseMsg.data[i + 2], responseMsg.data[i + 3]);
                            }
                            rv = true;

                            break;
                        }
                    }
                    return rv;
                }

            }
            catch (Exception e)
            {
                Console.WriteLine("Error opening device: " + e.Message);
                stopDevice(); // clears property 'device'
                return rv;
            }
        }
Beispiel #11
0
        // Request register contents
        public void getNextValues()
        {
            // Responses are handled on another thread
            DAN_read_array_msg msg = new DAN_read_array_msg(baseAddress, REG_COUNT);
            PcapConnection.pcap.sendDanMsg(msg);

        }