From cd7e239dadc44655d721cbffe14e92c384310970 Mon Sep 17 00:00:00 2001 From: dave Date: Wed, 22 Nov 2023 10:39:42 +0000 Subject: [PATCH] #424 stdio serial plugin added --- .../generator/ui/GenerateCodeDialog.java | 11 +++-- xmlPlugins/core-remote/remoteStdio.xml | 44 +++++++++++++++++++ .../core-remote/serialSrc/StdioTransport.cpp | 36 +++++++++++++++ .../core-remote/serialSrc/StdioTransport.h | 39 ++++++++++++++++ xmlPlugins/core-remote/tcmenu-plugin.xml | 3 +- 5 files changed, 128 insertions(+), 5 deletions(-) create mode 100644 xmlPlugins/core-remote/remoteStdio.xml create mode 100644 xmlPlugins/core-remote/serialSrc/StdioTransport.cpp create mode 100644 xmlPlugins/core-remote/serialSrc/StdioTransport.h diff --git a/tcMenuGenerator/src/main/java/com/thecoderscorner/menu/editorui/generator/ui/GenerateCodeDialog.java b/tcMenuGenerator/src/main/java/com/thecoderscorner/menu/editorui/generator/ui/GenerateCodeDialog.java index 4c87dfe5..ff987711 100644 --- a/tcMenuGenerator/src/main/java/com/thecoderscorner/menu/editorui/generator/ui/GenerateCodeDialog.java +++ b/tcMenuGenerator/src/main/java/com/thecoderscorner/menu/editorui/generator/ui/GenerateCodeDialog.java @@ -93,6 +93,7 @@ public class GenerateCodeDialog { private TextField namespaceField; private ToggleButton useModuleButton; private TableView formTable; + private VBox remotesPane; public GenerateCodeDialog(CodePluginManager manager, CurrentProjectEditorUI editorUI, CurrentEditorProject project, CodeGeneratorRunner runner, @@ -160,6 +161,8 @@ public void showCodeGenerator(Stage stage, boolean modal) { centerPane.getChildren().add(titleLbl); List remoteIds = genOptions.getLastRemoteCapabilitiesUuids(); + remotesPane = new VBox(); + centerPane.getChildren().add(remotesPane); if(remoteIds != null && !remoteIds.isEmpty()) { int count = 0; for(var remoteId : remoteIds) { @@ -169,7 +172,7 @@ public void showCodeGenerator(Stage stage, boolean modal) { String pluginId = "remotePlugin" + count; var currentRemote = new UICodePluginItem(manager, itemRemote, CHANGE, this::onRemoteChange, editorUI, allItems, count, pluginId); currentRemote.getStyleClass().add("uiCodeGen"); - centerPane.getChildren().add(currentRemote); + remotesPane.getChildren().add(currentRemote); count++; currentRemotes.add(currentRemote); } @@ -180,7 +183,7 @@ public void showCodeGenerator(Stage stage, boolean modal) { String pluginId = "remotePlugin0"; var currentRemote = new UICodePluginItem(manager, itemRemote, CHANGE, this::onRemoteChange, editorUI, allItems, 0, pluginId); currentRemote.getStyleClass().add("uiCodeGen"); - centerPane.getChildren().add(currentRemote); + remotesPane.getChildren().add(currentRemote); } Button addRemoteCapabilityButton = new Button(MenuEditorApp.getBundle().getString("code.gen.remote.add")); @@ -284,7 +287,7 @@ private void produceAnotherRemoteCapability(ActionEvent actionEvent) { currentRemote.setId("currentRemoteUI-" + currentRemotes.size()); currentRemote.getStyleClass().add("uiCodeGen"); currentRemotes.add(currentRemote); - centerPane.getChildren().add(currentRemote); + remotesPane.getChildren().add(currentRemote); } private Label addTitleLabel(Pane vbox, String text) { @@ -608,7 +611,7 @@ private void onRemoteChange(UICodePluginItem uiPlugin, CodePluginItem item) { if(item == null) { logger.log(INFO, "Remove fired on remote"); currentRemotes.remove(uiPlugin); - centerPane.getChildren().remove(uiPlugin); + remotesPane.getChildren().remove(uiPlugin); changeProperties(); for(int i=0; i + + TrueCpp + + An EmbedControl/API connection using stdio functions such as printf() and gets(). This assumes you have stdio available and configured on your board. + + + serial-connection.jpg + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/xmlPlugins/core-remote/serialSrc/StdioTransport.cpp b/xmlPlugins/core-remote/serialSrc/StdioTransport.cpp new file mode 100644 index 00000000..a54cae0c --- /dev/null +++ b/xmlPlugins/core-remote/serialSrc/StdioTransport.cpp @@ -0,0 +1,36 @@ + +#include "StdioTransport.h" + +int StdioTransport::writeStr(const char *data) { + auto dl = strlen(data); + for(size_t i = 0; i +#include +#include +#include "SCCircularBuffer.h" + +namespace tcremote { + + class StdioTransport : public TagValueTransport { + private: + SCCircularBuffer inputBuffer; + public: + explicit StdioTransport(int readBufferSize) : inputBuffer(readBufferSize), TagValueTransport(TVAL_UNBUFFERED) {} + + void flush() override { stdio_flush(); } + + int writeChar(char data) override; + + int writeStr(const char *data) override; + + uint8_t readByte() override; + + bool readAvailable() override; + + bool available() override { return true; } + + bool connected() override { return true; } + + void close() override; + }; +} + +#ifndef TC_MANUAL_NAMESPACING +using namespace tcremote; +#endif // TC_MANUAL_NAMESPACING + +#endif //STDIO_TRANSPORT_H diff --git a/xmlPlugins/core-remote/tcmenu-plugin.xml b/xmlPlugins/core-remote/tcmenu-plugin.xml index b526adcb..22808a35 100644 --- a/xmlPlugins/core-remote/tcmenu-plugin.xml +++ b/xmlPlugins/core-remote/tcmenu-plugin.xml @@ -21,8 +21,9 @@ remoteSerialESP.xml remoteWifiESP.xml - + remoteMbedEthernet.xml + remoteStdio.xml simhubConnector.xml