From 42063530c0690f5aa19795019e2598a53e4c836a Mon Sep 17 00:00:00 2001 From: Christian Mehlis Date: Sun, 9 Jun 2013 17:52:02 +0200 Subject: [PATCH 01/13] clarify: while loop without body is correct here --- core/sched.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/sched.c b/core/sched.c index 0b21dea1f8..2a475b2817 100644 --- a/core/sched.c +++ b/core/sched.c @@ -96,7 +96,10 @@ void sched_run() { if (num_tasks == 0) { DEBUG("scheduler: no tasks left.\n"); - while(! num_tasks); + while(! num_tasks) { + /* loop until a new task arrives */ + ; + } DEBUG("scheduler: new task created.\n"); } From b41fd192161e826b36423e3c38b82a2cc37d71a7 Mon Sep 17 00:00:00 2001 From: Christian Mehlis Date: Sun, 9 Jun 2013 18:02:30 +0200 Subject: [PATCH 02/13] prevent double include of debug.h --- core/include/debug.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/include/debug.h b/core/include/debug.h index 649171de72..f7d5a89cca 100644 --- a/core/include/debug.h +++ b/core/include/debug.h @@ -16,6 +16,9 @@ * @} */ +#ifndef DEBUG_H_ +#define DEBUG_H_ + #include #ifdef ENABLE_DEBUG @@ -23,3 +26,5 @@ #else #define DEBUG(...) #endif + +#endif /* DEGUG_H_ */ From 8f74612762db854354fe0e89f9c0027e284bc1da Mon Sep 17 00:00:00 2001 From: Christian Mehlis Date: Sun, 9 Jun 2013 18:02:58 +0200 Subject: [PATCH 03/13] main should always return int this fixes some compiler warnings --- core/kernel_init.c | 2 +- sys/auto_init/auto_init.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/kernel_init.c b/core/kernel_init.c index 29122abe0a..eb35ea5feb 100644 --- a/core/kernel_init.c +++ b/core/kernel_init.c @@ -37,7 +37,7 @@ volatile tcb_t *sched_threads[MAXTHREADS]; volatile tcb_t *active_thread; volatile int lpm_prevent_sleep = 0; -extern void main(void); +extern int main(void); static void idle_thread(void) { while(1) { diff --git a/sys/auto_init/auto_init.c b/sys/auto_init/auto_init.c index be6feabada..6c084af3e9 100644 --- a/sys/auto_init/auto_init.c +++ b/sys/auto_init/auto_init.c @@ -9,7 +9,7 @@ #define ENABLE_DEBUG #include -extern void main(void); +extern int main(void); void auto_init(void) { #ifdef MODULE_BOARD_DISPLAY From 6f92e1dae8a351253c9ac88a4cb08b1273fa4b78 Mon Sep 17 00:00:00 2001 From: Oliver Hahm Date: Mon, 10 Jun 2013 12:40:59 +0200 Subject: [PATCH 04/13] * changed transceiver_type_t to bit field (fixing #47) --- sys/include/transceiver.h | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/sys/include/transceiver.h b/sys/include/transceiver.h index f6cb927684..572d2162b1 100644 --- a/sys/include/transceiver.h +++ b/sys/include/transceiver.h @@ -12,8 +12,11 @@ #endif #endif +#ifdef MODULE_CC2420 +#define PAYLOAD_SIZE (118) +#else #define PAYLOAD_SIZE (58) - +#endif /* The maximum of threads to register */ #define TRANSCEIVER_MAX_REGISTERED (4) @@ -21,6 +24,19 @@ * of two */ #define TRANSCEIVER_MSG_BUFFER_SIZE (32) +/** + * @brief All supported transceivers + */ +#define TRANSCEIVER_NONE (0x0) ///< Invalid +#define TRANSCEIVER_CC1100 (0x01) ///< CC110X transceivers +#define TRANSCEIVER_CC1020 (0x02) ///< CC1020 transceivers +#define TRANSCEIVER_CC2420 (0x04) ///< CC2420 transceivers + +/** + * @brief Data type for transceiver specification + */ +typedef uint16_t transceiver_type_t; + /** * @brief Message types for transceiver interface */ @@ -28,6 +44,7 @@ enum transceiver_msg_type_t { /* Message types for driver <-> transceiver communication */ RCV_PKT_CC1020, ///< packet was received by CC1020 transceiver RCV_PKT_CC1100, ///< packet was received by CC1100 transceiver + RCV_PKT_CC2420, ///< packet was received by CC2420 transceiver /* Message types for transceiver <-> upper layer communication */ PKT_PENDING, ///< packet pending in transceiver buffer @@ -40,6 +57,8 @@ enum transceiver_msg_type_t { GET_ADDRESS, ///< Get the radio address SET_ADDRESS, ///< Set the radio address SET_MONITOR, ///< Set transceiver to monitor mode (disable address checking) + GET_PAN, ///< Get current pan + SET_PAN, ///< Set a new pan /* debug message types */ DBG_IGN, ///< add a physical address to the ignore list @@ -48,15 +67,6 @@ enum transceiver_msg_type_t { ENOBUFFER, ///< No buffer left }; -/** - * @brief All supported transceivers - */ -typedef enum { - TRANSCEIVER_NONE, ///< Invalid - TRANSCEIVER_CC1100, ///< CC110X transceivers - TRANSCEIVER_CC1020 ///< CC1020 transceivers -} transceiver_type_t; - /** * @brief Manage registered threads per transceiver */ From 40edc250227580e0f93707e75799dd14f0317156 Mon Sep 17 00:00:00 2001 From: Oliver Hahm Date: Mon, 10 Jun 2013 16:23:42 +0200 Subject: [PATCH 05/13] * cast main function in kernel_init to match prototype --- core/kernel_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/kernel_init.c b/core/kernel_init.c index eb35ea5feb..c912d3d381 100644 --- a/core/kernel_init.c +++ b/core/kernel_init.c @@ -61,7 +61,7 @@ static char idle_stack[KERNEL_CONF_STACKSIZE_IDLE]; #ifdef MODULE_AUTO_INIT #define MAIN_FUNC auto_init #else -#define MAIN_FUNC main +#define MAIN_FUNC ((void (*) (void)) main) #endif void kernel_init(void) From 43255ff855f02ebd628f60a2df71ad3ef40eda8b Mon Sep 17 00:00:00 2001 From: Martin Date: Mon, 10 Jun 2013 17:36:56 +0200 Subject: [PATCH 06/13] fix warnings due to unapropriate prototypes --- sys/net/sixlowpan/flowcontrol.c | 4 ++-- sys/net/sixlowpan/flowcontrol.h | 2 +- sys/net/sixlowpan/rpl/objective_functions.c | 2 +- sys/net/sixlowpan/rpl/objective_functions.h | 2 +- sys/net/sixlowpan/rpl/of0.c | 2 +- sys/net/sixlowpan/rpl/of0.h | 2 +- sys/net/sixlowpan/rpl/rpl.c | 20 ++++++++++---------- sys/net/sixlowpan/rpl/rpl.h | 4 ++-- sys/net/sixlowpan/rpl/rpl_dodag.h | 6 +++--- sys/net/sixlowpan/sixlowborder.h | 2 +- sys/net/sixlowpan/sixlownd.c | 8 ++++---- sys/net/sixlowpan/sixlowpan.c | 4 +--- sys/net/sixlowpan/sixlowpan.h | 4 ++-- 13 files changed, 30 insertions(+), 32 deletions(-) diff --git a/sys/net/sixlowpan/flowcontrol.c b/sys/net/sixlowpan/flowcontrol.c index 0e5e1c9968..11ebe81e53 100644 --- a/sys/net/sixlowpan/flowcontrol.c +++ b/sys/net/sixlowpan/flowcontrol.c @@ -20,7 +20,7 @@ flowcontrol_stat_t slwin_stat; sem_t connection_established; int16_t synack_seqnum = -1; -ipv6_addr_t init_threeway_handshake() { +ipv6_addr_t init_threeway_handshake(void) { border_syn_packet_t *syn; msg_t m; m.content.ptr = NULL; @@ -48,7 +48,7 @@ ipv6_addr_t init_threeway_handshake() { return addr; } -ipv6_addr_t flowcontrol_init() { +ipv6_addr_t flowcontrol_init(void) { int i; sem_init(&slwin_stat.send_win_not_full,BORDER_SWS); diff --git a/sys/net/sixlowpan/flowcontrol.h b/sys/net/sixlowpan/flowcontrol.h index 6c4c3ba582..060e049014 100644 --- a/sys/net/sixlowpan/flowcontrol.h +++ b/sys/net/sixlowpan/flowcontrol.h @@ -51,7 +51,7 @@ typedef struct __attribute__ ((packed)) border_syn_packet_t { ipv6_addr_t addr; } border_syn_packet_t; -ipv6_addr_t flowcontrol_init(); +ipv6_addr_t flowcontrol_init(void); void flowcontrol_send_over_uart(border_packet_t *packet, int len); void flowcontrol_deliver_from_uart(border_packet_t *packet, int len); diff --git a/sys/net/sixlowpan/rpl/objective_functions.c b/sys/net/sixlowpan/rpl/objective_functions.c index 96cb486731..9eb637111d 100644 --- a/sys/net/sixlowpan/rpl/objective_functions.c +++ b/sys/net/sixlowpan/rpl/objective_functions.c @@ -1,6 +1,6 @@ #include "objective_functions.h" -void of0(){ +void of0(void){ } diff --git a/sys/net/sixlowpan/rpl/objective_functions.h b/sys/net/sixlowpan/rpl/objective_functions.h index a6acfb0a3c..06c7b1620a 100644 --- a/sys/net/sixlowpan/rpl/objective_functions.h +++ b/sys/net/sixlowpan/rpl/objective_functions.h @@ -1,3 +1,3 @@ #include -void of0(); +void of0(void); diff --git a/sys/net/sixlowpan/rpl/of0.c b/sys/net/sixlowpan/rpl/of0.c index aebb6b6ebc..2719dedd26 100644 --- a/sys/net/sixlowpan/rpl/of0.c +++ b/sys/net/sixlowpan/rpl/of0.c @@ -10,7 +10,7 @@ rpl_of_t rpl_of0 = { NULL }; -rpl_of_t *rpl_get_of0(){ +rpl_of_t *rpl_get_of0(void){ return &rpl_of0; } diff --git a/sys/net/sixlowpan/rpl/of0.h b/sys/net/sixlowpan/rpl/of0.h index f31ec693e5..72a6900e8b 100644 --- a/sys/net/sixlowpan/rpl/of0.h +++ b/sys/net/sixlowpan/rpl/of0.h @@ -1,6 +1,6 @@ #include "rpl_structs.h" -rpl_of_t *rpl_get_of0(); +rpl_of_t *rpl_get_of0(void); uint16_t calc_rank(rpl_parent_t *, uint16_t); rpl_parent_t *which_parent(rpl_parent_t *, rpl_parent_t *); rpl_dodag_t *which_dodag(rpl_dodag_t *, rpl_dodag_t *); diff --git a/sys/net/sixlowpan/rpl/rpl.c b/sys/net/sixlowpan/rpl/rpl.c index 12c6b7f332..b760964254 100644 --- a/sys/net/sixlowpan/rpl/rpl.c +++ b/sys/net/sixlowpan/rpl/rpl.c @@ -65,18 +65,18 @@ static struct icmpv6_hdr_t * get_rpl_send_icmpv6_buf(uint8_t ext_len){ //return ((struct icmpv6_hdr_t*)&(rpl_send_buffer[LLHDR_IPV6HDR_LEN + ext_len])); return ((struct icmpv6_hdr_t*)&(rpl_send_buffer[IPV6_HDR_LEN + ext_len])); } -static struct rpl_dio_t* get_rpl_send_dio_buf(){ +static struct rpl_dio_t* get_rpl_send_dio_buf(void){ //return ((struct rpl_dio_t*)&(rpl_send_buffer[LLHDR_ICMPV6HDR_LEN])); return ((struct rpl_dio_t*)&(rpl_send_buffer[IPV6HDR_ICMPV6HDR_LEN])); } -static struct rpl_dao_t* get_rpl_send_dao_buf(){ +static struct rpl_dao_t* get_rpl_send_dao_buf(void){ //return ((struct rpl_dao_t*)&(rpl_send_buffer[LLHDR_ICMPV6HDR_LEN])); return ((struct rpl_dao_t*)&(rpl_send_buffer[IPV6HDR_ICMPV6HDR_LEN])); } -static struct rpl_dao_ack_t* get_rpl_send_dao_ack_buf(){ +static struct rpl_dao_ack_t* get_rpl_send_dao_ack_buf(void){ return ((struct rpl_dao_ack_t*)&(rpl_send_buffer[IPV6HDR_ICMPV6HDR_LEN])); } -static struct rpl_dis_t* get_rpl_send_dis_buf(){ +static struct rpl_dis_t* get_rpl_send_dis_buf(void){ //return ((struct rpl_dis_t*)&(rpl_send_buffer[LLHDR_ICMPV6HDR_LEN])); return ((struct rpl_dis_t*)&(rpl_send_buffer[IPV6HDR_ICMPV6HDR_LEN])); } @@ -98,17 +98,17 @@ static struct rpl_opt_transit_t* get_rpl_send_opt_transit_buf(uint8_t rpl_msg_le static struct ipv6_hdr_t * get_rpl_ipv6_buf(void){ return ((struct ipv6_hdr_t*)&(rpl_buffer[0])); } -static struct rpl_dio_t* get_rpl_dio_buf(){ +static struct rpl_dio_t* get_rpl_dio_buf(void){ return ((struct rpl_dio_t*)&(rpl_buffer[IPV6HDR_ICMPV6HDR_LEN])); } -static struct rpl_dao_t* get_rpl_dao_buf(){ +static struct rpl_dao_t* get_rpl_dao_buf(void){ return ((struct rpl_dao_t*)&(rpl_buffer[IPV6HDR_ICMPV6HDR_LEN])); } -static struct rpl_dao_ack_t* get_rpl_dao_ack_buf(){ +static struct rpl_dao_ack_t* get_rpl_dao_ack_buf(void){ return ((struct rpl_dao_ack_t*)&(buffer[LLHDR_ICMPV6HDR_LEN])); } -static struct rpl_dis_t* get_rpl_dis_buf(){ +static struct rpl_dis_t* get_rpl_dis_buf(void){ return ((struct rpl_dis_t*)&(rpl_buffer[IPV6HDR_ICMPV6HDR_LEN])); } static struct rpl_opt_t* get_rpl_opt_buf(uint8_t rpl_msg_len){ @@ -188,7 +188,7 @@ uint8_t rpl_init(transceiver_type_t trans, uint16_t rpl_address){ } -void rpl_init_root(){ +void rpl_init_root(void){ rpl_instance_t *inst; rpl_dodag_t *dodag; @@ -892,7 +892,7 @@ rpl_routing_entry_t *rpl_find_routing_entry(ipv6_addr_t *addr){ return NULL; } -void rpl_clear_routing_table(){ +void rpl_clear_routing_table(void){ for(uint8_t i=0; i Date: Mon, 10 Jun 2013 17:39:11 +0200 Subject: [PATCH 07/13] fix ICMP type is DIS --- sys/net/sixlowpan/rpl/rpl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/net/sixlowpan/rpl/rpl.c b/sys/net/sixlowpan/rpl/rpl.c index b760964254..14d72486b3 100644 --- a/sys/net/sixlowpan/rpl/rpl.c +++ b/sys/net/sixlowpan/rpl/rpl.c @@ -293,7 +293,7 @@ void send_DIS(ipv6_addr_t *destination){ icmp_send_buf = get_rpl_send_icmpv6_buf(ipv6_ext_hdr_len); icmp_send_buf->type = ICMP_RPL_CONTROL; - icmp_send_buf->code = ICMP_CODE_DIO; + icmp_send_buf->code = ICMP_CODE_DIS; icmp_send_buf->checksum = ~icmpv6_csum(PROTO_NUM_ICMPV6); rpl_send_dis_buf = get_rpl_send_dis_buf(); From d31bad6c9e742ff16f4376993fadd1d7482b1def Mon Sep 17 00:00:00 2001 From: Oliver Hahm Date: Tue, 11 Jun 2013 15:50:42 +0200 Subject: [PATCH 08/13] * cleaned up output from Makefiles --- Makefile.base | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile.base b/Makefile.base index cbd79d771a..27b51d8497 100644 --- a/Makefile.base +++ b/Makefile.base @@ -11,15 +11,15 @@ include $(RIOTCPU)/Makefile.base include $(RIOTBOARD)/Makefile.base $(BINDIR)$(MODULE).a: $(OBJ) $(ASMOBJ) - $(AR) -rc $(BINDIR)$(MODULE).a $(OBJ) $(ASMOBJ) + @$(AR) -rc $(BINDIR)$(MODULE).a $(OBJ) $(ASMOBJ) # pull in dependency info for *existing* .o files -include $(OBJ:.o=.d) # compile and generate dependency info $(BINDIR)%.o: %.c - $(CC) $(CFLAGS) $(PROJECTINCLUDE) $(BOARDINCLUDE) $(INCLUDES) -c $*.c -o $(BINDIR)$*.o - $(CC) $(CFLAGS) $(PROJECTINCLUDE) $(BOARDINCLUDE) $(INCLUDES) -MM $*.c > $(BINDIR)$*.d + @$(CC) $(CFLAGS) $(PROJECTINCLUDE) $(BOARDINCLUDE) $(INCLUDES) -c $*.c -o $(BINDIR)$*.o + @$(CC) $(CFLAGS) $(PROJECTINCLUDE) $(BOARDINCLUDE) $(INCLUDES) -MM $*.c > $(BINDIR)$*.d @printf "$(BINDIR)"|cat - $(BINDIR)$*.d > /tmp/riot_out && mv /tmp/riot_out $(BINDIR)$*.d $(BINDIR)%.o: %.s @@ -30,5 +30,5 @@ $(BINDIR)%.o: %.S # remove compilation products clean:: - rm -f $(BINDIR)$(MODULE).a $(OBJ) $(DEP) $(ASMOBJ) + @rm -f $(BINDIR)$(MODULE).a $(OBJ) $(DEP) $(ASMOBJ) From b8f674f5b6e95cb8f2a0f44be3f3601a3e7bedc9 Mon Sep 17 00:00:00 2001 From: Oliver Hahm Date: Wed, 12 Jun 2013 16:18:32 +0200 Subject: [PATCH 09/13] fix context switch in lpm_sleep --- cpu/native/lpm_cpu.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cpu/native/lpm_cpu.c b/cpu/native/lpm_cpu.c index f621c96062..45a5e01bc3 100644 --- a/cpu/native/lpm_cpu.c +++ b/cpu/native/lpm_cpu.c @@ -46,11 +46,19 @@ void _native_lpm_sleep() retval = select(1, &_native_uart_rfds, NULL, NULL, NULL); DEBUG("_native_lpm_sleep: retval: %i\n", retval); if (retval != -1) { - DEBUG("\n\n\t\treturn from syscall, calling _native_handle_uart0_input\n\n"); + /* uart ready, swap to ISR context and handle input */ + makecontext(_native_isr_ctx, _native_handle_uart0_input, 0); + swapcontext((ucontext_t*)(active_thread->sp), _native_isr_ctx); + } + else if ((retval == -1) && (errno == EINTR)) { + /* TODO: reevaluate and merge with above branch + * IF any thread except the idle thread uses lpm_set this could make sense... */ + /* select interrupted by signal swap to ISR context and handle input */ + DEBUG("\n\n\t\treturn from interrupted syscall, swapping context and calling _native_handle_uart0_input\n\n"); makecontext(_native_isr_ctx, _native_handle_uart0_input, 0); swapcontext(_native_cur_ctx, _native_isr_ctx); } - else if (errno != EINTR) { + else { err(1, "lpm_set(): select()"); } #else From 4d8783e023410e414bcbea208df4b46a72f71d0d Mon Sep 17 00:00:00 2001 From: Christian Mehlis Date: Thu, 13 Jun 2013 10:22:55 +0200 Subject: [PATCH 10/13] use out parameter for vtimer_now --- drivers/cc110x/cc1100-csmaca-mac.c | 15 ++++++++++----- drivers/cc110x/cc1100_phy.c | 6 ++++-- sys/include/vtimer.h | 2 +- sys/net/destiny/destiny.c | 4 +++- sys/net/destiny/socket.c | 16 ++++++++++++---- sys/net/destiny/tcp_timer.c | 14 +++++++++----- sys/net/sixlowpan/sixlowip.c | 10 +++++++--- sys/net/sixlowpan/sixlownd.c | 3 ++- sys/net/sixlowpan/sixlowpan.c | 13 ++++++++++--- sys/ping/ping.c | 5 +++-- sys/vtimer/vtimer.c | 10 ++++++---- 11 files changed, 67 insertions(+), 31 deletions(-) diff --git a/drivers/cc110x/cc1100-csmaca-mac.c b/drivers/cc110x/cc1100-csmaca-mac.c index 2eaa401b94..eb492e7909 100644 --- a/drivers/cc110x/cc1100-csmaca-mac.c +++ b/drivers/cc110x/cc1100-csmaca-mac.c @@ -102,22 +102,26 @@ int cc1100_send_csmaca(radio_address_t address, protocol_t protocol, int priorit // Calculate collisions per second if (collision_state == COLLISION_STATE_INITIAL) { - timex_t now = vtimer_now(); + timex_t now; + vtimer_now(&now); collision_measurement_start = now.microseconds; collision_count = 0; collisions_per_sec = 0; collision_state = COLLISION_STATE_MEASURE; } else if (collision_state == COLLISION_STATE_MEASURE) { - timex_t now = vtimer_now(); + timex_t now; + vtimer_now(&now); uint64_t timespan = now.microseconds - collision_measurement_start; if (timespan > 1000000) { collisions_per_sec = (collision_count * 1000000) / (double) timespan; if (collisions_per_sec > 0.5 && collisions_per_sec <= 2.2) { - timex_t now = vtimer_now(); + timex_t now; + vtimer_now(&now); collision_measurement_start = now.microseconds; collision_state = COLLISION_STATE_KEEP; } else if (collisions_per_sec > 2.2) { - timex_t now = vtimer_now(); + timex_t now; + vtimer_now(now); collision_measurement_start = now.microseconds; collision_state = COLLISION_STATE_KEEP; } else { @@ -125,7 +129,8 @@ int cc1100_send_csmaca(radio_address_t address, protocol_t protocol, int priorit } } } else if (collision_state == COLLISION_STATE_KEEP) { - timex_t now = vtimer_now(); + timex_t now; + vtimer_now(&now); uint64_t timespan = now.microseconds - collision_measurement_start; if (timespan > 5000000) { collision_state = COLLISION_STATE_INITIAL; diff --git a/drivers/cc110x/cc1100_phy.c b/drivers/cc110x/cc1100_phy.c index 0b2299a1a8..6bc27601bd 100644 --- a/drivers/cc110x/cc1100_phy.c +++ b/drivers/cc110x/cc1100_phy.c @@ -375,7 +375,8 @@ static bool contains_seq_entry(uint8_t src, uint8_t id) { int i; uint32_t cmp; - timex_t now_timex = vtimer_now(); + timex_t now_timex; + vtimer_now(&now_timex); uint64_t now = now_timex.microseconds; for (i = 0; i < MAX_SEQ_BUFFER_SIZE; i++) @@ -414,7 +415,8 @@ static void add_seq_entry(uint8_t src, uint8_t id) // Add new entry seq_buffer[seq_buffer_pos].source = src; seq_buffer[seq_buffer_pos].identification = id; - timex_t now = vtimer_now(); + timex_t now; + vtimer_now(&now); seq_buffer[seq_buffer_pos].m_ticks = now.microseconds; // Store 16 bit sequence number of layer 0 for speedup diff --git a/sys/include/vtimer.h b/sys/include/vtimer.h index def9666013..c50f5a496b 100644 --- a/sys/include/vtimer.h +++ b/sys/include/vtimer.h @@ -43,7 +43,7 @@ typedef struct vtimer_t { * @brief Current system time * @return Time as timex_t since system boot */ -timex_t vtimer_now(void); +void vtimer_now(timex_t* out); /** * @brief Initializes the vtimer subsystem. To be called once at system initialization. Will be initialized by auto_init. diff --git a/sys/net/destiny/destiny.c b/sys/net/destiny/destiny.c index ab59b49a68..84862d5644 100644 --- a/sys/net/destiny/destiny.c +++ b/sys/net/destiny/destiny.c @@ -27,7 +27,9 @@ void init_transport_layer(void) set_udp_packet_handler_pid(udp_thread_pid); // TCP - srand(vtimer_now().microseconds); + timex_t now; + vtimer_now(&now); + srand(now.microseconds); #ifdef TCP_HC printf("TCP_HC enabled!\n"); global_context_counter = rand(); diff --git a/sys/net/destiny/socket.c b/sys/net/destiny/socket.c index eaaf4d9a82..c08a0a21ad 100644 --- a/sys/net/destiny/socket.c +++ b/sys/net/destiny/socket.c @@ -74,9 +74,11 @@ void print_tcp_flags (tcp_hdr_t *tcp_header) void print_tcp_cb(tcp_cb_t *cb) { + timex_t now; + vtimer_now(&now); printf("Send_ISS: %lu\nSend_UNA: %lu\nSend_NXT: %lu\nSend_WND: %u\n", cb->send_iss, cb->send_una, cb->send_nxt, cb->send_wnd); printf("Rcv_IRS: %lu\nRcv_NXT: %lu\nRcv_WND: %u\n", cb->rcv_irs, cb->rcv_nxt, cb->rcv_wnd); - printf("Time difference: %lu, No_of_retries: %u, State: %u\n\n", timex_sub(vtimer_now(), cb->last_packet_time).microseconds, cb->no_of_retries, cb->state); + printf("Time difference: %lu, No_of_retries: %u, State: %u\n\n", timex_sub(now, cb->last_packet_time).microseconds, cb->no_of_retries, cb->state); } void print_tcp_status(int in_or_out, ipv6_hdr_t *ipv6_header, tcp_hdr_t *tcp_header, socket_t *tcp_socket) @@ -497,7 +499,9 @@ int connect(int socket, sockaddr6_t *addr, uint32_t addrlen) set_tcp_cb(¤t_tcp_socket->tcp_control, 0, STATIC_WINDOW, current_tcp_socket->tcp_control.send_iss, current_tcp_socket->tcp_control.send_iss, 0); // Remember current time - current_tcp_socket->tcp_control.last_packet_time = vtimer_now(); + timex_t now; + vtimer_now(&now); + current_tcp_socket->tcp_control.last_packet_time = now; current_tcp_socket->tcp_control.no_of_retries = 0; msg_from_server.type = TCP_RETRY; @@ -554,7 +558,9 @@ int connect(int socket, sockaddr6_t *addr, uint32_t addrlen) msg_from_server.type = UNDEFINED; // Remember current time - current_tcp_socket->tcp_control.last_packet_time = vtimer_now(); + timex_t now; + vtimer_now(&now) + current_tcp_socket->tcp_control.last_packet_time = now; current_tcp_socket->tcp_control.no_of_retries = 0; #ifdef TCP_HC @@ -1113,7 +1119,9 @@ int handle_new_tcp_connection(socket_internal_t *current_queued_int_socket, sock &server_socket->socket_values.tcp_control.tcp_context.context_id, sizeof(server_socket->socket_values.tcp_control.tcp_context.context_id)); #endif // Remember current time - current_queued_int_socket->socket_values.tcp_control.last_packet_time = vtimer_now(); + timex_t now; + vtimer_now(&now); + current_queued_int_socket->socket_values.tcp_control.last_packet_time = now; current_queued_int_socket->socket_values.tcp_control.no_of_retries = 0; diff --git a/sys/net/destiny/tcp_timer.c b/sys/net/destiny/tcp_timer.c index 983a11ec70..986017764b 100644 --- a/sys/net/destiny/tcp_timer.c +++ b/sys/net/destiny/tcp_timer.c @@ -23,8 +23,10 @@ void handle_synchro_timeout(socket_internal_t *current_socket) msg_t send; if (thread_getstatus(current_socket->recv_pid) == STATUS_RECEIVE_BLOCKED) { + timex_t now; + vtimer_now(&now); if ((current_socket->socket_values.tcp_control.no_of_retries == 0) && - (timex_sub(vtimer_now(), current_socket->socket_values.tcp_control.last_packet_time).microseconds > + (timex_sub(now, current_socket->socket_values.tcp_control.last_packet_time).microseconds > TCP_SYN_INITIAL_TIMEOUT)) { current_socket->socket_values.tcp_control.no_of_retries++; @@ -32,7 +34,7 @@ void handle_synchro_timeout(socket_internal_t *current_socket) // printf("FIRST RETRY!\n"); } else if ((current_socket->socket_values.tcp_control.no_of_retries > 0) && - (timex_sub(vtimer_now(), current_socket->socket_values.tcp_control.last_packet_time).microseconds > + (timex_sub(now, current_socket->socket_values.tcp_control.last_packet_time).microseconds > (current_socket->socket_values.tcp_control.no_of_retries * TCP_SYN_TIMEOUT + TCP_SYN_INITIAL_TIMEOUT))) { current_socket->socket_values.tcp_control.no_of_retries++; @@ -66,20 +68,22 @@ void handle_established(socket_internal_t *current_socket) { current_timeout *= 2; } + timex_t now; + vtimer_now(&now); if (current_timeout > TCP_ACK_MAX_TIMEOUT) { net_msg_send(&send, current_socket->send_pid, 0, TCP_TIMEOUT); // printf("GOT NO ACK: TIMEOUT!\n"); } - else if (timex_sub(vtimer_now(), current_socket->socket_values.tcp_control.last_packet_time).microseconds > + else if (timex_sub(now, current_socket->socket_values.tcp_control.last_packet_time).microseconds > current_timeout) { // printReasBuffers(); current_socket->socket_values.tcp_control.no_of_retries++; net_msg_send(&send, current_socket->send_pid, 0, TCP_RETRY); // printf("GOT NO ACK YET, %i. RETRY! Now: %lu Before: %lu, Diff: %lu, Cur Timeout: %f\n", current_socket->socket_values.tcp_control.no_of_retries, -// vtimer_now().microseconds, current_socket->socket_values.tcp_control.last_packet_time.microseconds, -// vtimer_now().microseconds - current_socket->socket_values.tcp_control.last_packet_time.microseconds, +// now.microseconds, current_socket->socket_values.tcp_control.last_packet_time.microseconds, +// now.microseconds - current_socket->socket_values.tcp_control.last_packet_time.microseconds, // current_timeout); } } diff --git a/sys/net/sixlowpan/sixlowip.c b/sys/net/sixlowpan/sixlowip.c index a0dd1e0d41..588d3c0577 100644 --- a/sys/net/sixlowpan/sixlowip.c +++ b/sys/net/sixlowpan/sixlowip.c @@ -211,7 +211,8 @@ void ipv6_iface_add_addr(ipv6_addr_t *addr, uint8_t state, uint32_t val_ltime, u iface.addr_list[iface_addr_list_count].state = state; timex_t valtime = {val_ltime, 0}; timex_t preftime = {pref_ltime, 0}; - timex_t now = vtimer_now(); + timex_t now; + vtimer_now(&now); iface.addr_list[iface_addr_list_count].val_ltime = timex_add(now, valtime); iface.addr_list[iface_addr_list_count].pref_ltime = timex_add(now, preftime); iface.addr_list[iface_addr_list_count].type = type; @@ -451,7 +452,8 @@ uint8_t ipv6_next_hdr_unknown(uint8_t next_hdr) { uint32_t get_remaining_time(timex_t *t){ - timex_t now = vtimer_now(); + timex_t now; + vtimer_now(&now); return (timex_sub(*t, now).seconds); } @@ -459,7 +461,9 @@ uint32_t get_remaining_time(timex_t *t){ void set_remaining_time(timex_t *t, uint32_t time){ timex_t tmp = {time, 0}; - *t = timex_add(vtimer_now(), tmp); + timex_t now; + vtimer_now(&now) + *t = timex_add(now, tmp); } void ipv6_init_iface_as_router(void) { diff --git a/sys/net/sixlowpan/sixlownd.c b/sys/net/sixlowpan/sixlownd.c index 4cf52ff3f6..f3865cdb64 100644 --- a/sys/net/sixlowpan/sixlownd.c +++ b/sys/net/sixlowpan/sixlownd.c @@ -1154,7 +1154,8 @@ void def_rtr_lst_add(ipv6_addr_t *ipaddr, uint32_t rtr_ltime){ } else { memcpy(&(def_rtr_lst[def_rtr_count].addr), ipaddr, 16); timex_t rltime = {rtr_ltime, 0}; - timex_t now = vtimer_now(); + timex_t now; + vtimer_now(&now); def_rtr_lst[def_rtr_count].inval_time = timex_add(now, rltime); diff --git a/sys/net/sixlowpan/sixlowpan.c b/sys/net/sixlowpan/sixlowpan.c index abb635cdfa..444bc1c4ca 100644 --- a/sys/net/sixlowpan/sixlowpan.c +++ b/sys/net/sixlowpan/sixlowpan.c @@ -298,7 +298,10 @@ lowpan_reas_buf_t *new_packet_buffer(uint16_t datagram_size, uint16_t datagram_t new_buf->ident_no = datagram_tag; new_buf->packet_size = datagram_size; - new_buf->timestamp = vtimer_now().microseconds; + + timex_t now; + vtimer_now(&now) + new_buf->timestamp = now.microseconds; if ((current_buf == NULL) && (temp_buf == NULL)) { @@ -334,7 +337,9 @@ lowpan_reas_buf_t *get_packet_frag_buf(uint16_t datagram_size, uint16_t datagram current_buf->interval_list_head != NULL) { /* Found buffer for current packet fragment */ - current_buf->timestamp = vtimer_now().microseconds; + timex_t now; + vtimer_now(&now); + current_buf->timestamp = now.microseconds; return current_buf; } temp_buf = current_buf; @@ -526,7 +531,9 @@ void check_timeout(void) long cur_time; int count = 0; - cur_time = vtimer_now().microseconds; + timex_t now; + vtimer_now(&now) + cur_time = now.microseconds; temp_buf = head; while (temp_buf != NULL) diff --git a/sys/ping/ping.c b/sys/ping/ping.c index fecc71f65f..62d23ac2b8 100644 --- a/sys/ping/ping.c +++ b/sys/ping/ping.c @@ -49,7 +49,7 @@ void ping(radio_address_t addr, uint8_t channr){ cc1100_set_channel(channr); cc1100_set_address(r_address); while(1){ - start = vtimer_now(); + vtimer_now(&start); int trans_ok = cc1100_send_csmaca(addr, protocol_id,2,pipa->payload,sizeof(pipa->payload)); if(trans_ok < 0) @@ -59,7 +59,8 @@ void ping(radio_address_t addr, uint8_t channr){ } void calc_rtt(void){ - timex_t end = vtimer_now(); + timex_t end; + vtimer_now(&end); timex_t result = vtimer_sub(end, start); rtt = result.seconds+(float)result.microseconds/100000; diff --git a/sys/vtimer/vtimer.c b/sys/vtimer/vtimer.c index a8999f16d6..eb0bb9016a 100644 --- a/sys/vtimer/vtimer.c +++ b/sys/vtimer/vtimer.c @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -146,7 +147,9 @@ void normalize_to_tick(timex_t *time) { static int vtimer_set(vtimer_t *timer) { DEBUG("vtimer_set(): New timer. Offset: %lu %lu\n", timer->absolute.seconds, timer->absolute.microseconds); - timer->absolute = timex_add(vtimer_now(), timer->absolute); + timex_t now; + vtimer_now(&now); + timer->absolute = timex_add(now, timer->absolute); normalize_to_tick(&(timer->absolute)); DEBUG("vtimer_set(): Absolute: %lu %lu\n", timer->absolute.seconds, timer->absolute.microseconds); @@ -184,10 +187,9 @@ static int vtimer_set(vtimer_t *timer) { return result; } -/* TODO: Do NOT return a struct! */ -timex_t vtimer_now() { +void vtimer_now(timex_t* out) { timex_t t = timex_set(seconds, hwtimer_now()-longterm_tick_start); - return t; + memcpy(out, &t, sizeof(timex_t)); } int vtimer_init() { From 9a3c0ab6ec98b43ae70dbb333ef08e4ccadcccc0 Mon Sep 17 00:00:00 2001 From: Christian Mehlis Date: Thu, 13 Jun 2013 10:54:22 +0200 Subject: [PATCH 11/13] add missing & --- drivers/cc110x/cc1100-csmaca-mac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/cc110x/cc1100-csmaca-mac.c b/drivers/cc110x/cc1100-csmaca-mac.c index eb492e7909..01822a7cb0 100644 --- a/drivers/cc110x/cc1100-csmaca-mac.c +++ b/drivers/cc110x/cc1100-csmaca-mac.c @@ -121,7 +121,7 @@ int cc1100_send_csmaca(radio_address_t address, protocol_t protocol, int priorit collision_state = COLLISION_STATE_KEEP; } else if (collisions_per_sec > 2.2) { timex_t now; - vtimer_now(now); + vtimer_now(&now); collision_measurement_start = now.microseconds; collision_state = COLLISION_STATE_KEEP; } else { From cad585e9ddb3a488f6ed81a3671d97cf8e940c66 Mon Sep 17 00:00:00 2001 From: Ludwig Ortmann Date: Thu, 13 Jun 2013 18:14:21 +0200 Subject: [PATCH 12/13] remove context switch in native lpm_sleep quick fix for now --- cpu/native/lpm_cpu.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/cpu/native/lpm_cpu.c b/cpu/native/lpm_cpu.c index 45a5e01bc3..0c70de9169 100644 --- a/cpu/native/lpm_cpu.c +++ b/cpu/native/lpm_cpu.c @@ -22,6 +22,7 @@ #include #include #endif +#include #include "lpm.h" #include "debug.h" @@ -46,21 +47,15 @@ void _native_lpm_sleep() retval = select(1, &_native_uart_rfds, NULL, NULL, NULL); DEBUG("_native_lpm_sleep: retval: %i\n", retval); if (retval != -1) { - /* uart ready, swap to ISR context and handle input */ - makecontext(_native_isr_ctx, _native_handle_uart0_input, 0); - swapcontext((ucontext_t*)(active_thread->sp), _native_isr_ctx); + /* uart ready, handle input */ + /* TODO: switch to ISR context */ + _native_handle_uart0_input(); } - else if ((retval == -1) && (errno == EINTR)) { - /* TODO: reevaluate and merge with above branch - * IF any thread except the idle thread uses lpm_set this could make sense... */ - /* select interrupted by signal swap to ISR context and handle input */ - DEBUG("\n\n\t\treturn from interrupted syscall, swapping context and calling _native_handle_uart0_input\n\n"); - makecontext(_native_isr_ctx, _native_handle_uart0_input, 0); - swapcontext(_native_cur_ctx, _native_isr_ctx); - } - else { + else if (errno != EINTR) { + /* select failed for reason other than signal */ err(1, "lpm_set(): select()"); } + /* otherwise select was interrupted because of a signal, continue below */ #else pause(); #endif From 57e70a659ca53a7f3b0435776a0736fa65f3c3f5 Mon Sep 17 00:00:00 2001 From: Christian Mehlis Date: Thu, 13 Jun 2013 21:31:08 +0200 Subject: [PATCH 13/13] Remove undefined variables from Makefiles The following variables are included in various Makefiles but never defined. $(BOARDINCLUDE) $(PROJECTINCLUDE) $(CPUINCLUDE) --- Makefile.base | 4 ++-- Makefile.include | 2 +- cpu/lpc214x/Makefile | 4 ++-- sys/shell/Makefile | 4 ++-- sys/shell/commands/Makefile | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Makefile.base b/Makefile.base index 27b51d8497..a05d65d1c2 100644 --- a/Makefile.base +++ b/Makefile.base @@ -18,8 +18,8 @@ $(BINDIR)$(MODULE).a: $(OBJ) $(ASMOBJ) # compile and generate dependency info $(BINDIR)%.o: %.c - @$(CC) $(CFLAGS) $(PROJECTINCLUDE) $(BOARDINCLUDE) $(INCLUDES) -c $*.c -o $(BINDIR)$*.o - @$(CC) $(CFLAGS) $(PROJECTINCLUDE) $(BOARDINCLUDE) $(INCLUDES) -MM $*.c > $(BINDIR)$*.d + @$(CC) $(CFLAGS) $(INCLUDES) -c $*.c -o $(BINDIR)$*.o + @$(CC) $(CFLAGS) $(INCLUDES) -MM $*.c > $(BINDIR)$*.d @printf "$(BINDIR)"|cat - $(BINDIR)$*.d > /tmp/riot_out && mv /tmp/riot_out $(BINDIR)$*.d $(BINDIR)%.o: %.s diff --git a/Makefile.include b/Makefile.include index 6f6b4171de..939a4c8494 100644 --- a/Makefile.include +++ b/Makefile.include @@ -70,7 +70,7 @@ ${PROJBINDIR}/$(PROJECT).a: $(OBJ) ${PROJBINDIR}/%.o: %.c @echo; echo "Compiling.... $*.c"; echo - $(CC) $(CFLAGS) $(BOARDINCLUDE) $(INCLUDES) -c $*.c -o bin/$*.o + $(CC) $(CFLAGS) $(INCLUDES) -c $*.c -o bin/$*.o clean: $(MAKE) -C $(RIOTBOARD) clean diff --git a/cpu/lpc214x/Makefile b/cpu/lpc214x/Makefile index fd9c47f8e6..a281d08a00 100644 --- a/cpu/lpc214x/Makefile +++ b/cpu/lpc214x/Makefile @@ -19,8 +19,8 @@ endif # compile and generate dependency info ../bin/%.o: %.c - $(CC) $(CFLAGS) $(INCLUDES) $(BOARDINCLUDE) $(PROJECTINCLUDE) $(CPUINCLUDE) -c $*.c -o ../bin/$*.o - $(CC) $(CFLAGS) $(INCLUDES) $(BOARDINCLUDE) $(PROJECTINCLUDE) $(CPUINCLUDE) -MM $*.c > ../bin/$*.d + $(CC) $(CFLAGS) $(INCLUDES) $(CPUINCLUDE) -c $*.c -o ../bin/$*.o + $(CC) $(CFLAGS) $(INCLUDES) $(CPUINCLUDE) -MM $*.c > ../bin/$*.d @printf "../bin/"|cat - ../bin/$*.d > /tmp/fw_out && mv /tmp/fw_out ../bin/$*.d # remove compilation products diff --git a/sys/shell/Makefile b/sys/shell/Makefile index 3b88abc0d6..9d889dbf40 100644 --- a/sys/shell/Makefile +++ b/sys/shell/Makefile @@ -13,8 +13,8 @@ $(BINDIR)$(MODULE).a: $(OBJ) # compile and generate dependency info $(BINDIR)%.o: %.c - $(CC) $(CFLAGS) $(PROJECTINCLUDE) $(BOARDINCLUDE) $(INCLUDES) -c $*.c -o $(BINDIR)$*.o - $(CC) $(CFLAGS) $(PROJECTINCLUDE) $(BOARDINCLUDE) $(INCLUDES) -MM $*.c > $(BINDIR)$*.d + $(CC) $(CFLAGS) $(INCLUDES) -c $*.c -o $(BINDIR)$*.o + $(CC) $(CFLAGS) $(INCLUDES) -MM $*.c > $(BINDIR)$*.d @printf "$(BINDIR)"|cat - $(BINDIR)$*.d > /tmp/riot_out && mv /tmp/riot_out $(BINDIR)$*.d # remove compilation products diff --git a/sys/shell/commands/Makefile b/sys/shell/commands/Makefile index c14ee9bcef..8fc4103d22 100644 --- a/sys/shell/commands/Makefile +++ b/sys/shell/commands/Makefile @@ -38,8 +38,8 @@ $(BINDIR)$(MODULE).a: $(OBJ) # compile and generate dependency info $(BINDIR)%.o: %.c - $(CC) $(CFLAGS) $(PROJECTINCLUDE) $(BOARDINCLUDE) $(INCLUDES) -c $*.c -o $(BINDIR)$*.o - $(CC) $(CFLAGS) $(PROJECTINCLUDE) $(BOARDINCLUDE) $(INCLUDES) -MM $*.c > $(BINDIR)$*.d + $(CC) $(CFLAGS) $(INCLUDES) -c $*.c -o $(BINDIR)$*.o + $(CC) $(CFLAGS) $(INCLUDES) -MM $*.c > $(BINDIR)$*.d @printf "$(BINDIR)"|cat - $(BINDIR)$*.d > /tmp/riot_out && mv /tmp/riot_out $(BINDIR)$*.d # remove compilation products