Пример #1
0
        private async void btnTsbConnect_Click(object sender, RoutedEventArgs e)
        {
            tsb.printCommandInProgress();
            if (btnTsbConnect.Content == "Disconnect")
            {
                setUI(uiSetTo.SerialConnectToTsb);
                await reset();

                btnTsbConnect.Content = "Connect to TSB";
                tsb = new TSB();
                // Initialize the TSB object.  This is necessary to start SerialDeviceWatcher.
                tsb.init(serialPorts, mainDisplayScroll, rtbMainDisplay, theOneParagraph, pbSys, serialBuffer, txbOpenFilePath);
            }
            else
            {
                btnConnect.IsEnabled = false;
                await reset();

                try
                {
                    tsb.hello();
                }
                catch (Exception ex)
                {
                    //await serialPorts.disposeStream();
                    Debug.WriteLine(ex.Message);
                }
            }
        }
Пример #2
0
        private async void btnReset_Click(object sender, RoutedEventArgs e)
        {
            tsb = new TSB();
            // Initialize the TSB object.  This is necessary to start SerialDeviceWatcher.
            tsb.init(serialPorts, mainDisplayScroll, rtbMainDisplay, theOneParagraph, pbSys, serialBuffer, txbOpenFilePath);

            await reset();

            tsbStatusUpdate(TSB.statuses.bootloaderDisconnected, null);
        }
Пример #3
0
        public MainPage()
        {
            this.InitializeComponent();

            // Add version information to main view.
            string appVersion = string.Format("Version: {0}.{1}.{2}.{3}",
                                              Package.Current.Id.Version.Major,
                                              Package.Current.Id.Version.Minor,
                                              Package.Current.Id.Version.Build,
                                              Package.Current.Id.Version.Revision);

            ApplicationView appView = ApplicationView.GetForCurrentView();

            appView.Title = "Lumi " + appVersion;

            // Setup a thread dispatcher, used to set thread during IO callbacks.
            dispatcher = CoreWindow.GetForCurrentThread().Dispatcher;

            // Add the callback handlers for serialPortsExtended isntance
            serialPorts.Callback += new serialPortsExtended.CallBackEventHandler(serialPortCallback);
            blue.Callback        += new blue.CallBackEventHandler(blueCallback);

            // Until other thread reports COM port discovered
            btnConnect.IsEnabled      = false;
            btnTsbConnect.IsEnabled   = false;
            pvtPortSettings.IsEnabled = false;
            tabTSB.IsEnabled          = false;

            // Let the user know to wait while device thread returns.
            clearDisplay();
            appendLine("Please wait while COM ports load...", Colors.White);

            // Default view to serial devices.
            tsb.setDevice(TSB.device.serial);
            tsb.populateResetPinCmbBox(cmbResetPin);

            // Have the serialPortsExtended object populate the combo boxes.
            serialPorts.populateComboBoxesWithPortSettings(cmbBaud, cmbDataBits, cmbStopBits, cmbParity, cmbHandshaking);
            serialPorts.init(theOneParagraph);

            // Initialize the TSB object.  This is necessary to start SerialDeviceWatcher.
            tsb.init(serialPorts, mainDisplayScroll, rtbMainDisplay, theOneParagraph, pbSys, serialBuffer, txbOpenFilePath);

            // Delegate callback for TSB updates.
            tsb.TsbUpdatedCommand += new TSB.TsbUpdateCommand(tsbStatusUpdate);

            // Get BluetoothLE up and going.
            blue.init();

            serialBuffer.RXbufferUpdated += new SerialBuffer.CallBackEventHandler(RXbufferUpdated);
            serialBuffer.TXbufferUpdated += new SerialBuffer.CallBackEventHandler(TXbufferUpdated);
        }