Example #1
0
        static void LoadRLP()
        {
            // Make sure to enable and unlock RLP before use!
            RLP.Enable();

            // Unlock RLP
            RLP.Unlock(rlpUserId, rlpKey);

            // Load RLP driver
            elfImage = Resources.GetBytes(Resources.BinaryResources.PWMGenerator);
            if (elfImage == null)
            {
                throw new Exception("Failed to load ELF image");
            }

            RLP.LoadELF(elfImage);
            RLP.InitializeBSSRegion(elfImage);
        }
        public static void Main()
        {
            RLP.Enable();
            // Unlock RLP
            RLP.Unlock("[email protected]", new byte[] { 0x60, 0xEE, 0xDB, 0x53, 0x8A, 0x31, 0x71, 0x34, 0xAE, 0xB5, 0x6A, 0x4A, 0xA8, 0x54, 0x10, 0xA4, 0x67, 0x24, 0xFA, 0x0B, 0x8A, 0x4C, 0x8A, 0x78, 0x27, 0x1F, 0xBF, 0x59, 0xC3, 0x21, 0x54, 0x1A });
            Debug.EnableGCMessages(false);

            Debug.GC(true);
            byte[] elf_file = Resources.GetBytes(Resources.BinaryResources.RLP_test);
            RLP.LoadELF(elf_file);

            RLP.InitializeBSSRegion(elf_file);

            rlpInit  = RLP.GetProcedure(elf_file, "Init");
            rlpStop  = RLP.GetProcedure(elf_file, "Stop");
            rlpStart = RLP.GetProcedure(elf_file, "Start");
            elf_file = null;
            Debug.GC(true);

            //sets up all analog pins as reading, and pwm pins as pwms
            for (int i = 0; i < 6; i++)
            {
                new AnalogIn((AnalogIn.Pin)i);
                new PWM((PWM.Pin)i + 1);
            }

            dataPort = new SerialPort("COM2", 57600, System.IO.Ports.Parity.None, 8, StopBits.One);
            dataPort.Open();
            dataPort.DataReceived += new SerialDataReceivedEventHandler(dataPort_DataReceived); //open before attaching the event - due to bug in framework
            //found at http://tinyclr.com/forum/2/4426/

            Thread.Sleep(2000); //this makes it easier to install new stuff if anything crashes

            rlpInit.Invoke();
            Thread.Sleep(Timeout.Infinite);
        }