Пример #1
0
        private async void NormalWriteButton_Click(object sender, EventArgs e)
        {
            if (_isBusy || _codeplug == null)
            {
                return;
            }
            try
            {
                _isBusy = true;
                NormalStatus.Clear();
                var codeplug = await _codeplug.WriteToRadio((String)NormalComPortComboBox.SelectedValue, new Progress <string>(s => NormalStatus.AppendText(s + Environment.NewLine)));

                NormalStatus.AppendText("Done!");
            }
            finally
            {
                _isBusy = false;
            }

            ////Round Trip Test
            //var sb = new StringBuilder();
            //var x = _codeplug.Serialize();
            //sb.AppendLine($"Original Size: {_codeplug.OriginalBytes.Length:X4} New Size: {x.Length:X4}");

            //for (var i = 0; i < Math.Min(x.Length, _codeplug.OriginalBytes.Length); i++)
            //{
            //    if (_codeplug.OriginalBytes[i] != x[i])
            //    {
            //        sb.AppendLine($"Mismatch {i:X4} Was {_codeplug.OriginalBytes[i]:X2} now {x[i]:X2}");
            //    }
            //}

            //Status.Text = sb.ToString();
        }
Пример #2
0
        private void NormalOpenButton_Click(object sender, EventArgs e)
        {
            if (_isBusy)
            {
                return;
            }

            using OpenFileDialog fileDialog = new OpenFileDialog
                  {
                      Filter           = "bin files (*.bin)|*.bin|All files (*.*)|*.*",
                      InitialDirectory = Application.StartupPath,
                      Title            = "Open Codeplug File"
                  };

            if (fileDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    NormalStatus.Clear();
                    var codeplug = new Codeplug(fileDialog.FileName);

                    if (codeplug != null)
                    {
                        _codeplug = codeplug;
                        UpdateCodeplug();
                        NormalStatus.Text = _codeplug.GetTextDump();
                    }
                }
                catch (Exception ex)
                {
                    NormalStatus.Text = $"Error opening file {fileDialog.FileName}\r\n{ex}";
                }
            }
        }
Пример #3
0
        private async void NormalReadButton_Click(object sender, EventArgs e)
        {
            if (_isBusy)
            {
                return;
            }
            try
            {
                _isBusy = true;
                NormalStatus.Clear();
                _codeplug = null;

                var codeplug = await Codeplug.ReadFromRadio((String)NormalComPortComboBox.SelectedValue, new Progress <string>(s => NormalStatus.AppendText(s + Environment.NewLine)));

                if (codeplug != null)
                {
                    _codeplug = codeplug;
                    UpdateCodeplug();
                    NormalStatus.Text = _codeplug.GetTextDump();
                }
            }
            finally
            {
                _isBusy = false;
            }
        }