Provide boot sequence hooks (Native)

This commit is contained in:
George Oikonomou 2017-10-15 18:01:18 +01:00 committed by George Oikonomou
parent 5d95f8bd54
commit 3a1d362549
4 changed files with 45 additions and 41 deletions

View File

@ -9,7 +9,7 @@ endif
CONTIKI_TARGET_DIRS = . dev CONTIKI_TARGET_DIRS = . dev
CONTIKI_TARGET_MAIN = ${addprefix $(OBJECTDIR)/,contiki-main.o} CONTIKI_TARGET_MAIN = ${addprefix $(OBJECTDIR)/,contiki-main.o}
CONTIKI_TARGET_SOURCEFILES = contiki-main.c clock.c leds.c leds-arch.c \ CONTIKI_TARGET_SOURCEFILES = platform.c clock.c leds.c leds-arch.c \
button-sensor.c pir-sensor.c vib-sensor.c xmem.c \ button-sensor.c pir-sensor.c vib-sensor.c xmem.c \
sensors.c irq.c cfs-posix.c cfs-posix-dir.c sensors.c irq.c cfs-posix.c cfs-posix-dir.c

View File

@ -68,3 +68,10 @@ clock_delay(unsigned int d)
/* Does not do anything. */ /* Does not do anything. */
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void
clock_init(void)
{
/* Provide this function, required by main() */
return;
}
/*---------------------------------------------------------------------------*/

View File

@ -99,4 +99,7 @@ typedef unsigned long clock_time_t;
/* Not part of C99 but actually present */ /* Not part of C99 but actually present */
int strcasecmp(const char*, const char*); int strcasecmp(const char*, const char*);
#define PLATFORM_CONF_PROVIDES_MAIN_LOOP 1
#define PLATFORM_CONF_MAIN_ACCEPTS_ARGS 1
#endif /* CONTIKI_CONF_H_ */ #endif /* CONTIKI_CONF_H_ */

View File

@ -164,7 +164,7 @@ set_lladdr(void)
} }
#endif #endif
linkaddr_set_node_addr(&addr); linkaddr_set_node_addr(&addr);
printf("Contiki started with address "); printf("Contiki starting with address ");
for(i = 0; i < sizeof(addr.u8) - 1; i++) { for(i = 0; i < sizeof(addr.u8) - 1; i++) {
printf("%d.", addr.u8[i]); printf("%d.", addr.u8[i]);
} }
@ -210,20 +210,10 @@ set_global_address(void)
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
int contiki_argc = 0; int contiki_argc = 0;
char **contiki_argv; char **contiki_argv;
/*---------------------------------------------------------------------------*/
int void
main(int argc, char **argv) platform_process_args(int argc, char**argv)
{ {
#if NETSTACK_CONF_WITH_IPV6
#if UIP_CONF_IPV6_RPL
printf(CONTIKI_VERSION_STRING " started with IPV6, RPL\n");
#else
printf(CONTIKI_VERSION_STRING " started with IPV6\n");
#endif
#else
printf(CONTIKI_VERSION_STRING " started\n");
#endif
/* crappy way of remembering and accessing argc/v */ /* crappy way of remembering and accessing argc/v */
contiki_argc = argc; contiki_argc = argc;
contiki_argv = argv; contiki_argv = argv;
@ -239,23 +229,34 @@ main(int argc, char **argv)
contiki_argv++; contiki_argv++;
#endif #endif
#endif #endif
}
process_init(); /*---------------------------------------------------------------------------*/
process_start(&etimer_process, NULL); void
ctimer_init(); platform_init_stage_one()
rtimer_init(); {
#if NETSTACK_CONF_WITH_IPV6
#if UIP_CONF_IPV6_RPL
printf(CONTIKI_VERSION_STRING " starting with IPV6, RPL\n");
#else
printf(CONTIKI_VERSION_STRING " starting with IPV6\n");
#endif
#else
printf(CONTIKI_VERSION_STRING " starting\n");
#endif
}
/*---------------------------------------------------------------------------*/
void
platform_init_stage_two()
{
set_lladdr(); set_lladdr();
}
netstack_init(); /*---------------------------------------------------------------------------*/
void
platform_init_stage_three()
{
printf("MAC %s NETWORK %s\n", NETSTACK_MAC.name, NETSTACK_NETWORK.name); printf("MAC %s NETWORK %s\n", NETSTACK_MAC.name, NETSTACK_NETWORK.name);
#if NETSTACK_CONF_WITH_IPV6 #if NETSTACK_CONF_WITH_IPV6
queuebuf_init();
memcpy(&uip_lladdr.addr, serial_id, sizeof(uip_lladdr.addr));
process_start(&tcpip_process, NULL);
#ifdef __CYGWIN__ #ifdef __CYGWIN__
process_start(&wpcap_process, NULL); process_start(&wpcap_process, NULL);
#endif #endif
@ -279,20 +280,13 @@ main(int argc, char **argv)
#endif /* NETSTACK_CONF_WITH_IPV6 */ #endif /* NETSTACK_CONF_WITH_IPV6 */
serial_line_init();
#if BUILD_WITH_ORCHESTRA
orchestra_init();
#endif /* BUILD_WITH_ORCHESTRA */
#if BUILD_WITH_SHELL
serial_shell_init();
#endif /* BUILD_WITH_SHELL */
autostart_start(autostart_processes);
/* Make standard output unbuffered. */ /* Make standard output unbuffered. */
setvbuf(stdout, (char *)NULL, _IONBF, 0); setvbuf(stdout, (char *)NULL, _IONBF, 0);
}
/*---------------------------------------------------------------------------*/
void
platform_main_loop()
{
select_set_callback(STDIN_FILENO, &stdin_fd); select_set_callback(STDIN_FILENO, &stdin_fd);
while(1) { while(1) {
fd_set fdr; fd_set fdr;
@ -333,7 +327,7 @@ main(int argc, char **argv)
etimer_request_poll(); etimer_request_poll();
} }
return 0; return;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void void