auto-sync

This commit is contained in:
rusEfi 2015-02-11 08:03:56 -06:00
parent 0e1867f308
commit a7f4ae9ce8
3 changed files with 36 additions and 13 deletions

View File

@ -23,7 +23,7 @@ import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
* @see WavePanel * @see WavePanel
*/ */
public class Launcher extends FrameHelper { public class Launcher extends FrameHelper {
public static final int CONSOLE_VERSION = 20150209; public static final int CONSOLE_VERSION = 20150211;
public static final boolean SHOW_STIMULATOR = true; public static final boolean SHOW_STIMULATOR = true;
public static final String TAB_INDEX = "main_tab"; public static final String TAB_INDEX = "main_tab";
private final String port; private final String port;

View File

@ -1,6 +1,8 @@
package com.rusefi.maintenance; package com.rusefi.maintenance;
import com.rusefi.ui.FrameHelper; import com.rusefi.ui.FrameHelper;
import com.rusefi.ui.UiUtils;
import com.rusefi.ui.widgets.UpDownImage;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
@ -24,9 +26,16 @@ public class FirmwareFlasher {
"-c \"verify_image " + IMAGE_ELF + "\" " + "-c \"verify_image " + IMAGE_ELF + "\" " +
"-c \"reset run\" " + "-c \"reset run\" " +
"-c shutdown"; "-c shutdown";
public static final String SUCCESS_MESSAGE_TAG = "shutdown command invoked";
private final JButton button = new JButton("wip"); private final JButton button = new JButton("Program Firmware");
private final JTextArea log = new JTextArea(); private final JTextArea log = new JTextArea();
private final JScrollPane messagesScroll = new JScrollPane(log, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED) {
@Override
public Dimension getPreferredSize() {
return new Dimension(400, 400);
}
};
public FirmwareFlasher() { public FirmwareFlasher() {
log.setLineWrap(true); log.setLineWrap(true);
@ -35,19 +44,28 @@ public class FirmwareFlasher {
@Override @Override
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {
FrameHelper f = new FrameHelper(); FrameHelper f = new FrameHelper();
f.showFrame(log, false); f.getFrame().setTitle("rusEfi Firmware Flasher");
f.showFrame(messagesScroll, false);
if (!new File(IMAGE_ELF).exists()) { UiUtils.centerWindow(f.getFrame());
appendMsg(IMAGE_ELF + " not found, cannot proceed !!!"); log.setText(""); // let's remove stuff from previous invocation
return;
}
Thread openOcdThread = new Thread(new Runnable() {
@Override
public void run() {
doFlashFirmware(); doFlashFirmware();
} }
}); });
openOcdThread.setDaemon(true);
openOcdThread.start();
}
});
} }
private void doFlashFirmware() { private void doFlashFirmware() {
if (!new File(IMAGE_ELF).exists()) {
appendMsg(IMAGE_ELF + " not found, cannot proceed !!!");
return;
}
appendMsg("Executing " + OPEN_OCD_COMMAND); appendMsg("Executing " + OPEN_OCD_COMMAND);
StringBuffer output = new StringBuffer(); StringBuffer output = new StringBuffer();
StringBuffer error = new StringBuffer(); StringBuffer error = new StringBuffer();
@ -61,9 +79,12 @@ public class FirmwareFlasher {
} catch (InterruptedException e) { } catch (InterruptedException e) {
appendMsg("WaitError: " + e); appendMsg("WaitError: " + e);
} }
if (error.toString().contains(SUCCESS_MESSAGE_TAG)) {
appendMsg("!!! Looks good!!!");
} else {
appendMsg("!!! FIRMWARE FLASH: DOES NOT LOOK RIGHT !!!"); appendMsg("!!! FIRMWARE FLASH: DOES NOT LOOK RIGHT !!!");
} }
}
/** /**
* This method listens to a data stream from the process, appends messages to UI * This method listens to a data stream from the process, appends messages to UI
@ -77,13 +98,15 @@ public class FirmwareFlasher {
BufferedReader bis = new BufferedReader(new InputStreamReader(stream)); BufferedReader bis = new BufferedReader(new InputStreamReader(stream));
while (isRunning(p)) { while (isRunning(p)) {
String line = bis.readLine(); String line = bis.readLine();
if (line == null)
break;
appendMsg(line); appendMsg(line);
buffer.append(line); buffer.append(line);
} }
} catch (IOException e) { } catch (IOException e) {
appendMsg("Stream " + e); appendMsg("Stream " + e);
} }
appendMsg("<EOS> " + msg); // appendMsg("<EOS> " + msg);
} }
}); });
t.setDaemon(true); t.setDaemon(true);
@ -104,6 +127,7 @@ public class FirmwareFlasher {
@Override @Override
public void run() { public void run() {
log.append(s + "\r\n"); log.append(s + "\r\n");
UpDownImage.trueLayout(log);
} }
}); });
} }

View File

@ -31,7 +31,6 @@ public class RecentCommands {
private final JScrollPane messagesScroll = new JScrollPane(content, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); private final JScrollPane messagesScroll = new JScrollPane(content, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
public RecentCommands() { public RecentCommands() {
CommandQueue.getInstance().addListener(new CommandQueue.CommandQueueListener() { CommandQueue.getInstance().addListener(new CommandQueue.CommandQueueListener() {