diff --git a/bundles/com.espressif.idf.terminal.connector.serial/src/com/espressif/idf/terminal/connector/serial/connector/SerialPortHandler.java b/bundles/com.espressif.idf.terminal.connector.serial/src/com/espressif/idf/terminal/connector/serial/connector/SerialPortHandler.java
index 9ddba0f2a..83db962a7 100644
--- a/bundles/com.espressif.idf.terminal.connector.serial/src/com/espressif/idf/terminal/connector/serial/connector/SerialPortHandler.java
+++ b/bundles/com.espressif.idf.terminal.connector.serial/src/com/espressif/idf/terminal/connector/serial/connector/SerialPortHandler.java
@@ -16,6 +16,7 @@
import com.espressif.idf.terminal.connector.serial.activator.Activator;
import com.espressif.idf.terminal.connector.serial.server.SocketServerHandler;
import com.espressif.idf.terminal.connector.serial.server.SocketServerMessageHandler;
+import com.espressif.idf.ui.TelemetryViewerObserver;
public class SerialPortHandler
{
@@ -136,11 +137,14 @@ public void run()
int n;
try
{
- while ((n = targetIn.read(buff, 0, buff.length)) >= 0)
+ while ((n = targetIn.read(buff = new byte[256], 0, buff.length)) >= 0)
{
if (n != 0)
{
+ System.out.println((new String(buff).replaceAll("\u0000.*", "")
+ .replaceAll("\u001B\\[[\\d;]*[^\\d;]", "")));
serialConnector.control.getRemoteToTerminalOutputStream().write(buff, 0, n);
+ TelemetryViewerObserver.updateGraphs(buff);
}
}
diff --git a/bundles/com.espressif.idf.ui/META-INF/MANIFEST.MF b/bundles/com.espressif.idf.ui/META-INF/MANIFEST.MF
index 155248c33..db5e50306 100644
--- a/bundles/com.espressif.idf.ui/META-INF/MANIFEST.MF
+++ b/bundles/com.espressif.idf.ui/META-INF/MANIFEST.MF
@@ -54,3 +54,4 @@ Bundle-ClassPath: .,
lib/ini4j-0.5.4.jar,
lib/gson-2.8.7.jar,
lib/commons-compress-1.21.jar
+Import-Package: org.apache.commons.collections4.queue
diff --git a/bundles/com.espressif.idf.ui/plugin.xml b/bundles/com.espressif.idf.ui/plugin.xml
index 645abb94f..93207f3d9 100644
--- a/bundles/com.espressif.idf.ui/plugin.xml
+++ b/bundles/com.espressif.idf.ui/plugin.xml
@@ -395,6 +395,11 @@
+
+
+
+
@@ -534,6 +544,11 @@
id="org.eclipse.ui.commands.toggleState">
+
+
@@ -604,6 +619,14 @@
id="com.espressif.idf.ui.category"
name="%views_category.name">
+
+
@@ -665,6 +688,11 @@
style="toggle"
tooltip="%command.tooltip.2">
+
+
diff --git a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/TelemetryViewer.java b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/TelemetryViewer.java
new file mode 100644
index 000000000..1347a39cd
--- /dev/null
+++ b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/TelemetryViewer.java
@@ -0,0 +1,41 @@
+package com.espressif.idf.ui;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.part.ViewPart;
+
+import com.espressif.idf.ui.dialogs.TelemetryGraph;
+import com.espressif.idf.ui.telemetry.util.DataParser;
+
+public class TelemetryViewer extends ViewPart
+{
+
+ Composite parentComposite;
+
+ public TelemetryViewer()
+ {
+ super();
+ }
+
+ @Override
+ public void createPartControl(Composite parent)
+ {
+
+ parentComposite = parent;
+
+ }
+
+ public void createGraph(int cacheLimit, String graphName, String yAxisName, DataParser dataParser)
+ {
+ TelemetryGraph graph = new TelemetryGraph(parentComposite, cacheLimit, graphName, yAxisName, dataParser);
+ Thread grahThread = new Thread(graph);
+ grahThread.start();
+ }
+
+ @Override
+ public void setFocus()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+}
diff --git a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/TelemetryViewerObserver.java b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/TelemetryViewerObserver.java
new file mode 100644
index 000000000..d8baa4c1a
--- /dev/null
+++ b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/TelemetryViewerObserver.java
@@ -0,0 +1,25 @@
+package com.espressif.idf.ui;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.espressif.idf.ui.dialogs.TelemetryGraph;
+
+public class TelemetryViewerObserver
+{
+ public static List graphs = new ArrayList<>();
+
+ public static void updateGraphs(byte[] data)
+ {
+ for (TelemetryGraph graph : graphs)
+ {
+ graph.update(data);
+ }
+ }
+
+ public static void subcribe(TelemetryGraph subscriber)
+ {
+ graphs.add(subscriber);
+ }
+
+}
diff --git a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/dialogs/Messages.java b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/dialogs/Messages.java
index 47d979b9a..77cbc1a7d 100644
--- a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/dialogs/Messages.java
+++ b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/dialogs/Messages.java
@@ -26,6 +26,23 @@ public class Messages extends NLS
public static String FilterMessage;
public static String HintsYmlNotFoundErrMsg;
+ public static String TelemetryDialog_CacheLimitLbl;
+ public static String TelemetryDialog_ColumnNumberLbl;
+ public static String TelemetryDialog_DataFormatLbl;
+ public static String TelemetryDialog_DefaultAxisY;
+ public static String TelemetryDialog_DefaultCacheLimit;
+ public static String TelemetryDialog_DefaultColumnsText;
+ public static String TelemetryDialog_DefaultGraphName;
+ public static String TelemetryDialog_DefaultSeparator;
+ public static String TelemetryDialog_GraphNameLbl;
+ public static String TelemetryDialog_Message;
+ public static String TelemetryDialog_RegexLbl;
+ public static String TelemetryDialog_SeparatorLbl;
+ public static String TelemetryDialog_ShellText;
+ public static String TelemetryDialog_Title;
+ public static String TelemetryDialog_TotalColumnsLbl;
+ public static String TelemetryDialog_YNameLbl;
+
static
{
// initialize resource bundle
diff --git a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/dialogs/TelemetryDialog.java b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/dialogs/TelemetryDialog.java
new file mode 100644
index 000000000..0ee21e38e
--- /dev/null
+++ b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/dialogs/TelemetryDialog.java
@@ -0,0 +1,280 @@
+package com.espressif.idf.ui.dialogs;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+
+import com.espressif.idf.core.logging.Logger;
+import com.espressif.idf.core.util.StringUtil;
+import com.espressif.idf.ui.TelemetryViewer;
+import com.espressif.idf.ui.telemetry.util.CsvDataParser;
+import com.espressif.idf.ui.telemetry.util.DataParser;
+import com.espressif.idf.ui.telemetry.util.RegexParser;
+
+public class TelemetryDialog extends TitleAreaDialog
+{
+
+ private Text cacheLimitText;
+ private Text graphNameText;
+ private Text yAxisText;
+ private Combo dataFormatCombo;
+ private Label regexLbl;
+ private Text regextText;
+ private Label csvColumnNumberLbl;
+ private Combo csvColumnNumberText;
+ private Label csvTotalColumnsNumberlbl;
+ private Text csvTotalColumnsNumberText;
+ private Label csvSeparatorLbl;
+ private Text csvSeparatorText;
+
+ private static int graphCounter = 0;
+
+ public TelemetryDialog(Shell parentShell)
+ {
+ super(parentShell);
+ setShellStyle(getShellStyle() | SWT.RESIZE | SWT.MAX);
+ }
+
+ @Override
+ public void create()
+ {
+ super.create();
+ setMessage(Messages.TelemetryDialog_Message);
+ setTitle(Messages.TelemetryDialog_Title);
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent)
+ {
+ Composite area = (Composite) super.createDialogArea(parent);
+ createContainer(area);
+ return super.createDialogArea(parent);
+ }
+
+ @Override
+ protected void configureShell(Shell newShell)
+ {
+ super.configureShell(newShell);
+ newShell.setText(Messages.TelemetryDialog_ShellText);
+ }
+
+ private void createContainer(Composite area)
+ {
+ Composite container = new Composite(area, SWT.NONE);
+ container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ GridLayout layout = new GridLayout(6, false);
+ container.setLayout(layout);
+
+ Label cacheLimitLbl = new Label(container, SWT.NONE);
+ cacheLimitLbl.setText(Messages.TelemetryDialog_CacheLimitLbl);
+ cacheLimitText = new Text(container, SWT.BORDER);
+ cacheLimitText.setText(Messages.TelemetryDialog_DefaultCacheLimit);
+
+ Label graphNameLbl = new Label(container, SWT.NONE);
+ graphNameLbl.setText(Messages.TelemetryDialog_GraphNameLbl);
+ graphNameText = new Text(container, SWT.BORDER);
+ graphNameText.setText(Messages.TelemetryDialog_DefaultGraphName);
+
+ Label yAxisLbl = new Label(container, SWT.NONE);
+ yAxisLbl.setText(Messages.TelemetryDialog_YNameLbl);
+ yAxisText = new Text(container, SWT.BORDER);
+ yAxisText.setText(Messages.TelemetryDialog_DefaultAxisY);
+
+ Label dataFormatLbl = new Label(container, SWT.NONE);
+ dataFormatLbl.setText(Messages.TelemetryDialog_DataFormatLbl);
+ dataFormatCombo = new Combo(container, SWT.READ_ONLY);
+ GridData gridData = new GridData();
+ gridData.horizontalSpan = 5;
+ dataFormatCombo.setLayoutData(gridData);
+ String[] items = { "csv", "regex" }; //$NON-NLS-1$ //$NON-NLS-2$
+ dataFormatCombo.setItems(items);
+ dataFormatCombo.addSelectionListener(new SelectionAdapter()
+ {
+ @Override
+ public void widgetSelected(SelectionEvent e)
+ {
+ if (dataFormatCombo.getSelectionIndex() == 0)
+ {
+ disposeRegexWidgets();
+ if (csvColumnNumberLbl == null || csvColumnNumberLbl.isDisposed())
+ {
+ createCsvWidgets(container);
+
+ }
+ }
+
+ if (dataFormatCombo.getSelectionIndex() == 1)
+ {
+ disposeCsvWidgets();
+ if (regexLbl == null || regexLbl.isDisposed())
+ {
+ createRegexWidgets(container);
+ }
+
+ }
+ getShell().layout(true, false);
+ final Point newSize = getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
+ getShell().setSize(newSize);
+ }
+ });
+ }
+
+ private void createRegexWidgets(Composite container)
+ {
+ regexLbl = new Label(container, SWT.NONE);
+ regexLbl.setText(Messages.TelemetryDialog_RegexLbl);
+ regextText = new Text(container, SWT.BORDER);
+ GridData gridData = new GridData();
+ gridData.horizontalSpan = 5;
+ regextText.setLayoutData(gridData);
+ }
+
+ private void createCsvWidgets(Composite container)
+ {
+ csvTotalColumnsNumberlbl = new Label(container, SWT.NONE);
+ csvTotalColumnsNumberlbl.setText(Messages.TelemetryDialog_TotalColumnsLbl);
+ csvTotalColumnsNumberText = new Text(container, SWT.BORDER);
+ csvTotalColumnsNumberText.setText(Messages.TelemetryDialog_DefaultColumnsText);
+ csvTotalColumnsNumberText.addModifyListener(e -> {
+ try
+ {
+ if (Integer.valueOf(csvTotalColumnsNumberText.getText()) > 0)
+ {
+ csvColumnNumberText.setItems(getColumnItems(csvTotalColumnsNumberText.getText()));
+ csvColumnNumberText.select(0);
+ csvColumnNumberText.update();
+ }
+ }
+ catch (NumberFormatException exc)
+ {
+ Logger.log(exc);
+ }
+ });
+
+ csvTotalColumnsNumberText.addVerifyListener(e -> {
+ String currentText = ((Text) e.widget).getText();
+ currentText = currentText.substring(0, e.start) + e.text + currentText.substring(e.end);
+ try
+ {
+ if (Integer.valueOf(currentText) >= 0)
+ {
+ e.doit = true;
+ }
+ else
+ {
+ e.doit = false;
+ }
+
+ }
+ catch (NumberFormatException exc)
+ {
+ if (!e.text.equals(StringUtil.EMPTY))
+ e.doit = false;
+ }
+ });
+
+ csvTotalColumnsNumberText.addSelectionListener(new SelectionAdapter()
+ {
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e)
+ {
+ if (Integer.valueOf(csvColumnNumberText.getText()) > 0)
+ {
+ csvColumnNumberText.setItems(getColumnItems(csvTotalColumnsNumberText.getText()));
+ csvColumnNumberText.select(0);
+ }
+ }
+ });
+
+ csvColumnNumberLbl = new Label(container, SWT.NONE);
+ csvColumnNumberLbl.setText(Messages.TelemetryDialog_ColumnNumberLbl);
+ csvColumnNumberText = new Combo(container, SWT.READ_ONLY);
+ csvColumnNumberText.setItems(getColumnItems(csvTotalColumnsNumberText.getText()));
+ csvColumnNumberText.select(0);
+
+ csvSeparatorLbl = new Label(container, SWT.NONE);
+ csvSeparatorLbl.setText(Messages.TelemetryDialog_SeparatorLbl);
+ csvSeparatorText = new Text(container, SWT.BORDER);
+ csvSeparatorText.setText(Messages.TelemetryDialog_DefaultSeparator);
+ }
+
+ private void disposeWidget(Control widget)
+ {
+ if (widget != null && !widget.isDisposed())
+ {
+ widget.dispose();
+ }
+ }
+
+ private void disposeRegexWidgets()
+ {
+ disposeWidget(regexLbl);
+ disposeWidget(regextText);
+ }
+
+ private void disposeCsvWidgets()
+ {
+ disposeWidget(csvColumnNumberLbl);
+ disposeWidget(csvColumnNumberText);
+ disposeWidget(csvSeparatorLbl);
+ disposeWidget(csvSeparatorText);
+ disposeWidget(csvTotalColumnsNumberlbl);
+ disposeWidget(csvTotalColumnsNumberText);
+ }
+
+ private String[] getColumnItems(String columnQuantity)
+ {
+ int maxValue = Integer.parseInt(columnQuantity);
+ String[] items = new String[maxValue];
+ for (int i = 0; i < maxValue; i++)
+ {
+ items[i] = String.valueOf(i);
+ }
+ return items;
+ }
+
+ @Override
+ protected void buttonPressed(int buttonId)
+ {
+ if (buttonId == IDialogConstants.OK_ID)
+ {
+ try
+ {
+ TelemetryViewer view = (TelemetryViewer) PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+ .getActivePage().showView("com.espressif.idf.ui.telemetry", "graph" + graphCounter, 3); //$NON-NLS-1$ //$NON-NLS-2$
+ graphCounter += 1;
+ int cacheLimit = Integer.parseInt(cacheLimitText.getText());
+ String graphName = graphNameText.getText();
+ String yAxisName = yAxisText.getText();
+
+ cacheLimit = cacheLimit == 0 ? 100 : cacheLimit;
+ graphName = graphName.isBlank() ? Messages.TelemetryDialog_DefaultGraphName : graphName;
+ yAxisName = yAxisName.isBlank() ? Messages.TelemetryDialog_DefaultAxisY : yAxisName;
+ DataParser dataParser = dataFormatCombo.getSelectionIndex() == 0
+ ? new CsvDataParser(Integer.valueOf(csvColumnNumberText.getText()),
+ Integer.valueOf(csvTotalColumnsNumberText.getText()), csvSeparatorText.getText())
+ : new RegexParser(regextText.getText());
+ view.createGraph(cacheLimit, graphName, yAxisName, dataParser);
+ }
+ catch (PartInitException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ super.buttonPressed(buttonId);
+ }
+
+}
diff --git a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/dialogs/TelemetryGraph.java b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/dialogs/TelemetryGraph.java
new file mode 100644
index 000000000..6e549a055
--- /dev/null
+++ b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/dialogs/TelemetryGraph.java
@@ -0,0 +1,117 @@
+package com.espressif.idf.ui.dialogs;
+
+import java.util.List;
+import java.util.Queue;
+import java.util.stream.Stream;
+
+import org.apache.commons.collections4.queue.CircularFifoQueue;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swtchart.Chart;
+import org.eclipse.swtchart.ILineSeries;
+import org.eclipse.swtchart.ISeries;
+import org.eclipse.swtchart.ISeries.SeriesType;
+
+import com.espressif.idf.core.logging.Logger;
+import com.espressif.idf.ui.TelemetryViewerObserver;
+import com.espressif.idf.ui.telemetry.util.DataParser;
+
+public class TelemetryGraph implements Runnable
+{
+ private Queue dataQueue;
+ private Chart chart;
+ private boolean dataAvailable;
+ private String chartTitle;
+ private String yAxisTitle;
+ private DataParser dataParser;
+
+ public TelemetryGraph(Composite parent, int cacheLimit, String chartTitle, String yAxistTitle,
+ DataParser dataParser)
+ {
+ TelemetryViewerObserver.subcribe(this);
+ dataQueue = new CircularFifoQueue<>(cacheLimit);
+ this.chartTitle = chartTitle;
+ this.yAxisTitle = yAxistTitle;
+ this.dataParser = dataParser;
+ createGraph(parent);
+ }
+
+ private void createGraph(Composite parent)
+ {
+ Composite container = new Composite(parent, SWT.NONE);
+ container.setSize(400, 400);
+ container.setLayout(new FillLayout());
+ chart = createChart(container);
+ }
+
+ @Override
+ public synchronized void run()
+ {
+ Display display = Display.getDefault();
+ while (!chart.isDisposed())
+ {
+ if (!dataAvailable)
+ {
+ try
+ {
+ wait();
+ }
+ catch (InterruptedException e)
+ {
+ Logger.log(e);
+ }
+ }
+ display.asyncExec(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ ISeries[] seriesInChart = chart.getSeriesSet().getSeries();
+ for (ISeries series : seriesInChart)
+ {
+ chart.getSeriesSet().deleteSeries(series.getId());
+ }
+ ILineSeries> lineSeries = (ILineSeries>) chart.getSeriesSet().createSeries(SeriesType.LINE,
+ "line series"); //$NON-NLS-1$
+ Double[] ySeries = dataQueue.toArray(new Double[] {});
+ lineSeries.setYSeries(Stream.of(ySeries).mapToDouble(Double::doubleValue).toArray());
+ chart.getAxisSet().adjustRange();
+ chart.redraw();
+ }
+ });
+ dataAvailable = false;
+ notifyAll();
+ }
+ }
+
+ public Chart createChart(Composite parent)
+ {
+
+ // create a chart
+ Chart chart = new Chart(parent, SWT.NONE);
+ // set titles
+ chart.getTitle().setText(chartTitle);
+ chart.getAxisSet().getYAxis(0).getTitle().setText(yAxisTitle);
+ chart.getAxisSet().getXAxis(0).getTitle().setText("Data Points"); //$NON-NLS-1$
+ return chart;
+ }
+
+ public synchronized void update(byte[] buff)
+ {
+ if (!dataAvailable)
+ {
+ List dataDouble = dataParser.parseSerialData(buff);
+ if (dataDouble == null)
+ {
+ return;
+ }
+ dataQueue.addAll(dataDouble);
+ notifyAll();
+ dataAvailable = true;
+ }
+
+ }
+
+}
diff --git a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/dialogs/messages.properties b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/dialogs/messages.properties
index 17885a8c5..272e8f026 100644
--- a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/dialogs/messages.properties
+++ b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/dialogs/messages.properties
@@ -17,4 +17,20 @@ EraseFlashDialog_EraseFlashInProcessMessageTitle=Erase Flash Still in Process
DeleteResourcesWizard_project_deleteConfigurations=Delete all related configurations
HintDetailsTitle=Hint Details
FilterMessage=type filter text
-HintsYmlNotFoundErrMsg={0} is missing. Hints are only supported from esp-idf v5.0 and higher
\ No newline at end of file
+HintsYmlNotFoundErrMsg={0} is missing. Hints are only supported from esp-idf v5.0 and higher
+TelemetryDialog_CacheLimitLbl=Cache limit:
+TelemetryDialog_ColumnNumberLbl=Column number:
+TelemetryDialog_DataFormatLbl=Data format:
+TelemetryDialog_DefaultAxisY=Amplitude
+TelemetryDialog_DefaultCacheLimit=100
+TelemetryDialog_DefaultColumnsText=3
+TelemetryDialog_DefaultGraphName=Line Chart
+TelemetryDialog_DefaultSeparator=,
+TelemetryDialog_GraphNameLbl=Graph name:
+TelemetryDialog_Message=Provide options for a new telemetry graph
+TelemetryDialog_RegexLbl=Regex:
+TelemetryDialog_SeparatorLbl=Separator:
+TelemetryDialog_ShellText=Telemetry Graph Settings
+TelemetryDialog_Title=Telemetry Graph Settings
+TelemetryDialog_TotalColumnsLbl=Total columns:
+TelemetryDialog_YNameLbl=Y axis name:
diff --git a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/handlers/TelemetryHandler.java b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/handlers/TelemetryHandler.java
new file mode 100644
index 000000000..6667babf8
--- /dev/null
+++ b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/handlers/TelemetryHandler.java
@@ -0,0 +1,32 @@
+package com.espressif.idf.ui.handlers;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+import com.espressif.idf.ui.dialogs.TelemetryDialog;
+
+public class TelemetryHandler extends AbstractHandler
+{
+
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException
+ {
+ Display display = Display.getDefault();
+ display.syncExec((new Runnable()
+ {
+ @Override
+ public void run()
+ {
+
+ Shell shell = new Shell(display);
+
+ new TelemetryDialog(shell).open();
+ }
+ }));
+
+ return null;
+ }
+}
diff --git a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/telemetry/util/CsvDataParser.java b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/telemetry/util/CsvDataParser.java
new file mode 100644
index 000000000..6572ed8b8
--- /dev/null
+++ b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/telemetry/util/CsvDataParser.java
@@ -0,0 +1,40 @@
+package com.espressif.idf.ui.telemetry.util;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class CsvDataParser implements DataParser
+{
+
+ private int columnNumber;
+ private int totalColumns;
+ private String separator;
+
+ public CsvDataParser(int columnNumber, int totalColumns, String separator)
+ {
+ this.columnNumber = columnNumber;
+ this.totalColumns = totalColumns;
+ this.separator = separator;
+ }
+
+ @Override
+ public List parseSerialData(byte[] buff)
+ {
+ List resultList = new ArrayList<>();
+ String parsingString = new String(buff).replaceAll("\u0000.*", "").replaceAll("\u001B\\[[\\d;]*[^\\d;]", "");
+ Pattern pattern = Pattern.compile(String.format("(-?\\d+(\\.\\d+)?[%s]){%d}$", separator, totalColumns));
+ for (String compileString : parsingString.split("\n"))
+ {
+ Matcher matcher = pattern.matcher(compileString.strip());
+ while (matcher.find())
+ {
+ resultList.add(Double.valueOf(compileString.split(separator)[columnNumber]));
+ }
+ }
+
+ return resultList;
+ }
+
+}
diff --git a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/telemetry/util/DataParser.java b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/telemetry/util/DataParser.java
new file mode 100644
index 000000000..0d6389fc8
--- /dev/null
+++ b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/telemetry/util/DataParser.java
@@ -0,0 +1,8 @@
+package com.espressif.idf.ui.telemetry.util;
+
+import java.util.List;
+
+public interface DataParser
+{
+ List parseSerialData(byte[] buff);
+}
diff --git a/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/telemetry/util/RegexParser.java b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/telemetry/util/RegexParser.java
new file mode 100644
index 000000000..afe5a85f5
--- /dev/null
+++ b/bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/telemetry/util/RegexParser.java
@@ -0,0 +1,37 @@
+package com.espressif.idf.ui.telemetry.util;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class RegexParser implements DataParser
+{
+
+ private String regex;
+
+ public RegexParser(String regex)
+ {
+ this.regex = regex;
+ }
+
+ @Override
+ public List parseSerialData(byte[] buff)
+ {
+ List resultList = new ArrayList<>();
+ String parsingString = new String(buff).replaceAll("\u0000.*", "").replaceAll("\u001B\\[[\\d;]*[^\\d;]", "");
+ Pattern pattern = Pattern.compile(regex);
+ for (String compileString : parsingString.split("\n"))
+ {
+ Matcher matcher = pattern.matcher(compileString.strip());
+ while (matcher.find())
+ {
+ resultList.add(Double.valueOf(compileString));
+ }
+ }
+
+ return resultList;
+
+ }
+
+}