示例#1
0
        public static void Main()
        {
            // Instantiate the main RS485Shield handler
            rs485 = new RS485Shield("COM1", 9600, Parity.None, 8, StopBits.One, Pins.GPIO_PIN_D2);

            // Add a suitable RxEvent Handler Callback
            rs485.initHandlers(new SerialDataReceivedEventHandler(comDataReceived), null);

            // Endless loop. We have nothing to do here!
            while (true)
            {
            }
        }
示例#2
0
        public static void Main()
        {
            // Instantiate the main RS485Shield handler
            rs485 = new RS485Shield("COM1", 9600, Parity.None, 8, StopBits.One, Pins.GPIO_PIN_D2);

            // Add a suitable RxEvent Handler Callback
            rs485.initHandlers(new SerialDataReceivedEventHandler(comDataReceived), null);

            long lastTick = Utility.GetMachineTime().Ticks;

            // Endless loop.
            while (true)
            {
                long curTick = Utility.GetMachineTime().Ticks;
                if ((curTick - lastTick) > timePeriod)
                {
                    // Because I'm the "ping actor", just start a ping-pong game
                    rs485.Write(txBuffer);

                    // repeat each second
                    lastTick = curTick;
                }
            }
        }