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; _firmata = new FirmataService("BrainPad", "b335f01176044984941833c9ce00d3ae", _appVersion.Major, _appVersion.Minor); _board = new BrainPadBoard(_firmata); 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) { _board.Process(); } }
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 = ""; } } } } }