mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-12-23 01:29:33 +00:00
Merge branch 'master' of ssh://contiki.git.sourceforge.net/gitroot/contiki/contiki
This commit is contained in:
commit
c4eeb578a7
@ -202,8 +202,8 @@ handle_incoming_data(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
coap_error_code = INTERNAL_SERVER_ERROR_5_00;
|
||||
coap_error_message = "Service callback undefined";
|
||||
coap_error_code = NOT_IMPLEMENTED_5_01;
|
||||
coap_error_message = "NoServiceCallbck"; // no a to fit 16 bytes
|
||||
} /* if (service callback) */
|
||||
|
||||
} else {
|
||||
|
@ -81,12 +81,14 @@ PT_THREAD(coap_blocking_request(struct request_state_t *state, process_event_t e
|
||||
blocking_response_handler request_callback));
|
||||
|
||||
#define COAP_BLOCKING_REQUEST(server_addr, server_port, request, chunk_handler) \
|
||||
static struct request_state_t request_state; \
|
||||
PT_SPAWN(process_pt, &request_state.pt, \
|
||||
coap_blocking_request(&request_state, ev, \
|
||||
server_addr, server_port, \
|
||||
request, chunk_handler) \
|
||||
);
|
||||
{ \
|
||||
static struct request_state_t request_state; \
|
||||
PT_SPAWN(process_pt, &request_state.pt, \
|
||||
coap_blocking_request(&request_state, ev, \
|
||||
server_addr, server_port, \
|
||||
request, chunk_handler) \
|
||||
); \
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
#endif /* COAP_SERVER_H_ */
|
||||
|
@ -72,13 +72,6 @@ int coap_separate_handler(resource_t *resource, void *request, void *response)
|
||||
coap_init_message(ack, COAP_TYPE_ACK, 0, coap_req->mid);
|
||||
/* Serializing into IPBUF: Only overwrites header parts that are already parsed into the request struct. */
|
||||
coap_send_message(&UIP_IP_BUF->srcipaddr, UIP_UDP_BUF->srcport, (uip_appdata), coap_serialize_message(ack, uip_appdata));
|
||||
|
||||
/* Change response to separate response. */
|
||||
coap_res->type = COAP_TYPE_CON;
|
||||
coap_res->mid = coap_get_mid();
|
||||
|
||||
/* Update MID in transaction for identification. */
|
||||
t->mid = coap_res->mid;
|
||||
}
|
||||
|
||||
/* Pre-handlers could skip the handling by returning 0. */
|
||||
@ -86,26 +79,26 @@ int coap_separate_handler(resource_t *resource, void *request, void *response)
|
||||
}
|
||||
|
||||
int
|
||||
coap_separate_response(void *response, coap_separate_t *separate_store)
|
||||
coap_separate_response(void *request, coap_separate_t *separate_store)
|
||||
{
|
||||
coap_packet_t *const coap_res = (coap_packet_t *) response;
|
||||
coap_transaction_t *const t = coap_get_transaction_by_mid(coap_res->mid);
|
||||
coap_packet_t *const coap_req = (coap_packet_t *) request;
|
||||
coap_transaction_t *const t = coap_get_transaction_by_mid(coap_req->mid);
|
||||
|
||||
if (t)
|
||||
{
|
||||
uip_ipaddr_copy(&separate_store->addr, &t->addr);
|
||||
separate_store->port = t->port;
|
||||
|
||||
separate_store->mid = coap_res->mid;
|
||||
separate_store->type = coap_res->type;
|
||||
separate_store->type = coap_req->type==COAP_TYPE_CON ? COAP_TYPE_CON : COAP_TYPE_NON;
|
||||
separate_store->mid = coap_get_mid(); // if it was NON, we burned one MID in the engine...
|
||||
|
||||
memcpy(separate_store->token, coap_res->token, coap_res->token_len);
|
||||
separate_store->token_len = coap_res->token_len;
|
||||
memcpy(separate_store->token, coap_req->token, coap_req->token_len);
|
||||
separate_store->token_len = coap_req->token_len;
|
||||
|
||||
separate_store->block2_num = coap_res->block2_num;
|
||||
separate_store->block2_more = coap_res->block2_more;
|
||||
separate_store->block2_size = coap_res->block2_size;
|
||||
separate_store->block2_offset = coap_res->block2_offset;
|
||||
separate_store->block2_num = coap_req->block2_num;
|
||||
separate_store->block2_more = coap_req->block2_more;
|
||||
separate_store->block2_size = coap_req->block2_size;
|
||||
separate_store->block2_offset = coap_req->block2_offset;
|
||||
|
||||
/* Signal the engine to skip automatic response and clear transaction by engine. */
|
||||
coap_error_code = MANUAL_RESPONSE;
|
||||
|
@ -52,14 +52,12 @@ typedef struct coap_separate {
|
||||
uint8_t token_len;
|
||||
uint8_t token[COAP_TOKEN_LEN];
|
||||
|
||||
/* separate + blockwise is untested! */
|
||||
uint32_t block2_num;
|
||||
uint8_t block2_more;
|
||||
uint16_t block2_size;
|
||||
uint32_t block2_offset;
|
||||
|
||||
/* Add fields for addition information to be saved here, e.g.: */
|
||||
char buffer[17];
|
||||
|
||||
} coap_separate_t;
|
||||
|
||||
int coap_separate_handler(resource_t *resource, void *request, void *response);
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include "lib/random.h"
|
||||
#include "net/rime.h"
|
||||
#include "net/rime/timesynch.h"
|
||||
#include <string.h>
|
||||
|
||||
#if TIMESYNCH_CONF_ENABLED
|
||||
static int authority_level;
|
||||
|
@ -98,7 +98,7 @@ CFLAGS += -Os -fno-strict-aliasing
|
||||
LDFLAGS += -mmcu=$(MCU) -Wl,-Map=contiki-$(TARGET).map
|
||||
|
||||
### These flags can reduce the code size and RAM usage with up to 10%
|
||||
ifdef SMALL
|
||||
ifeq ($(SMALL),1)
|
||||
CFLAGS += -ffunction-sections
|
||||
# CFLAGS += -fdata-sections
|
||||
LDFLAGS += -Wl,--gc-sections,--undefined=_reset_vector__,--undefined=InterruptVectors,--undefined=_copy_data_init__,--undefined=_clear_bss_init__,--undefined=_end_of_init__
|
||||
|
@ -17,10 +17,14 @@ UIP_CONF_IPV6=1
|
||||
# configure CoAP implementation (3|7)
|
||||
WITH_COAP=7
|
||||
|
||||
# must be CFLAGS not variables
|
||||
# minimal-net does not support RPL, avoid redefine warnings
|
||||
# new variable since slip-radio
|
||||
ifneq ($(TARGET), minimal-net)
|
||||
CFLAGS += -DUIP_CONF_IPV6_RPL=1
|
||||
UIP_CONF_RPL=1
|
||||
else
|
||||
# minimal-net does not support RPL under Linux and is mostly used to test CoAP only
|
||||
${info INFO: compiling without RPL}
|
||||
UIP_CONF_RPL=0
|
||||
CFLAGS += -DUIP_CONF_ND6_DEF_MAXDADNS=0
|
||||
endif
|
||||
|
||||
# linker optimizations
|
||||
|
@ -355,12 +355,22 @@ chunks_handler(void* request, void* response, uint8_t *buffer, uint16_t preferre
|
||||
#include "er-coap-07-transactions.h"
|
||||
/*
|
||||
* CoAP-specific example for separate responses.
|
||||
* This resource is .
|
||||
* Note the call "rest_set_pre_handler(&resource_separate, coap_separate_handler);" in the main process.
|
||||
* The pre-handler takes care of the empty ACK and updates the MID and message type for CON requests.
|
||||
* The resource handler must store all information that required to finalize the response later.
|
||||
*/
|
||||
RESOURCE(separate, METHOD_GET, "debug/separate", "title=\"Separate demo\"");
|
||||
|
||||
/* A structure to store the required information */
|
||||
typedef struct application_separate_store {
|
||||
/* Provided by Erbium to store generic request information such as remote address and token. */
|
||||
coap_separate_t request_metadata;
|
||||
/* Add fields for addition information to be stored for finalizing, e.g.: */
|
||||
char buffer[16];
|
||||
} application_separate_store_t;
|
||||
|
||||
static uint8_t separate_active = 0;
|
||||
static coap_separate_t separate_store[1];
|
||||
static application_separate_store_t separate_store[1];
|
||||
|
||||
void
|
||||
separate_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
|
||||
@ -380,7 +390,7 @@ separate_handler(void* request, void* response, uint8_t *buffer, uint16_t prefer
|
||||
separate_active = 1;
|
||||
|
||||
/* Take over and skip response by engine. */
|
||||
coap_separate_response(response, separate_store);
|
||||
coap_separate_response(request, &separate_store->request_metadata);
|
||||
|
||||
/*
|
||||
* At the moment, only the minimal information is stored in the store (client address, port, token, MID, type, and Block2).
|
||||
@ -397,10 +407,10 @@ separate_finalize_handler()
|
||||
if (separate_active)
|
||||
{
|
||||
coap_transaction_t *transaction = NULL;
|
||||
if ( (transaction = coap_new_transaction(separate_store->mid, &separate_store->addr, separate_store->port)) )
|
||||
if ( (transaction = coap_new_transaction(separate_store->request_metadata.mid, &separate_store->request_metadata.addr, separate_store->request_metadata.port)) )
|
||||
{
|
||||
coap_packet_t response[1]; /* This way the packet can be treated as pointer as usual. */
|
||||
coap_init_message(response, separate_store->type, CONTENT_2_05, separate_store->mid);
|
||||
coap_init_message(response, separate_store->request_metadata.type, CONTENT_2_05, separate_store->request_metadata.mid);
|
||||
|
||||
coap_set_payload(response, separate_store->buffer, strlen(separate_store->buffer));
|
||||
|
||||
|
@ -157,7 +157,7 @@ exit(1);
|
||||
argv += optind - 1;
|
||||
|
||||
if(argc != 2 && argc != 3) {
|
||||
err(1, "usage: %s [-B baudrate] [-H] [-L] [-s siodev] [-t tundev] [-T] [-v verbosity] [-d delay] ipaddress", prog);
|
||||
err(1, "usage: %s [-B baudrate] [-H] [-L] [-s siodev] [-t tundev] [-T] [-v verbosity] [-d delay] [-a serveraddress] [-p serverport] ipaddress", prog);
|
||||
}
|
||||
slip_config_ipaddr = argv[1];
|
||||
|
||||
|
@ -72,14 +72,26 @@ AUTOSTART_PROCESSES(&border_router_process);
|
||||
#include "webserver-nogui.h"
|
||||
AUTOSTART_PROCESSES(&border_router_process,&webserver_nogui_process);
|
||||
#else
|
||||
/* Use simple webserver with only one page */
|
||||
/* Use simple webserver with only one page for minimum footprint.
|
||||
* Multiple connections can result in interleaved tcp segments since
|
||||
* a single static buffer is used for all segments.
|
||||
*/
|
||||
#include "httpd-simple.h"
|
||||
|
||||
/* The internal webserver can provide additional information if
|
||||
* enough program flash is available.
|
||||
*/
|
||||
#define WEBSERVER_CONF_LOADTIME 0
|
||||
#define WEBSERVER_CONF_FILESTATS 0
|
||||
#define WEBSERVER_CONF_NEIGHBOR_STATUS 0
|
||||
/* Adding links requires a larger RAM buffer. To avoid static allocation
|
||||
* the stack can be used for formatting; however tcp retransmissions
|
||||
* and multiple connections can result in garbled segments.
|
||||
* TODO:use PSOCk_GENERATOR_SEND and tcp state storage to fix this.
|
||||
*/
|
||||
#define WEBSERVER_CONF_ROUTE_LINKS 0
|
||||
#if WEBSERVER_CONF_ROUTE_LINKS
|
||||
#define BUF_USES_STACK 1
|
||||
#endif
|
||||
|
||||
PROCESS(webserver_nogui_process, "Web server");
|
||||
PROCESS_THREAD(webserver_nogui_process, ev, data)
|
||||
|
@ -387,7 +387,9 @@ public abstract class MspMote extends AbstractEmulatedMote implements Mote, Watc
|
||||
|
||||
public boolean setConfigXML(Simulation simulation, Collection<Element> configXML, boolean visAvailable) {
|
||||
setSimulation(simulation);
|
||||
myMoteInterfaceHandler = createMoteInterfaceHandler();
|
||||
if (myMoteInterfaceHandler == null) {
|
||||
myMoteInterfaceHandler = createMoteInterfaceHandler();
|
||||
}
|
||||
|
||||
/* Create watchpoint container */
|
||||
try {
|
||||
@ -497,18 +499,23 @@ public abstract class MspMote extends AbstractEmulatedMote implements Mote, Watc
|
||||
}
|
||||
if (di == null) {
|
||||
/* Return PC value */
|
||||
MapEntry mapEntry = ((SimpleProfiler)myCpu.getProfiler()).getCallMapEntry(0);
|
||||
if (mapEntry != null) {
|
||||
String file = mapEntry.getFile();
|
||||
if (file != null) {
|
||||
if (file.indexOf('/') >= 0) {
|
||||
file = file.substring(file.lastIndexOf('/')+1);
|
||||
SimpleProfiler sp = (SimpleProfiler)myCpu.getProfiler();
|
||||
try {
|
||||
MapEntry mapEntry = sp.getCallMapEntry(0);
|
||||
if (mapEntry != null) {
|
||||
String file = mapEntry.getFile();
|
||||
if (file != null) {
|
||||
if (file.indexOf('/') >= 0) {
|
||||
file = file.substring(file.lastIndexOf('/')+1);
|
||||
}
|
||||
}
|
||||
String name = mapEntry.getName();
|
||||
return file + ":?:" + name;
|
||||
}
|
||||
String name = mapEntry.getName();
|
||||
return file + ":?:" + name;
|
||||
return String.format("*%02x", myCpu.reg[MSP430Constants.PC]);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
return String.format("*%02x", myCpu.reg[MSP430Constants.PC]);
|
||||
}
|
||||
|
||||
int lineNo = di.getLine();
|
||||
|
@ -30,9 +30,6 @@
|
||||
*/
|
||||
|
||||
package se.sics.cooja.mspmote.interfaces;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Observable;
|
||||
import java.util.Observer;
|
||||
|
||||
@ -40,7 +37,6 @@ import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.jdom.Element;
|
||||
|
||||
import se.sics.cooja.Mote;
|
||||
import se.sics.cooja.MoteTimeEvent;
|
||||
@ -76,41 +72,6 @@ public class MspMoteID extends MoteID {
|
||||
public MspMoteID(Mote m) {
|
||||
this.mote = (MspMote) m;
|
||||
this.moteMem = (MspMoteMemory) mote.getMemory();
|
||||
|
||||
final MoteTimeEvent writeIDEvent = new MoteTimeEvent(mote, 0) {
|
||||
public void execute(long t) {
|
||||
setMoteID(moteID);
|
||||
}
|
||||
};
|
||||
|
||||
cpuMonitor = new CPUMonitor() {
|
||||
public void cpuAction(int type, int adr, int data) {
|
||||
if (type != MEMORY_WRITE) {
|
||||
return;
|
||||
}
|
||||
if (data == moteID) {
|
||||
return;
|
||||
}
|
||||
Simulation s = mote.getSimulation();
|
||||
if (writeIDEvent.isScheduled()) {
|
||||
return;
|
||||
}
|
||||
s.scheduleEvent(writeIDEvent, s.getSimulationTime());
|
||||
}
|
||||
};
|
||||
|
||||
if (moteMem.variableExists("node_id")) {
|
||||
this.mote.getCPU().addWatchPoint(moteMem.getVariableAddress("node_id"), cpuMonitor);
|
||||
}
|
||||
if (moteMem.variableExists("TOS_NODE_ID")) {
|
||||
this.mote.getCPU().addWatchPoint(moteMem.getVariableAddress("TOS_NODE_ID"), cpuMonitor);
|
||||
}
|
||||
if (moteMem.variableExists("ActiveMessageAddressC__addr")) {
|
||||
this.mote.getCPU().addWatchPoint(moteMem.getVariableAddress("ActiveMessageAddressC__addr"), cpuMonitor);
|
||||
}
|
||||
if (moteMem.variableExists("ActiveMessageAddressC$addr")) {
|
||||
this.mote.getCPU().addWatchPoint(moteMem.getVariableAddress("ActiveMessageAddressC$addr"), cpuMonitor);
|
||||
}
|
||||
}
|
||||
|
||||
public int getMoteID() {
|
||||
@ -149,6 +110,42 @@ public class MspMoteID extends MoteID {
|
||||
if (moteMem.variableExists("ActiveMessageAddressC$addr")) {
|
||||
moteMem.setIntValueOf("ActiveMessageAddressC$addr", newID);
|
||||
}
|
||||
if (cpuMonitor == null) {
|
||||
final MoteTimeEvent writeIDEvent = new MoteTimeEvent(mote, 0) {
|
||||
public void execute(long t) {
|
||||
setMoteID(moteID);
|
||||
}
|
||||
};
|
||||
|
||||
cpuMonitor = new CPUMonitor() {
|
||||
public void cpuAction(int type, int address, int data) {
|
||||
if (type != MEMORY_WRITE) {
|
||||
return;
|
||||
}
|
||||
if (data == moteID) {
|
||||
return;
|
||||
}
|
||||
if (writeIDEvent.isScheduled()) {
|
||||
return;
|
||||
}
|
||||
Simulation s = mote.getSimulation();
|
||||
s.scheduleEvent(writeIDEvent, s.getSimulationTime());
|
||||
}
|
||||
};
|
||||
|
||||
if (moteMem.variableExists("node_id")) {
|
||||
this.mote.getCPU().addWatchPoint(moteMem.getVariableAddress("node_id"), cpuMonitor);
|
||||
}
|
||||
if (moteMem.variableExists("TOS_NODE_ID")) {
|
||||
this.mote.getCPU().addWatchPoint(moteMem.getVariableAddress("TOS_NODE_ID"), cpuMonitor);
|
||||
}
|
||||
if (moteMem.variableExists("ActiveMessageAddressC__addr")) {
|
||||
this.mote.getCPU().addWatchPoint(moteMem.getVariableAddress("ActiveMessageAddressC__addr"), cpuMonitor);
|
||||
}
|
||||
if (moteMem.variableExists("ActiveMessageAddressC$addr")) {
|
||||
this.mote.getCPU().addWatchPoint(moteMem.getVariableAddress("ActiveMessageAddressC$addr"), cpuMonitor);
|
||||
}
|
||||
}
|
||||
|
||||
notifyObservers();
|
||||
}
|
||||
@ -183,35 +180,22 @@ public class MspMoteID extends MoteID {
|
||||
this.deleteObserver(observer);
|
||||
}
|
||||
|
||||
public Collection<Element> getConfigXML() {
|
||||
ArrayList<Element> config = new ArrayList<Element>();
|
||||
Element element = new Element("id");
|
||||
element.setText(Integer.toString(getMoteID()));
|
||||
config.add(element);
|
||||
return config;
|
||||
}
|
||||
|
||||
public void setConfigXML(Collection<Element> configXML, boolean visAvailable) {
|
||||
for (Element element : configXML) {
|
||||
if (element.getName().equals("id")) {
|
||||
setMoteID(Integer.parseInt(element.getText()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void removed() {
|
||||
super.removed();
|
||||
if (moteMem.variableExists("node_id")) {
|
||||
this.mote.getCPU().removeWatchPoint(moteMem.getVariableAddress("node_id"), cpuMonitor);
|
||||
}
|
||||
if (moteMem.variableExists("TOS_NODE_ID")) {
|
||||
this.mote.getCPU().removeWatchPoint(moteMem.getVariableAddress("TOS_NODE_ID"), cpuMonitor);
|
||||
}
|
||||
if (moteMem.variableExists("ActiveMessageAddressC__addr")) {
|
||||
this.mote.getCPU().removeWatchPoint(moteMem.getVariableAddress("ActiveMessageAddressC__addr"), cpuMonitor);
|
||||
}
|
||||
if (moteMem.variableExists("ActiveMessageAddressC$addr")) {
|
||||
this.mote.getCPU().removeWatchPoint(moteMem.getVariableAddress("ActiveMessageAddressC$addr"), cpuMonitor);
|
||||
if (cpuMonitor != null) {
|
||||
if (moteMem.variableExists("node_id")) {
|
||||
this.mote.getCPU().removeWatchPoint(moteMem.getVariableAddress("node_id"), cpuMonitor);
|
||||
}
|
||||
if (moteMem.variableExists("TOS_NODE_ID")) {
|
||||
this.mote.getCPU().removeWatchPoint(moteMem.getVariableAddress("TOS_NODE_ID"), cpuMonitor);
|
||||
}
|
||||
if (moteMem.variableExists("ActiveMessageAddressC__addr")) {
|
||||
this.mote.getCPU().removeWatchPoint(moteMem.getVariableAddress("ActiveMessageAddressC__addr"), cpuMonitor);
|
||||
}
|
||||
if (moteMem.variableExists("ActiveMessageAddressC$addr")) {
|
||||
this.mote.getCPU().removeWatchPoint(moteMem.getVariableAddress("ActiveMessageAddressC$addr"), cpuMonitor);
|
||||
}
|
||||
cpuMonitor = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.io.PrintStream;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JOptionPane;
|
||||
@ -44,7 +45,6 @@ import javax.swing.JPopupMenu;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import se.sics.cooja.ClassDescription;
|
||||
import se.sics.cooja.GUI;
|
||||
@ -53,6 +53,7 @@ import se.sics.cooja.MotePlugin;
|
||||
import se.sics.cooja.PluginType;
|
||||
import se.sics.cooja.Simulation;
|
||||
import se.sics.cooja.VisPlugin;
|
||||
import se.sics.cooja.dialogs.UpdateAggregator;
|
||||
import se.sics.cooja.mspmote.MspMote;
|
||||
import se.sics.mspsim.cli.CommandContext;
|
||||
import se.sics.mspsim.cli.LineListener;
|
||||
@ -77,8 +78,8 @@ public class MspCLI extends VisPlugin implements MotePlugin {
|
||||
|
||||
final Container panel = getContentPane();
|
||||
|
||||
logArea = new JTextArea(4, 30);
|
||||
logArea.setTabSize(4);
|
||||
logArea = new JTextArea(4, 20);
|
||||
logArea.setTabSize(8);
|
||||
logArea.setEditable(false);
|
||||
panel.add(new JScrollPane(logArea), BorderLayout.CENTER);
|
||||
|
||||
@ -176,27 +177,41 @@ public class MspCLI extends VisPlugin implements MotePlugin {
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
cliResponseAggregator.start();
|
||||
|
||||
panel.add(commandField, BorderLayout.SOUTH);
|
||||
setSize(500,500);
|
||||
}
|
||||
|
||||
public void closePlugin() {
|
||||
cliResponseAggregator.stop();
|
||||
}
|
||||
|
||||
public void addCLIData(final String text) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
String current = logArea.getText();
|
||||
int len = current.length();
|
||||
if (len > 4096) {
|
||||
current = current.substring(len - 4096);
|
||||
}
|
||||
current = len > 0 ? (current + '\n' + text) : text;
|
||||
logArea.setText(current);
|
||||
logArea.setCaretPosition(current.length());
|
||||
}
|
||||
});
|
||||
cliResponseAggregator.add(text);
|
||||
}
|
||||
|
||||
private static final int UPDATE_INTERVAL = 250;
|
||||
private UpdateAggregator<String> cliResponseAggregator = new UpdateAggregator<String>(UPDATE_INTERVAL) {
|
||||
protected void handle(List<String> ls) {
|
||||
String current = logArea.getText();
|
||||
int len = current.length();
|
||||
if (len > 4096) {
|
||||
current = current.substring(len - 4096);
|
||||
}
|
||||
|
||||
/* Add */
|
||||
StringBuilder sb = new StringBuilder(current);
|
||||
for (String l: ls) {
|
||||
sb.append(l);
|
||||
sb.append('\n');
|
||||
}
|
||||
logArea.setText(sb.toString());
|
||||
logArea.setCaretPosition(sb.length());
|
||||
}
|
||||
};
|
||||
|
||||
private String trim(String text) {
|
||||
return (text != null) && ((text = text.trim()).length() > 0) ? text : null;
|
||||
}
|
||||
|
@ -549,8 +549,9 @@ public class RadioLogger extends VisPlugin {
|
||||
|
||||
private boolean analyzePacket(PacketAnalyzer.Packet packet, StringBuffer brief, StringBuffer verbose) {
|
||||
if (analyzers == null) return false;
|
||||
boolean analyze = true;
|
||||
while (analyze) {
|
||||
try {
|
||||
boolean analyze = true;
|
||||
while (analyze) {
|
||||
analyze = false;
|
||||
for (int i = 0; i < analyzers.size(); i++) {
|
||||
PacketAnalyzer analyzer = analyzers.get(i);
|
||||
@ -570,6 +571,10 @@ public class RadioLogger extends VisPlugin {
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.debug("Error when analyzing packet: " + e.getMessage(), e);
|
||||
return false;
|
||||
}
|
||||
return brief.length() > 0;
|
||||
}
|
||||
|
||||
|
@ -262,6 +262,7 @@ public class TimeLine extends VisPlugin {
|
||||
|
||||
getContentPane().add(splitPane);
|
||||
|
||||
recalculateMoteHeight();
|
||||
pack();
|
||||
setSize(gui.getDesktopPane().getWidth(), 150);
|
||||
setLocation(0, gui.getDesktopPane().getHeight() - 150);
|
||||
@ -1192,9 +1193,11 @@ public class TimeLine extends VisPlugin {
|
||||
if (showWatchpoints) {
|
||||
h += EVENT_PIXEL_HEIGHT;
|
||||
}
|
||||
paintedMoteHeight = h;
|
||||
timelineMoteRuler.repaint();
|
||||
timeline.repaint();
|
||||
if (h != paintedMoteHeight) {
|
||||
paintedMoteHeight = h;
|
||||
timelineMoteRuler.repaint();
|
||||
timeline.repaint();
|
||||
}
|
||||
}
|
||||
|
||||
public void closePlugin() {
|
||||
@ -1346,6 +1349,7 @@ public class TimeLine extends VisPlugin {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private int mousePixelPositionX = -1;
|
||||
private int mousePixelPositionY = -1;
|
||||
private int mouseDownPixelPositionX = -1;
|
||||
|
@ -603,39 +603,44 @@ ifconf(const char *tundev, const char *ipaddr)
|
||||
#elif 1
|
||||
/* Generate a link local address a la sixxs/aiccu */
|
||||
/* First a full parse, stripping off the prefix length */
|
||||
{
|
||||
char lladdr[40];
|
||||
char c,*ptr=(char *)ipaddr;
|
||||
uint16_t digit,ai,a[8],cc,scc,i;
|
||||
for(ai=0;ai<8;ai++) a[ai]=0;
|
||||
ai=0;cc=scc=0;
|
||||
while(c=*ptr++) {
|
||||
if(c=='/') break;
|
||||
if(c==':') {
|
||||
if(cc) scc = ai;
|
||||
cc = 1;
|
||||
if (++ai>7) break;
|
||||
} else {
|
||||
cc=0;
|
||||
digit = c-'0'; if (digit > 9) digit = 10 + (c & 0xdf) - 'A';
|
||||
a[ai] = (a[ai] << 4) + digit;
|
||||
{
|
||||
char lladdr[40];
|
||||
char c, *ptr=(char *)ipaddr;
|
||||
uint16_t digit,ai,a[8],cc,scc,i;
|
||||
for(ai=0; ai<8; ai++) {
|
||||
a[ai]=0;
|
||||
}
|
||||
}
|
||||
/* Get # elided and shift what's after to the end */
|
||||
cc=8-ai;
|
||||
for(i=0;i<cc;i++) {
|
||||
if ((8-i-cc) <= scc) {
|
||||
a[7-i] = 0;
|
||||
} else {
|
||||
a[7-i] = a[8-i-cc];
|
||||
a[8-i-cc]=0;
|
||||
ai=0;
|
||||
cc=scc=0;
|
||||
while(c=*ptr++) {
|
||||
if(c=='/') break;
|
||||
if(c==':') {
|
||||
if(cc)
|
||||
scc = ai;
|
||||
cc = 1;
|
||||
if(++ai>7) break;
|
||||
} else {
|
||||
cc=0;
|
||||
digit = c-'0';
|
||||
if (digit > 9)
|
||||
digit = 10 + (c & 0xdf) - 'A';
|
||||
a[ai] = (a[ai] << 4) + digit;
|
||||
}
|
||||
}
|
||||
/* Get # elided and shift what's after to the end */
|
||||
cc=8-ai;
|
||||
for(i=0;i<cc;i++) {
|
||||
if ((8-i-cc) <= scc) {
|
||||
a[7-i] = 0;
|
||||
} else {
|
||||
a[7-i] = a[8-i-cc];
|
||||
a[8-i-cc]=0;
|
||||
}
|
||||
}
|
||||
sprintf(lladdr,"fe80::%x:%x:%x:%x",a[1]&0xfefd,a[2],a[3],a[7]);
|
||||
if (timestamp) stamptime();
|
||||
ssystem("ifconfig %s add %s/64", tundev, lladdr);
|
||||
}
|
||||
sprintf(lladdr,"fe80::%x:%x:%x:%x",a[1]&0xfefd,a[2],a[3],a[7]);
|
||||
|
||||
if (timestamp) stamptime();
|
||||
ssystem("ifconfig %s add %s/64", tundev, lladdr);
|
||||
|
||||
#endif /* link local */
|
||||
|
||||
#else
|
||||
|
Loading…
Reference in New Issue
Block a user