首页 > 解决方案 > 缓冲区 Jlink.exe

问题描述

这样的问题 应用程序(Jlink.exe)写入缓冲区,直到缓冲区满,没有数据显示。如果退出应用程序,缓冲区将刷新到控制台。我怎样才能解决这个问题?如何在不离开应用程序的情况下显示数据 (Jlink.exe)。

public partial class MainWindow : Window
{
    Process jLinkProcess = new Process();
    
    public MainWindow()
    {
        InitializeComponent();
    }

    private void Window_Loaded(object sender, RoutedEventArgs e)
    {
        jLinkProcess.StartInfo = new ProcessStartInfo(@"C:\Program Files\SEGGER\JLink\JLink.exe");
        jLinkProcess.StartInfo.UseShellExecute = false;
        jLinkProcess.StartInfo.RedirectStandardInput = true;
        jLinkProcess.StartInfo.RedirectStandardOutput = true;
        jLinkProcess.StartInfo.RedirectStandardError = true;
        jLinkProcess.StartInfo.CreateNoWindow = true;
        jLinkProcess.OutputDataReceived += jLinkProcess_OutputDataReceived;
        jLinkProcess.ErrorDataReceived += jLinkProcess_ErrorDataReceived;
        jLinkProcess.Start();
        jLinkProcess.BeginOutputReadLine();
        jLinkProcess.BeginErrorReadLine();
        jLinkProcess.StandardInput.WriteLine("connect");
        jLinkProcess.StandardInput.WriteLine("NRF52811_XXAA");
        jLinkProcess.StandardInput.WriteLine("SWD");
        jLinkProcess.StandardInput.WriteLine("4000");
    }

    private void jLinkProcess_ErrorDataReceived(object sender, DataReceivedEventArgs e)
    {
        Dispatcher.Invoke(() =>
        {
            TextBox2.Text += e.Data + "\r\n";
            TextBox2.ScrollToEnd();
        });
    }

    private void jLinkProcess_OutputDataReceived(object sender, DataReceivedEventArgs e)
    {
        Dispatcher.Invoke(() =>
        {
            TextBox2.Text += e.Data + "\r\n";
            TextBox2.ScrollToEnd();
        });
    }

    private void TextBox1_PreviewKeyDown(object sender, KeyEventArgs e)
    {
        if (sender is TextBox textBox && e.Key == Key.Enter)
        {
            jLinkProcess.StandardInput.WriteLine(textBox.Text);
            textBox.Text = string.Empty;
            e.Handled = true;
        }
    }

    private void ReadMemory(object sender, RoutedEventArgs e)
    {
        string mac = "mem 10000060,8";
        jLinkProcess.StandardInput.WriteLine(mac);
    }
}

标签: c#user-interfacemicrocontroller

解决方案


推荐阅读