Package org.simbuck.plugins.simbuckflash

Source Code of org.simbuck.plugins.simbuckflash.BootFlashUSBAction

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.simbuck.plugins.simbuckflash;

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 BootFlashUSBAction extends SimbuckAbstractAction {
   
   
    private static final String ACTION_COMMAND_KEY_BootFlashUSB = "BootUSB-command";
    private static final String NAME_BootFlashUSB = "USB Boot";
    private static final String SMALL_ICON_BootFlashUSB = "usb.png";
    private static final String LARGE_ICON_BootFlashUSB = "usb.png";
    private static final String SHORT_DESCRIPTION_BootFlashUSB = "Bootload mode via USB";
    private static final String LONG_DESCRIPTION_BootFlashUSB = "Load baseboard using USB Bootloader";
    private static final int MNEMONIC_KEY_BootFlashUSB = 'F';

   
   
    /**
     * constructor
     */
    public BootFlashUSBAction() {

        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)0x001F);
       
        String msg[] = new String[2];
          msg[0] = "15 FF A5";
          msg[1] = "FF 00 00";
        
         for(int i=0;i<2;i++)
         {
         ArrayList al = new ArrayList(USBcomm.TransferBuffer(msg[i]))// - 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());
       
          }
       } 
        
         USBcomm = null;
    }
}


TOP

Related Classes of org.simbuck.plugins.simbuckflash.BootFlashUSBAction

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.