/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.simbuck.plugins.simbuckflash;
import ch.ntb.usb.Device;
import java.awt.event.ActionEvent;
import java.util.ArrayList;
import javax.swing.Action;
import org.simbuck.GUI.SimbuckAbstractAction;
import org.simbuck.application.core.SimbuckUSBComms;
/**
*
* @author rjone611
*/
public class ResetFlashUSBAction extends SimbuckAbstractAction {
private static final String ACTION_COMMAND_KEY_BootFlashUSB = "ResetUSB-command";
private static final String NAME_BootFlashUSB = "USB Reset";
private static final String SMALL_ICON_BootFlashUSB = "cpu.png";
private static final String LARGE_ICON_BootFlashUSB = "cpu.png";
private static final String SHORT_DESCRIPTION_BootFlashUSB = "Reset Bootload mode via USB";
private static final String LONG_DESCRIPTION_BootFlashUSB = "Reset baseboard using USB Bootloader";
private static final int MNEMONIC_KEY_BootFlashUSB = 'R';
private Device simbuck;
/**
* constructor
*/
public ResetFlashUSBAction() {
putValue(Action.NAME, NAME_BootFlashUSB);
putValue(Action.SMALL_ICON, createImageIcon(SMALL_ICON_BootFlashUSB));
putValue(LARGE_ICON, createImageIcon(LARGE_ICON_BootFlashUSB));
putValue(Action.SHORT_DESCRIPTION, SHORT_DESCRIPTION_BootFlashUSB);
putValue(Action.LONG_DESCRIPTION, LONG_DESCRIPTION_BootFlashUSB);
putValue(Action.MNEMONIC_KEY, new Integer(MNEMONIC_KEY_BootFlashUSB));
putValue(Action.ACTION_COMMAND_KEY, ACTION_COMMAND_KEY_BootFlashUSB);
}
@Override
public void actionPerformed(ActionEvent e) {
// create the usb thread
SimbuckUSBComms USBcomm = new SimbuckUSBComms((short)0x04D8, (short)0x003C);
String msg[] = new String[1];
msg[0] = "08 00 00";
ArrayList al = new ArrayList(USBcomm.TransferBuffer(msg[0])); // - Works
if (!al.isEmpty()) {
StringBuilder str = new StringBuilder();
//int responseSize = Integer.parseInt(al.get(2).toString(), 16);
for (int j = 0; j < 32; j++) {
str.append(al.get(j));
str.append(" ");
}
System.out.println("\nData from Simbuck: \n" + str.toString());
}
}
}