From 9e83b22bb058fa9e6157847decb3a7b172d017df Mon Sep 17 00:00:00 2001 From: rusEfi Date: Wed, 25 Nov 2015 00:01:24 -0500 Subject: [PATCH] auto-sync --- .../rusefi/io/tcp/BinaryProtocolServer.java | 50 +++++++++++++++++++ java_console/ui/src/com/rusefi/Launcher.java | 4 +- 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 java_console/io/src/com/rusefi/io/tcp/BinaryProtocolServer.java diff --git a/java_console/io/src/com/rusefi/io/tcp/BinaryProtocolServer.java b/java_console/io/src/com/rusefi/io/tcp/BinaryProtocolServer.java new file mode 100644 index 0000000000..d93fe0f4f8 --- /dev/null +++ b/java_console/io/src/com/rusefi/io/tcp/BinaryProtocolServer.java @@ -0,0 +1,50 @@ +package com.rusefi.io.tcp; + +import com.rusefi.FileLog; + +import java.io.IOException; +import java.net.ServerSocket; +import java.net.Socket; + +/** + * This class makes rusEfi console a proxy for other tuning software, this way we can have two tools connected via same + * serial port simultaniously + * + * @author Andrey Belomutskiy + * 11/24/15 + */ + +public class BinaryProtocolServer { + private static final int PROXY_PORT = 2390; + + public static void start() { + FileLog.MAIN.logLine("BinaryProtocolServer on " + PROXY_PORT); + Runnable runnable = new Runnable() { + @Override + public void run() { + ServerSocket serverSocket; + try { + serverSocket = new ServerSocket(PROXY_PORT, 1); + + while (true) { + // Wait for a connection + final Socket clientSocket = serverSocket.accept(); + FileLog.MAIN.logLine("Binary protocol proxy port connection"); + new Thread(new Runnable() { + @Override + public void run() { + runProxy(clientSocket); + } + }, "proxy connection").start(); + } + } catch (IOException e) { + } + } + }; + new Thread(runnable, "BinaryProtocolServer").start(); + } + + private static void runProxy(Socket clientSocket) { + + } +} \ No newline at end of file diff --git a/java_console/ui/src/com/rusefi/Launcher.java b/java_console/ui/src/com/rusefi/Launcher.java index fc6e3ea073..ea98a92aed 100644 --- a/java_console/ui/src/com/rusefi/Launcher.java +++ b/java_console/ui/src/com/rusefi/Launcher.java @@ -4,6 +4,7 @@ import com.rusefi.binaryprotocol.BinaryProtocol; import com.rusefi.core.EngineState; import com.rusefi.core.MessagesCentral; import com.rusefi.io.LinkManager; +import com.rusefi.io.tcp.BinaryProtocolServer; import com.rusefi.maintenance.VersionChecker; import com.rusefi.ui.*; import com.rusefi.ui.engine.EngineSnifferPanel; @@ -32,7 +33,7 @@ import static com.rusefi.ui.storage.PersistentConfiguration.getConfig; * @see com.rusefi.StartupFrame */ public class Launcher { - public static final int CONSOLE_VERSION = 20151117; + public static final int CONSOLE_VERSION = 20151124; public static final boolean SHOW_STIMULATOR = false; private static final String TAB_INDEX = "main_tab"; protected static final String PORT_KEY = "port"; @@ -80,6 +81,7 @@ public class Launcher { tabbedPane.add("Log Viewer", new LogViewer(engineSnifferPanel)); ConnectionWatchdog.start(); + BinaryProtocolServer.start(); tabbedPane.addTab("Gauges", new GaugesPanel(getConfig().getRoot().getChild("gauges")).getContent()); tabbedPane.addTab("Engine Sniffer", engineSnifferPanel.getPanel());