Exemplo n.º 1
0
 public void testGPSimConstruction()
 {
     gpSim uut = null;
     try
     {
         uut = new gpSim(_knownGoodHexFile, _handerForm.Object);
     }
     finally
     {
         if (uut != null)
             uut.Dispose();
     }
 }
Exemplo n.º 2
0
        public void testGPSimLoadsToCorrectType()
        {
            gpSim uut = null;
            try
            {
                uut = new gpSim(_knownGoodHexFile, _handerForm.Object);

                Assert.AreEqual(_knownGoodPICType, uut.chipType);
            }
            finally
            {
                if (uut != null)
                    uut.Dispose();
            }
        }
Exemplo n.º 3
0
        public void testGPSimRunsToPortBreakpoint()
        {
            gpSim uut = null;
            try
            {
                uut = new gpSim(_knownGoodHexFile, _handerForm.Object);

                // Add a breakpoint on PORTB.
                breakpoint brk = new breakpoint(){callback = this.handler,location = "portb"};
                uut.addWriteBreakpoint(brk);

                // and then run the node.
                uut.run();

                 // Now wait for our handler to be called.
                int timeout = 1000;
                while(!handlerCalled)
                {
                    Thread.Sleep(1000);
                    timeout--;

                    if (timeout == 0)
                        throw new TimeoutException();
                }
                _handerForm.Verify(i => i.BeginInvoke(It.IsAny<gpSim.breakpointHandler>(), It.Is<object[]>(x => x == new object[] { uut, brk })), Times.Once());

                // OK, the handler was called. Ace. Ensure that it was set to the
                // correct value.
                Assert.AreEqual(0x01, portState & 0x01);
            }
            finally
            {
                if (uut != null)
                    uut.Dispose();
            }
        }
Exemplo n.º 4
0
 private void handler(gpSim sender, breakpoint hit)
 {
     portState = sender.readMemory("portb");
     handlerCalled = true;
 }
Exemplo n.º 5
0
 private void onPortBChange(gpSim sender, breakpoint hit)
 {
     // OK, a pin has changed in PORTB. We should examine portb and discover if any interesting bits
     // are now set.
     sfrPORTB portb = sender.readMemory<sfrPORTB>(sfrPORTB.name);
     if (portb.hasBit(0))
     {
         // A sync packet is being reported by the debug interface. Fire the appropriate event.
         syncPacket();
     }
 }
Exemplo n.º 6
0
        private void onByteWritten(gpSim sender, breakpoint hit)
        {
            _packet[_packetCount++] = (byte) sender.readMemory( hit.location );

            if (_packetCount > networkPacket.lengthInBytes)
                onSendPacket(new networkPacket(_packet));
        }
Exemplo n.º 7
0
        public simulatedPICNode(int newId, string newName, System.ComponentModel.ISynchronizeInvoke eventHandler, string objectFile)
            : base(newId, newName)
        {
            // Make our new simulator..
            _simulator = new gpSim(objectFile, eventHandler);

            // And add breakpoints on things which are important - rs232 IO, and the debug pins.
            lock (_simulator)
            {
                _simulator.addWriteBreakpoint(sfrTXREG.name, onByteWritten);
                _simulator.addWriteBreakpoint(sfrPORTB.name, onPortBChange);
                _simulator.run();
            }
        }
Exemplo n.º 8
0
 public simulatedPICNode(int newId, string newName, IEnumerable<virtualNodeSensor> newSensors, System.ComponentModel.ISynchronizeInvoke eventHandler, string objectFile)
     : base(newId, newName, newSensors)
 {
     _simulator = new gpSim(objectFile, eventHandler);
 }