local_proxy

This commit is contained in:
rusefillc 2020-10-29 00:04:30 -04:00
parent 1617636132
commit c554989475
2 changed files with 21 additions and 1 deletions

View File

@ -40,7 +40,7 @@ public class TcpIoStream extends AbstractIoStream {
} }
@NotNull @NotNull
public static TcpIoStream open(String port) throws TcpConnector.InvalidTcpPort, IOException { public static TcpIoStream open(String port) throws IOException {
int portPart = TcpConnector.getTcpPort(port); int portPart = TcpConnector.getTcpPort(port);
String hostname = TcpConnector.getHostname(port); String hostname = TcpConnector.getHostname(port);
Socket socket = new Socket(hostname, portPart); Socket socket = new Socket(hostname, portPart);

View File

@ -19,7 +19,9 @@ import com.rusefi.io.ConnectionStateListener;
import com.rusefi.io.ConnectionStatusLogic; import com.rusefi.io.ConnectionStatusLogic;
import com.rusefi.io.IoStream; import com.rusefi.io.IoStream;
import com.rusefi.io.LinkManager; import com.rusefi.io.LinkManager;
import com.rusefi.io.tcp.BinaryProtocolProxy;
import com.rusefi.io.tcp.BinaryProtocolServer; import com.rusefi.io.tcp.BinaryProtocolServer;
import com.rusefi.io.tcp.ServerSocketReference;
import com.rusefi.maintenance.ExecHelper; import com.rusefi.maintenance.ExecHelper;
import com.rusefi.proxy.client.LocalApplicationProxy; import com.rusefi.proxy.client.LocalApplicationProxy;
import com.rusefi.tools.online.Online; import com.rusefi.tools.online.Online;
@ -78,12 +80,30 @@ public class ConsoleTools {
registerTool("lightui", strings -> lightUI(), "Start lightweight GUI for tiny screens"); registerTool("lightui", strings -> lightUI(), "Start lightweight GUI for tiny screens");
registerTool("dfu", DfuTool::run, "Program specified file into ECU via DFU"); registerTool("dfu", DfuTool::run, "Program specified file into ECU via DFU");
registerTool("local_proxy", ConsoleTools::localProxy, "Detect rusEFI ECU and proxy serial <> TCP");
registerTool("detect", ConsoleTools::detect, "Find attached rusEFI"); registerTool("detect", ConsoleTools::detect, "Find attached rusEFI");
registerTool("reboot_ecu", args -> sendCommand(Fields.CMD_REBOOT), "Sends a command to reboot rusEFI controller."); registerTool("reboot_ecu", args -> sendCommand(Fields.CMD_REBOOT), "Sends a command to reboot rusEFI controller.");
registerTool(Fields.CMD_REBOOT_DFU, args -> sendCommand(Fields.CMD_REBOOT_DFU), "Sends a command to switch rusEFI controller into DFU mode."); registerTool(Fields.CMD_REBOOT_DFU, args -> sendCommand(Fields.CMD_REBOOT_DFU), "Sends a command to switch rusEFI controller into DFU mode.");
} }
private static void localProxy(String[] strings) throws IOException {
String autoDetectedPort = autoDetectPort();
if (autoDetectedPort == null) {
System.out.println(RUS_EFI_NOT_DETECTED);
return;
}
IoStream ecuStream = LinkManager.open(autoDetectedPort);
ServerSocketReference serverHolder = BinaryProtocolProxy.createProxy(ecuStream, 29001, new BinaryProtocolProxy.ClientApplicationActivityListener() {
@Override
public void onActivity() {
}
});
}
private static void version(String[] strings) { private static void version(String[] strings) {
// version is printed by already, all we need is to do nothing // version is printed by already, all we need is to do nothing
} }