Contiki-Inga 3.x
contiki-main.c
1 /*
2  * Copyright (c) 2006, Technical University of Munich
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the Institute nor the names of its contributors
14  * may be used to endorse or promote products derived from this software
15  * without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  * This file is part of the Contiki operating system.
30  *
31  */
32 #define PRINTF(FORMAT,args...) printf_P(PSTR(FORMAT),##args)
33 
34 #define ANNOUNCE_BOOT 1 //adds about 600 bytes to program size
35 #if ANNOUNCE_BOOT
36 #define PRINTA(FORMAT,args...) printf_P(PSTR(FORMAT),##args)
37 #else
38 #define PRINTA(...)
39 #endif
40 
41 #ifndef DEBUG
42 #define DEBUG 0
43 #endif
44 #if DEBUG
45 #define PRINTD(FORMAT,args...) printf_P(PSTR(FORMAT),##args)
46 #else
47 #define PRINTD(...)
48 #endif
49 
50 #include <avr/pgmspace.h>
51 #include <avr/fuse.h>
52 #include <avr/eeprom.h>
53 #include <stdio.h>
54 #include <string.h>
55 #include <dev/watchdog.h>
56 
57 #include "loader/symbols-def.h"
58 #include "loader/symtab.h"
59 
60 #include "params.h"
61 #include "radio/rf230bb/rf230bb.h"
62 #include "net/mac/frame802154.h"
63 #include "net/mac/framer-802154.h"
64 #include "net/ipv6/sicslowpan.h"
65 
66 #include "contiki.h"
67 #include "contiki-net.h"
68 #include "contiki-lib.h"
69 
70 #include "dev/rs232.h"
71 #include "dev/serial-line.h"
72 #include "dev/slip.h"
73 
74 #ifdef RAVEN_LCD_INTERFACE
75 #include "raven-lcd.h"
76 #endif
77 
78 #if AVR_WEBSERVER
79 #include "httpd-fs.h"
80 #include "httpd-cgi.h"
81 #endif
82 
83 #ifdef COFFEE_FILES
84 #include "cfs/cfs.h"
85 #include "cfs/cfs-coffee.h"
86 #endif
87 
88 #if UIP_CONF_ROUTER&&0
89 #include "net/routing/rimeroute.h"
90 #include "net/rime/rime-udp.h"
91 #endif
92 
93 #include "net/rime/rime.h"
94 
95 /* Track interrupt flow through mac, rdc and radio driver */
96 //#define DEBUGFLOWSIZE 32
97 #if DEBUGFLOWSIZE
98 uint8_t debugflowsize,debugflow[DEBUGFLOWSIZE];
99 #define DEBUGFLOW(c) if (debugflowsize<(DEBUGFLOWSIZE-1)) debugflow[debugflowsize++]=c
100 #else
101 #define DEBUGFLOW(c)
102 #endif
103 
104 /* Get periodic prints from idle loop, from clock seconds or rtimer interrupts */
105 /* Use of rtimer will conflict with other rtimer interrupts such as contikimac radio cycling */
106 /* STAMPS will print ENERGEST outputs if that is enabled. */
107 #define PERIODICPRINTS 1
108 #if PERIODICPRINTS
109 //#define PINGS 64
110 #define ROUTES 600
111 #define STAMPS 60
112 #define STACKMONITOR 1024
113 uint32_t clocktime;
114 #define TESTRTIMER 0
115 #if TESTRTIMER
116 uint8_t rtimerflag=1;
117 struct rtimer rt;
118 void rtimercycle(void) {rtimerflag=1;}
119 #endif
120 #endif
121 /* node_id is used in Cooja to generate a unique EUI mac address for each instance.
122  * Cooja plants the mote number in node_id on startup, but if the variable is in RAM
123  * gcc will clear it during the later .bss initialization. Cooja can repeatedly
124  * rewrite node_id, e.g. every 62 usec for the first 62 msec of runtime.
125  * But putting it in EEMEM avoids the need for that.
126  */
127 #define NODE_ID 1
128 #if NODE_ID
129 //EEMEM uint16_t eemem_node_id;
130 uint16_t node_id;
131 #endif
132 uint16_t ledtimer;
133 
134 /*-------------------------------------------------------------------------*/
135 /*----------------------Configuration of the .elf file---------------------*/
136 #if 1
137 /* The proper way to set the signature is */
138 #include <avr/signature.h>
139 #else
140 /* Older avr-gcc's may not define the needed SIGNATURE bytes. Do it manually if you get an error */
141 typedef struct {const unsigned char B2;const unsigned char B1;const unsigned char B0;} __signature_t;
142 #define SIGNATURE __signature_t __signature __attribute__((section (".signature")))
143 SIGNATURE = {
144  .B2 = 0x01,//SIGNATURE_2, //ATMEGA128rfa1
145  .B1 = 0xA7,//SIGNATURE_1, //128KB flash
146  .B0 = 0x1E,//SIGNATURE_0, //Atmel
147 };
148 #endif
149 
150 #if 1
151 /* JTAG, SPI enabled, Internal RC osc, Boot flash size 4K, 6CK+65msec delay, brownout disabled */
152 FUSES ={.low = 0xe2, .high = 0x99, .extended = 0xff,};
153 #else
154 /* JTAG+SPI, Boot 4096 words @ $F000, Internal oscillator, startup 6 CK +0 ms, Brownout 1.8 volts */
155 FUSES ={.low = 0xC2, .high = 0x99, .extended = 0xfe,};
156 #endif
157 
158 uint8_t
159 rng_get_uint8(void) {
160 #if 1
161  /* Upper two RSSI reg bits (RND_VALUE) are random in rf231 */
162  uint8_t j;
163  j = (PHY_RSSI&0xc0) + ((PHY_RSSI>>2)&0x30) + ((PHY_RSSI>>4)&0x0c) + ((PHY_RSSI>>6)&0x03);
164 #else
165 /* Get a pseudo random number using the ADC */
166  uint8_t i,j;
167  ADCSRA=1<<ADEN; //Enable ADC, not free running, interrupt disabled, fastest clock
168  for (i=0;i<4;i++) {
169  ADMUX = 0; //toggle reference to increase noise
170  ADMUX =0x1E; //Select AREF as reference, measure 1.1 volt bandgap reference.
171  ADCSRA|=1<<ADSC; //Start conversion
172  while (ADCSRA&(1<<ADSC)); //Wait till done
173  j = (j<<2) + ADC;
174  }
175  ADCSRA=0; //Disable ADC
176 #endif
177  PRINTD("rng issues %d\n",j);
178  return j;
179 }
180 
181 /*-------------------------Low level initialization------------------------*/
182 /*------Done in a subroutine to keep main routine stack usage small--------*/
183 void initialize(void)
184 {
185  watchdog_init();
186  watchdog_start();
187 
188 /* The Raven implements a serial command and data interface via uart0 to a 3290p,
189  * which could be duplicated using another host computer.
190  */
191 #if !RF230BB_CONF_LEDONPORTE1 //Conflicts with USART0
192 #ifdef RAVEN_LCD_INTERFACE
193  rs232_init(RS232_PORT_0, USART_BAUD_38400,USART_PARITY_NONE | USART_STOP_BITS_1 | USART_DATA_BITS_8);
194  rs232_set_input(0,raven_lcd_serial_input);
195 #else
196  /* Generic or slip connection on uart0 */
197  rs232_init(RS232_PORT_0, USART_BAUD_38400,USART_PARITY_NONE | USART_STOP_BITS_1 | USART_DATA_BITS_8);
198 #endif
199 #endif
200 
201  /* Second rs232 port for debugging or slip alternative */
202  rs232_init(RS232_PORT_1, USART_BAUD_57600,USART_PARITY_NONE | USART_STOP_BITS_1 | USART_DATA_BITS_8);
203  /* Redirect stdout */
204 #if RF230BB_CONF_LEDONPORTE1 || defined(RAVEN_LCD_INTERFACE)
205  rs232_redirect_stdout(RS232_PORT_1);
206 #else
207  rs232_redirect_stdout(RS232_PORT_0);
208 #endif
209  clock_init();
210 
211  if(MCUSR & (1<<PORF )) PRINTD("Power-on reset.\n");
212  if(MCUSR & (1<<EXTRF)) PRINTD("External reset!\n");
213  if(MCUSR & (1<<BORF )) PRINTD("Brownout reset!\n");
214  if(MCUSR & (1<<WDRF )) PRINTD("Watchdog reset!\n");
215  if(MCUSR & (1<<JTRF )) PRINTD("JTAG reset!\n");
216 
217 #if STACKMONITOR
218  /* Simple stack pointer highwater monitor. Checks for magic numbers in the main
219  * loop. In conjuction with PERIODICPRINTS, never-used stack will be printed
220  * every STACKMONITOR seconds.
221  */
222 {
223 extern uint16_t __bss_end;
224 uint16_t p=(uint16_t)&__bss_end;
225  do {
226  *(uint16_t *)p = 0x4242;
227  p+=10;
228  } while (p<SP-10); //don't overwrite our own stack
229 }
230 #endif
231 
232 #define CONF_CALIBRATE_OSCCAL 0
233 #if CONF_CALIBRATE_OSCCAL
234 void calibrate_rc_osc_32k();
235 {
236 extern uint8_t osccal_calibrated;
237 uint8_t i;
238  PRINTD("\nBefore calibration OSCCAL=%x\n",OSCCAL);
239  for (i=0;i<10;i++) {
241  PRINTD("Calibrated=%x\n",osccal_calibrated);
242 //#include <util/delay_basic.h>
243 //#define delay_us( us ) ( _delay_loop_2(1+(us*F_CPU)/4000000UL) )
244 // delay_us(50000);
245  }
246  clock_init();
247 }
248 #endif
249 
250  PRINTA("\n*******Booting %s*******\n",CONTIKI_VERSION_STRING);
251 
252 /* rtimers needed for radio cycling */
253  rtimer_init();
254 
255  /* Initialize process subsystem */
256  process_init();
257 
258  /* etimers must be started before ctimer_init */
259  process_start(&etimer_process, NULL);
260  ctimer_init();
261 
262  /* Start radio and radio receive process */
263  NETSTACK_RADIO.init();
264 
265 /* Get a random seed for the 802.15.4 packet sequence number.
266  * Some layers will ignore duplicates found in a history (e.g. Contikimac)
267  * causing the initial packets to be ignored after a short-cycle restart.
268  */
269  random_init(rng_get_uint8());
270 
271  /* Set addresses BEFORE starting tcpip process */
272 
273  linkaddr_t addr;
274 
275  /* If eeprom is used for parameter retention, params_get_channel will check
276  * for integrity and reinitialize it from flash if it seems corrupted.
277  * It will then always return a valid channel
278  */
279  rf230_set_channel(params_get_channel());
280  rf230_set_txpower(params_get_txpower());
281  if (params_get_eui64(addr.u8)) {
282  PRINTA("Random EUI64 address generated\n");
283  }
284 
285 #if UIP_CONF_IPV6
286 #if NODE_ID
287  // {uint16_t node_id=eeprom_read_word(&eemem_node_id);
288  PRINTA("Initial node_id %u\n",node_id);
289  if (node_id) {
290  addr.u8[0]=0;
291  addr.u8[1]=0;
292  addr.u8[2]=0;
293  addr.u8[3]=node_id&0xff;
294  addr.u8[4]=(node_id&0xff)>>8;
295  addr.u8[5]=node_id;
296  addr.u8[6]=node_id;
297  addr.u8[7]=node_id;
298 }
299 #endif
300  // } else {
301  // node_id=addr.u8[7]+(addr.u8[6]<<8);
302  // }
303  memcpy(&uip_lladdr.addr, &addr.u8, sizeof(linkaddr_t));
304  linkaddr_set_node_addr(&addr);
305  rf230_set_pan_addr(params_get_panid(),params_get_panaddr(),(uint8_t *)&addr.u8);
306 #elif WITH_NODE_ID
307  node_id=get_panaddr_from_eeprom();
308  addr.u8[1]=node_id&0xff;
309  addr.u8[0]=(node_id&0xff00)>>8;
310  PRINTA("Node ID from eeprom: %X\n",node_id);
311  uint16_t inv_node_id=((node_id&0xff00)>>8)+((node_id&0xff)<<8); // change order of bytes for rf23x
312  linkaddr_set_node_addr(&addr);
313  rf230_set_pan_addr(params_get_panid(),inv_node_id,NULL);
314 #else
315  linkaddr_set_node_addr(&addr);
316  rf230_set_pan_addr(params_get_panid(),params_get_panaddr(),(uint8_t *)&addr.u8);
317 #endif
318  linkaddr_set_node_addr(&addr);
319 
320  rf230_set_pan_addr(params_get_panid(),params_get_panaddr(),(uint8_t *)&addr.u8);
321 
322 
323 #if UIP_CONF_IPV6
324  PRINTA("EUI-64 MAC: %x-%x-%x-%x-%x-%x-%x-%x\n",addr.u8[0],addr.u8[1],addr.u8[2],addr.u8[3],addr.u8[4],addr.u8[5],addr.u8[6],addr.u8[7]);
325 #else
326  PRINTA("MAC address ");
327  uint8_t i;
328  for (i=sizeof(linkaddr_t); i>0; i--){
329  PRINTA("%x:",addr.u8[i-1]);
330  }
331  PRINTA("\n");
332 #endif
333 
334  /* Initialize stack protocols */
335  queuebuf_init();
336  NETSTACK_RDC.init();
337  NETSTACK_MAC.init();
338  NETSTACK_NETWORK.init();
339 
340 #if ANNOUNCE_BOOT
341  PRINTA("%s %s, channel %u , check rate %u Hz tx power %u\n",NETSTACK_MAC.name, NETSTACK_RDC.name, rf230_get_channel(),
342  CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1:NETSTACK_RDC.channel_check_interval()),
343  rf230_get_txpower());
344 #if UIP_CONF_IPV6_RPL
345  PRINTA("RPL Enabled\n");
346 #endif
347 #if UIP_CONF_ROUTER
348  PRINTA("Routing Enabled\n");
349 #endif
350 
351 #endif /* ANNOUNCE_BOOT */
352 
353  process_start(&tcpip_process, NULL);
354 
355 #ifdef RAVEN_LCD_INTERFACE
356  process_start(&raven_lcd_process, NULL);
357 #endif
358 
359  /* Autostart other processes */
360  autostart_start(autostart_processes);
361 
362  /*---If using coffee file system create initial web content if necessary---*/
363 #if COFFEE_FILES
364  int fa = cfs_open( "/index.html", CFS_READ);
365  if (fa<0) { //Make some default web content
366  PRINTA("No index.html file found, creating upload.html!\n");
367  PRINTA("Formatting FLASH file system for coffee...");
369  PRINTA("Done!\n");
370  fa = cfs_open( "/index.html", CFS_WRITE);
371  int r = cfs_write(fa, &"It works!", 9);
372  if (r<0) PRINTA("Can''t create /index.html!\n");
373  cfs_close(fa);
374 // fa = cfs_open("upload.html"), CFW_WRITE);
375 // <html><body><form action="upload.html" enctype="multipart/form-data" method="post"><input name="userfile" type="file" size="50" /><input value="Upload" type="submit" /></form></body></html>
376  }
377 #endif /* COFFEE_FILES */
378 
379 /* Add addresses for testing */
380 #if 0
381 {
382  uip_ip6addr_t ipaddr;
383  uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 0);
384  uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF);
385 // uip_ds6_prefix_add(&ipaddr,64,0);
386 }
387 #endif
388 
389 /*--------------------------Announce the configuration---------------------*/
390 #if ANNOUNCE_BOOT
391 #if AVR_WEBSERVER
392 { uint8_t i;
393  char buf[80];
394  unsigned int size;
395 
396  for (i=0;i<UIP_DS6_ADDR_NB;i++) {
397  if (uip_ds6_if.addr_list[i].isused) {
398  httpd_cgi_sprint_ip6(uip_ds6_if.addr_list[i].ipaddr,buf);
399  PRINTA("IPv6 Address: %s\n",buf);
400  }
401  }
402  cli();
403  eeprom_read_block (buf,eemem_server_name, sizeof(eemem_server_name));
404  sei();
405  buf[sizeof(eemem_server_name)]=0;
406  PRINTA("%s",buf);
407  cli();
408  eeprom_read_block (buf,eemem_domain_name, sizeof(eemem_domain_name));
409  sei();
410  buf[sizeof(eemem_domain_name)]=0;
411  size=httpd_fs_get_size();
412 #ifndef COFFEE_FILES
413  PRINTA(".%s online with fixed %u byte web content\n",buf,size);
414 #elif COFFEE_FILES==1
415  PRINTA(".%s online with static %u byte EEPROM file system\n",buf,size);
416 #elif COFFEE_FILES==2
417  PRINTA(".%s online with dynamic %u KB EEPROM file system\n",buf,size>>10);
418 #elif COFFEE_FILES==3
419  PRINTA(".%s online with static %u byte program memory file system\n",buf,size);
420 #elif COFFEE_FILES==4
421  PRINTA(".%s online with dynamic %u KB program memory file system\n",buf,size>>10);
422 #endif /* COFFEE_FILES */
423 }
424 #else
425  PRINTA("Online\n");
426 #endif
427 #endif /* ANNOUNCE_BOOT */
428 
429 #if RF230BB_CONF_LEDONPORTE1
430  /* NB: PORTE1 conflicts with UART0 */
431  DDRE|=(1<<DDE1); //set led pin to output (Micheal Hatrtman board)
432  PORTE&=~(1<<PE1); //and low to turn led off
433 #endif
434 }
435 
436 #if ROUTES && UIP_CONF_IPV6
437 static void
438 ipaddr_add(const uip_ipaddr_t *addr)
439 {
440  uint16_t a;
441  int8_t i, f;
442  for(i = 0, f = 0; i < sizeof(uip_ipaddr_t); i += 2) {
443  a = (addr->u8[i] << 8) + addr->u8[i + 1];
444  if(a == 0 && f >= 0) {
445  if(f++ == 0) PRINTF("::");
446  } else {
447  if(f > 0) {
448  f = -1;
449  } else if(i > 0) {
450  PRINTF(":");
451  }
452  PRINTF("%x",a);
453  }
454  }
455 }
456 #endif
457 
458 /*-------------------------------------------------------------------------*/
459 /*------------------------- Main Scheduler loop----------------------------*/
460 /*-------------------------------------------------------------------------*/
461 int
462 main(void)
463 {
464 #if UIP_CONF_IPV6
465  uip_ds6_nbr_t *nbr;
466 #endif /* UIP_CONF_IPV6 */
467  initialize();
468 
469  while(1) {
470  process_run();
472 
473  /* Turn off LED after a while */
474  if (ledtimer) {
475  if (--ledtimer==0) {
476 #if RF230BB_CONF_LEDONPORTE1
477  PORTE&=~(1<<PE1);
478 #endif
479 #if defined(RAVEN_LCD_INTERFACE)&&0
480  /* ledtimer can be set by received ping; ping the other way for testing */
481  extern void raven_ping6(void);
482  raven_ping6();
483 #endif
484  }
485  }
486 
487 #if 0
488 /* Various entry points for debugging in the AVR Studio simulator.
489  * Set as next statement and step into the routine.
490  */
491  NETSTACK_RADIO.send(packetbuf_hdrptr(), 42);
492  process_poll(&rf230_process);
493  packetbuf_clear();
494  len = rf230_read(packetbuf_dataptr(), PACKETBUF_SIZE);
496  NETSTACK_RDC.input();
497 #endif
498 
499 #if 0
500 /* Clock.c can trigger a periodic PLL calibration in the RF230BB driver.
501  * This can show when that happens.
502  */
503  extern uint8_t rf230_calibrated;
504  if (rf230_calibrated) {
505  PRINTD("\nRF230 calibrated!\n");
506  rf230_calibrated=0;
507  }
508 #endif
509 
510 /* Set DEBUGFLOWSIZE in contiki-conf.h to track path through MAC, RDC, and RADIO */
511 #if DEBUGFLOWSIZE
512  if (debugflowsize) {
513  debugflow[debugflowsize]=0;
514  PRINTF("%s\n",debugflow);
515  debugflowsize=0;
516  }
517 #endif
518 
519 #if PERIODICPRINTS
520 #if TESTRTIMER
521 /* Timeout can be increased up to 8 seconds maximum.
522  * A one second cycle is convenient for triggering the various debug printouts.
523  * The triggers are staggered to avoid printing everything at once.
524  */
525  if (rtimerflag) {
526  rtimer_set(&rt, RTIMER_NOW()+ RTIMER_ARCH_SECOND*1UL, 1,(void *) rtimercycle, NULL);
527  rtimerflag=0;
528 #else
529  if (clocktime!=clock_seconds()) {
530  clocktime=clock_seconds();
531 #endif
532 
533 #if STAMPS
534 if ((clocktime%STAMPS)==0) {
535 #if ENERGEST_CONF_ON
536 #include "lib/print-stats.h"
537  print_stats();
538 #elif RADIOSTATS
539 extern volatile unsigned long radioontime;
540  PRINTF("%u(%u)s\n",clocktime,radioontime);
541 #else
542  PRINTF("%us\n",clocktime);
543 #endif
544 
545 }
546 #endif
547 #if TESTRTIMER
548  clocktime+=1;
549 #endif
550 
551 #if PINGS && UIP_CONF_IPV6
552 extern void raven_ping6(void);
553 if ((clocktime%PINGS)==1) {
554  PRINTF("**Ping\n");
555  raven_ping6();
556 }
557 #endif
558 
559 #if ROUTES && UIP_CONF_IPV6
560 if ((clocktime%ROUTES)==2) {
561 
562 extern uip_ds6_netif_t uip_ds6_if;
563 
564  uint8_t i,j;
565  PRINTF("\nAddresses [%u max]\n",UIP_DS6_ADDR_NB);
566  for (i=0;i<UIP_DS6_ADDR_NB;i++) {
567  if (uip_ds6_if.addr_list[i].isused) {
568  ipaddr_add(&uip_ds6_if.addr_list[i].ipaddr);
569  PRINTF("\n");
570  }
571  }
572  PRINTF("\nNeighbors [%u max]\n",NBR_TABLE_MAX_NEIGHBORS);
573 
574  for(nbr = nbr_table_head(ds6_neighbors);
575  nbr != NULL;
576  nbr = nbr_table_next(ds6_neighbors, nbr)) {
577  ipaddr_add(&nbr->ipaddr);
578  PRINTF("\n");
579  j=0;
580  }
581  if (j) PRINTF(" <none>");
582  PRINTF("\nRoutes [%u max]\n",UIP_DS6_ROUTE_NB);
583  {
584  uip_ds6_route_t *r;
585  PRINTF("\nRoutes [%u max]\n",UIP_DS6_ROUTE_NB);
586  j = 1;
587  for(r = uip_ds6_route_head();
588  r != NULL;
589  r = uip_ds6_route_next(r)) {
590  ipaddr_add(&r->ipaddr);
591  PRINTF("/%u (via ", r->length);
592  ipaddr_add(uip_ds6_route_nexthop(r));
593  PRINTF(") %lus\n", r->state.lifetime);
594  j = 0;
595  }
596  }
597  if (j) PRINTF(" <none>");
598  PRINTF("\n---------\n");
599 }
600 #endif
601 
602 #if STACKMONITOR
603 if ((clocktime%STACKMONITOR)==3) {
604  extern uint16_t __bss_end;
605  uint16_t p=(uint16_t)&__bss_end;
606  do {
607  if (*(uint16_t *)p != 0x4242) {
608  PRINTF("Never-used stack > %d bytes\n",p-(uint16_t)&__bss_end);
609  break;
610  }
611  p+=10;
612  } while (p<RAMEND-10);
613 }
614 #endif
615 
616  }
617 #endif /* PERIODICPRINTS */
618 
619 #if RF230BB&&0
620 extern uint8_t rf230processflag;
621  if (rf230processflag) {
622  PRINTF("rf230p%d",rf230processflag);
623  rf230processflag=0;
624  }
625 #endif
626 
627 #if RF230BB&&0
628 extern uint8_t rf230_interrupt_flag;
629  if (rf230_interrupt_flag) {
630  // if (rf230_interrupt_flag!=11) {
631  PRINTF("**RI%u",rf230_interrupt_flag);
632  // }
633  rf230_interrupt_flag=0;
634  }
635 #endif
636  }
637  return 0;
638 }
639 
640 /*---------------------------------------------------------------------------*/
641 
642 void log_message(char *m1, char *m2)
643 {
644  PRINTF("%s%s\n", m1, m2);
645 }