Пример #1
0
 // This method is run when the mainboard is powered up or reset.
 void ProgramStarted()
 {
     //TODO: Read config values to find out if we have a USB serial adapter and on which port? do we have a serial-capable Bee? Do we have an ethernet port?
     //  Construct the comms channels on that basis.  For now, its hardcoded for serial usb on port 1, and with ethernet
     //TODO: Set name based on a config value
     _firmata = new FirmataService("GHICerbuino", "", 1, 0);
     _board   = new CerbuinoBoard(_firmata, Mainboard);
     _firmata.Open(_board, new UsbSerialCommunicationChannel(usbSerial) /*, new EthernetCommunicationChannel()*/);
 }
Пример #2
0
 public BrainPadBoard(FirmataService firmata)
 {
     _firmata = firmata;
 }
Пример #3
0
        public static void Main()
        {
            _appVersion = typeof(Program).Assembly.GetName().Version;

            DisplayTitlePage();

            ClearStatus();
            BrainPad.Display.DrawFillRect(65, 100, 10, 10, BrainPad.Color.Palette.Black);

            ICommunicationChannel channel = null;

            // 437 : _firmata = new FirmataService("BrainPad", "b335f01176044984941833c9ce00d3ae", _appVersion.Major, _appVersion.Minor);
            // 438 :
            _firmata = new FirmataService("BrainPad", "07e62d24272240d2b4876b199524079c", _appVersion.Major, _appVersion.Minor);
            _board   = new BrainPadBoard(_firmata);

            if (GHI.Processor.DebugInterface.Type == DebugInterface.InterfaceType.Usb)
            {
                GHI.Processor.DebugInterface.Type            = DebugInterface.InterfaceType.Serial;
                GHI.Processor.DebugInterface.ComPort         = "COM1";
                GHI.Processor.DebugInterface.UseInTinyBooter = true;
                GHI.Processor.DebugInterface.Save();
                PowerState.RebootDevice(false);
            }

            try
            {
                var vsp = new Cdc();
                Controller.ActiveDevice = vsp;
                channel = new UsbCommunicationChannel(vsp);
                DisplayStatus("Using USB. Reset to deploy");
            }
            catch
            {
                var port = new SerialPort("COM1", 115200, Parity.None, 8, StopBits.One);
                channel = new SerialCommunicationChannel(port);
                DisplayStatus("Using secondary serial port");
            }

            _firmata.Open(_board, channel);

            while (true)
            {
                try
                {
                    _board.Process();
                }
                catch (GHI.Usb.OperationTimedOutException)
                {
                }
                catch (Exception ex)
                {
                    BrainPad.Display.Clear();
                    BrainPad.Display.DrawString(0, 0, "Exception", BrainPad.Color.Palette.Red);
                    var msg = ex.Message;
                    int iy  = 10;
                    while (msg.Length > 0)
                    {
                        var line = msg;
                        if (line.Length > 27)
                        {
                            line = msg.Substring(0, 27);
                        }
                        BrainPad.Display.DrawString(0, iy, line, BrainPad.Color.Palette.Red);
                        iy += 10;
                        if (msg.Length > 27)
                        {
                            msg = msg.Substring(27);
                        }
                        else
                        {
                            msg = "";
                        }
                    }
                }
            }
        }
Пример #4
0
 public CerbuinoBoard(FirmataService firmata, Mainboard mb)
 {
     _firmata = firmata;
     _mb      = mb;
 }