command line tune upload
This commit is contained in:
parent
4405ce80a4
commit
76277ee6d8
|
@ -13,12 +13,10 @@ import com.rusefi.config.generated.Fields;
|
||||||
import com.rusefi.core.EngineState;
|
import com.rusefi.core.EngineState;
|
||||||
import com.rusefi.core.ResponseBuffer;
|
import com.rusefi.core.ResponseBuffer;
|
||||||
import com.rusefi.io.*;
|
import com.rusefi.io.*;
|
||||||
import com.rusefi.io.serial.PortHolder;
|
|
||||||
import com.rusefi.io.serial.SerialIoStreamJSerialComm;
|
import com.rusefi.io.serial.SerialIoStreamJSerialComm;
|
||||||
import com.rusefi.maintenance.ExecHelper;
|
import com.rusefi.maintenance.ExecHelper;
|
||||||
import com.rusefi.tools.online.Online;
|
import com.rusefi.tools.online.Online;
|
||||||
import com.rusefi.tune.xml.Msq;
|
import com.rusefi.tune.xml.Msq;
|
||||||
import com.rusefi.ui.OnlineTab;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import javax.xml.bind.JAXBException;
|
import javax.xml.bind.JAXBException;
|
||||||
|
@ -53,6 +51,7 @@ public class ConsoleTools {
|
||||||
|
|
||||||
registerTool("print_auth_token", args -> printAuthToken(), "Print current rusEFI Online authentication token.");
|
registerTool("print_auth_token", args -> printAuthToken(), "Print current rusEFI Online authentication token.");
|
||||||
registerTool(SET_AUTH_TOKEN, ConsoleTools::setAuthToken, "Set rusEFI authentication token.");
|
registerTool(SET_AUTH_TOKEN, ConsoleTools::setAuthToken, "Set rusEFI authentication token.");
|
||||||
|
registerTool("upload_tune", ConsoleTools::uploadTune, "Upload specified tune file using auth token from settings");
|
||||||
|
|
||||||
|
|
||||||
registerTool("detect", ConsoleTools::detect, "Find attached rusEFI");
|
registerTool("detect", ConsoleTools::detect, "Find attached rusEFI");
|
||||||
|
@ -60,6 +59,13 @@ public class ConsoleTools {
|
||||||
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 uploadTune(String[] args) throws IOException {
|
||||||
|
String fileName = args[1];
|
||||||
|
String authToken = getConfig().getRoot().getProperty(Online.AUTH_TOKEN);
|
||||||
|
System.out.println("Trying to upload " + fileName + " using " + authToken);
|
||||||
|
Online.upload(new File(fileName), authToken);
|
||||||
|
}
|
||||||
|
|
||||||
private static void registerTool(String command, ConsoleTool callback, String help) {
|
private static void registerTool(String command, ConsoleTool callback, String help) {
|
||||||
TOOLS.put(command, callback);
|
TOOLS.put(command, callback);
|
||||||
toolsHelp.put(command, help);
|
toolsHelp.put(command, help);
|
||||||
|
@ -101,11 +107,12 @@ public class ConsoleTools {
|
||||||
|
|
||||||
private static void setAuthToken(String[] args) {
|
private static void setAuthToken(String[] args) {
|
||||||
String newToken = args[1];
|
String newToken = args[1];
|
||||||
getConfig().getRoot().setProperty(OnlineTab.AUTH_TOKEN, newToken);
|
System.out.println("Saving auth token " + newToken);
|
||||||
|
getConfig().getRoot().setProperty(Online.AUTH_TOKEN, newToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void printAuthToken() {
|
private static void printAuthToken() {
|
||||||
String authToken = getConfig().getRoot().getProperty(OnlineTab.AUTH_TOKEN);
|
String authToken = getConfig().getRoot().getProperty(Online.AUTH_TOKEN);
|
||||||
if (authToken.trim().isEmpty()) {
|
if (authToken.trim().isEmpty()) {
|
||||||
System.out.println("Auth token not defined. Please use " + SET_AUTH_TOKEN + " command");
|
System.out.println("Auth token not defined. Please use " + SET_AUTH_TOKEN + " command");
|
||||||
System.out.println("\tPlease see https://github.com/rusefi/rusefi/wiki/Online");
|
System.out.println("\tPlease see https://github.com/rusefi/rusefi/wiki/Online");
|
||||||
|
@ -208,7 +215,6 @@ public class ConsoleTools {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void convertBinaryToXml(String[] args) throws IOException, JAXBException {
|
private static void convertBinaryToXml(String[] args) throws IOException, JAXBException {
|
||||||
|
|
||||||
if (args.length < 2) {
|
if (args.length < 2) {
|
||||||
System.err.println("Binary file input expected");
|
System.err.println("Binary file input expected");
|
||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
|
@ -219,7 +225,9 @@ public class ConsoleTools {
|
||||||
|
|
||||||
Msq tune = Msq.toMsq(image);
|
Msq tune = Msq.toMsq(image);
|
||||||
tune.writeXmlFile(Msq.outputXmlFileName);
|
tune.writeXmlFile(Msq.outputXmlFileName);
|
||||||
Online.upload(new File(Msq.outputXmlFileName), "x");
|
String authToken = getConfig().getRoot().getProperty(Online.AUTH_TOKEN);
|
||||||
|
System.out.println("Using " + authToken);
|
||||||
|
Online.upload(new File(Msq.outputXmlFileName), authToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long classBuildTimeMillis() throws URISyntaxException, IllegalStateException, IllegalArgumentException {
|
public static long classBuildTimeMillis() throws URISyntaxException, IllegalStateException, IllegalArgumentException {
|
||||||
|
|
|
@ -13,6 +13,7 @@ import org.apache.http.util.EntityUtils;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
public class Online {
|
public class Online {
|
||||||
|
public static final String AUTH_TOKEN = "auth_token";
|
||||||
private static final String url = "https://rusefi.com/online/upload.php";
|
private static final String url = "https://rusefi.com/online/upload.php";
|
||||||
|
|
||||||
public static void upload(File xmlFile, String authTokenValue) throws IOException {
|
public static void upload(File xmlFile, String authTokenValue) throws IOException {
|
||||||
|
|
|
@ -17,7 +17,6 @@ import java.io.IOException;
|
||||||
import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
|
import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
|
||||||
|
|
||||||
public class OnlineTab {
|
public class OnlineTab {
|
||||||
public static final String AUTH_TOKEN = "auth_token";
|
|
||||||
private static final String TOKEN_WARNING = "Please copy token from your forum profile";
|
private static final String TOKEN_WARNING = "Please copy token from your forum profile";
|
||||||
|
|
||||||
private final JPanel content = new JPanel(new VerticalFlowLayout());
|
private final JPanel content = new JPanel(new VerticalFlowLayout());
|
||||||
|
@ -26,7 +25,7 @@ public class OnlineTab {
|
||||||
JTextField textField = new JTextField();
|
JTextField textField = new JTextField();
|
||||||
textField.setPreferredSize(new Dimension(200, 24));
|
textField.setPreferredSize(new Dimension(200, 24));
|
||||||
|
|
||||||
String authToken = getConfig().getRoot().getProperty(AUTH_TOKEN);
|
String authToken = getConfig().getRoot().getProperty(Online.AUTH_TOKEN);
|
||||||
if (authToken.trim().isEmpty())
|
if (authToken.trim().isEmpty())
|
||||||
authToken = TOKEN_WARNING;
|
authToken = TOKEN_WARNING;
|
||||||
|
|
||||||
|
@ -40,7 +39,7 @@ public class OnlineTab {
|
||||||
save.addActionListener(new AbstractAction() {
|
save.addActionListener(new AbstractAction() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
getConfig().getRoot().setProperty(AUTH_TOKEN, textField.getText());
|
getConfig().getRoot().setProperty(Online.AUTH_TOKEN, textField.getText());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
content.add(save);
|
content.add(save);
|
||||||
|
|
Loading…
Reference in New Issue