splitting contiki messages on newlines
This commit is contained in:
parent
70a74f624a
commit
52d9bcaed5
1 changed files with 17 additions and 13 deletions
|
@ -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,17 +96,20 @@ 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);
|
||||
|
||||
this.setChanged();
|
||||
this.notifyObservers(mote);
|
||||
String fullMessage[] = String.valueOf(chars).split("\n");
|
||||
for (String message: fullMessage) {
|
||||
lastLogMessage = message;
|
||||
|
||||
this.setChanged();
|
||||
this.notifyObservers(mote);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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() {
|
||||
|
|
Loading…
Reference in a new issue