Hello everyone, i am writing GUI for this microcontroller (nordicsemi.com/products/nrf52811), using J_Link EDU (segger.com/products/debug-probes/j-link/models/j-link-edu/).
No message is displayed when JLink.exe starts and nothing happens when the "ReadMemory" button is pressed. But when you enter the command "exit" (exit from JLink.exe) all the information appears. How can you fix this and why is it happening?
Display All
No message is displayed when JLink.exe starts and nothing happens when the "ReadMemory" button is pressed. But when you enter the command "exit" (exit from JLink.exe) all the information appears. How can you fix this and why is it happening?
C Source Code
- 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 += CmdProcess_OutputDataReceived;
- jLinkProcess.ErrorDataReceived += CmdProcess_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 CmdProcess_ErrorDataReceived(object sender, DataReceivedEventArgs e)
- {
- Dispatcher.Invoke(() =>
- {
- TextBox2.Text += e.Data + "\r\n";
- TextBox2.ScrollToEnd();
- });
- }
- private void CmdProcess_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);
- }
- }