Ejemplo n.º 1
0
        public async Task SetConnectionSettings(DeviceConnection.ConnectionSettings connectionSettings)
        {
            await ftDevice.SetBaudRateAsync(connectionSettings.BaudRate);

            await ftDevice.SetDataCharacteristicsAsync(GetWordLength(connectionSettings.DataBits), GetStopBits(connectionSettings.StopBits), GetParity(connectionSettings.Parity));

            await ftDevice.SetFlowControlAsync(GetFlowControl(connectionSettings.Handshake), connectionSettings.XOn, connectionSettings.XOff);
        }
Ejemplo n.º 2
0
        private async Task SetUARTSettings(IFTDevice ftDevice)
        {
            UInt32 baudRate = 3000000;
            // Get the baud rate from the combo box.

            /*await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
             * {
             *  ComboBoxItem br = (ComboBoxItem)cbBaudRate.SelectedItem;
             *  baudRate = Convert.ToUInt32(br.Content);
             * });*/

            /*await MainPage.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
             * {
             *  ComboBoxItem br = (ComboBoxItem)cbBaudRate.SelectedItem;
             *  baudRate = Convert.ToUInt32(br.Content);
             * });*/

            await ftDevice.SetBaudRateAsync(baudRate);

            await ftDevice.SetFlowControlAsync(FLOW_CONTROL.RTS_CTS, 0x00, 0x00);

            await ftDevice.SetDataCharacteristicsAsync(WORD_LENGTH.BITS_8, STOP_BITS.BITS_1, PARITY.NONE);
        }
Ejemplo n.º 3
0
        public async Task InitializeSettings(ConnectionSettings connectionSettings)
        {
            WriteToLog("Initializing connection.");

            try
            {
                await device.SetBaudRateAsync(connectionSettings.BaudRate);

                await device.SetDataCharacteristicsAsync(connectionSettings.WordLength, connectionSettings.StopBits, connectionSettings.Parity);

                await device.SetFlowControlAsync(connectionSettings.FlowControl, connectionSettings.XOn, connectionSettings.XOff);

                WriteToLog("Connection settings succesfully applied: {0}.", connectionSettings);
            }
            catch (Exception ex)
            {
                WriteToLog("Unable to apply connection settings, communication may not function properly. Exception={0}.", ex.Message);
            }

            State = ConnectionState.Ready;

            StartReadingData();
            WriteToLog("Connection ready.");
        }