reading specified binary firmware from webserver
This commit is contained in:
parent
2691abecaa
commit
a4c408fb66
1 changed files with 20 additions and 3 deletions
|
@ -26,12 +26,14 @@
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* $Id: MspMote.java,v 1.6 2008/04/01 08:08:58 fros4943 Exp $
|
* $Id: MspMote.java,v 1.7 2008/04/03 14:01:06 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.mspmote;
|
package se.sics.cooja.mspmote;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLConnection;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.jdom.Element;
|
import org.jdom.Element;
|
||||||
|
@ -90,7 +92,6 @@ public abstract class MspMote implements Mote {
|
||||||
public MspMote(MspMoteType moteType, Simulation simulation) {
|
public MspMote(MspMoteType moteType, Simulation simulation) {
|
||||||
myMoteType = moteType;
|
myMoteType = moteType;
|
||||||
mySimulation = simulation;
|
mySimulation = simulation;
|
||||||
|
|
||||||
initEmulator(myMoteType.getELFFile());
|
initEmulator(myMoteType.getELFFile());
|
||||||
|
|
||||||
myMoteInterfaceHandler = createMoteInterfaceHandler();
|
myMoteInterfaceHandler = createMoteInterfaceHandler();
|
||||||
|
@ -182,7 +183,23 @@ public abstract class MspMote implements Mote {
|
||||||
|
|
||||||
int[] memory = myCpu.getMemory();
|
int[] memory = myCpu.getMemory();
|
||||||
|
|
||||||
|
if (GUI.isVisualizedInApplet()) {
|
||||||
|
URLConnection urlConnection = new URL(GUI.getAppletCodeBase(), fileELF.getName()).openConnection();
|
||||||
|
urlConnection.setDoInput(true);
|
||||||
|
urlConnection.setUseCaches(false);
|
||||||
|
DataInputStream inputStream = new DataInputStream(urlConnection.getInputStream());
|
||||||
|
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
|
||||||
|
byte[] firmwareData = new byte[2048];
|
||||||
|
for(int read; (read = inputStream.read(firmwareData)) != -1; byteStream.write(firmwareData, 0, read)) { }
|
||||||
|
inputStream.close();
|
||||||
|
firmwareData = null;
|
||||||
|
firmwareData = byteStream.toByteArray();
|
||||||
|
|
||||||
|
myELFModule = new ELF(firmwareData);
|
||||||
|
myELFModule.readAll();
|
||||||
|
} else {
|
||||||
myELFModule = ELF.readELF(fileELF.getPath());
|
myELFModule = ELF.readELF(fileELF.getPath());
|
||||||
|
}
|
||||||
myELFModule.loadPrograms(memory);
|
myELFModule.loadPrograms(memory);
|
||||||
MapTable map = myELFModule.getMap();
|
MapTable map = myELFModule.getMap();
|
||||||
myCpu.getDisAsm().setMap(map);
|
myCpu.getDisAsm().setMap(map);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue