Added serial input from stdin, removed uIP initialization since uIP is not used anyway, made stdout unbuffered
This commit is contained in:
parent
b7ab95499f
commit
bd9230b4b3
1 changed files with 28 additions and 25 deletions
|
@ -29,22 +29,25 @@
|
|||
*
|
||||
* This file is part of the Contiki OS
|
||||
*
|
||||
* $Id: contiki-main.c,v 1.6 2007/11/28 12:54:42 adamdunkels Exp $
|
||||
* $Id: contiki-main.c,v 1.7 2008/01/08 08:08:57 adamdunkels Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/select.h>
|
||||
|
||||
#include "contiki.h"
|
||||
|
||||
#include "dev/serial.h"
|
||||
|
||||
#include "net/uip.h"
|
||||
|
||||
#include "dev/button-sensor.h"
|
||||
#include "dev/pir-sensor.h"
|
||||
#include "dev/vib-sensor.h"
|
||||
|
||||
PROCINIT(&etimer_process, &tcpip_process);
|
||||
PROCINIT(&etimer_process, &tcpip_process, &serial_process);
|
||||
|
||||
SENSORS(&pir_sensor, &vib_sensor, &button_sensor);
|
||||
|
||||
|
@ -52,54 +55,54 @@ SENSORS(&pir_sensor, &vib_sensor, &button_sensor);
|
|||
int
|
||||
main(void)
|
||||
{
|
||||
uip_ipaddr_t addr;
|
||||
|
||||
process_init();
|
||||
|
||||
procinit_init();
|
||||
|
||||
autostart_start((struct process **)autostart_processes);
|
||||
|
||||
/* Make standard output unbuffered. */
|
||||
setvbuf(stdout, (char *)NULL, _IONBF, 0);
|
||||
|
||||
uip_ipaddr(&addr, 192,168,2,2);
|
||||
uip_sethostaddr(&addr);
|
||||
|
||||
uip_ipaddr(&addr, 192,168,2,1);
|
||||
uip_setdraddr(&addr);
|
||||
|
||||
uip_ipaddr(&addr, 255,255,255,0);
|
||||
uip_setnetmask(&addr);
|
||||
|
||||
printf("Contiki initiated, now starting process scheduling\n");
|
||||
printf("Contiki started\n");
|
||||
|
||||
while(1) {
|
||||
fd_set fds;
|
||||
int n;
|
||||
struct timeval tv;
|
||||
|
||||
n = process_run();
|
||||
|
||||
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = 1;
|
||||
select(0, NULL, NULL, NULL, &tv);
|
||||
|
||||
FD_ZERO(&fds);
|
||||
FD_SET(STDIN_FILENO, &fds);
|
||||
select(1, &fds, NULL, NULL, &tv);
|
||||
|
||||
if(FD_ISSET(STDIN_FILENO, &fds)) {
|
||||
char c;
|
||||
if(read(STDIN_FILENO, &c, 1) > 0) {
|
||||
serial_input_byte(c);
|
||||
}
|
||||
}
|
||||
|
||||
etimer_request_poll();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void log_message(char *m1, char *m2)
|
||||
void
|
||||
log_message(char *m1, char *m2)
|
||||
{
|
||||
printf("%s%s\n", m1, m2);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
uip_log(char *m)
|
||||
{
|
||||
printf("%s\n", m);
|
||||
}
|
||||
|
||||
/*unsigned short
|
||||
sensors_light1(void)
|
||||
{
|
||||
static unsigned short count;
|
||||
return count++;
|
||||
}
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
Loading…
Reference in a new issue