splitting contiki messages on newlines

This commit is contained in:
fros4943 2008-10-03 10:36:39 +00:00
parent 70a74f624a
commit 52d9bcaed5

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: ContikiLog.java,v 1.2 2007/01/09 10:05:19 fros4943 Exp $
* $Id: ContikiLog.java,v 1.3 2008/10/03 10:36:39 fros4943 Exp $
*/
package se.sics.cooja.contikimote.interfaces;
@ -96,19 +96,22 @@ public class ContikiLog extends Log implements ContikiMoteInterface {
int totalLength = moteMem.getIntValueOf("simLoggedLength");
byte[] bytes = moteMem.getByteArray("simLoggedData", totalLength);
char[] chars = new char[bytes.length];
for (int i=0; i < chars.length; i++)
for (int i=0; i < chars.length; i++) {
chars[i] = (char) bytes[i];
String message = String.valueOf(chars);
lastLogMessage = message;
}
moteMem.setByteValueOf("simLoggedFlag", (byte) 0);
moteMem.setIntValueOf("simLoggedLength", (int) 0);
moteMem.setIntValueOf("simLoggedLength", 0);
String fullMessage[] = String.valueOf(chars).split("\n");
for (String message: fullMessage) {
lastLogMessage = message;
this.setChanged();
this.notifyObservers(mote);
}
}
}
public String getLastLogMessages() {
return lastLogMessage;
@ -121,10 +124,11 @@ public class ContikiLog extends Log implements ContikiMoteInterface {
logTextPane.setOpaque(false);
logTextPane.setEditable(false);
if (lastLogMessage == null)
if (lastLogMessage == null) {
logTextPane.setText("");
else
} else {
logTextPane.append(lastLogMessage);
}
Observer observer;
this.addObserver(observer = new Observer() {