mirror of
https://github.com/oliverschmidt/contiki.git
synced 2025-01-11 19:29:50 +00:00
Merge pull request #180 from mmuman/cleanup-and-fixes
Cleanup and fixes
This commit is contained in:
commit
6ba28bf74f
@ -102,7 +102,7 @@ shell_prompt(char *str)
|
|||||||
}
|
}
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
shell_exit(char *str)
|
shell_exit(void)
|
||||||
{
|
{
|
||||||
ctk_window_close(&window);
|
ctk_window_close(&window);
|
||||||
}
|
}
|
||||||
|
@ -69,6 +69,13 @@ static unsigned long lasttime;
|
|||||||
|
|
||||||
#define BUF ((struct uip_eth_hdr *)&uip_buf[0])
|
#define BUF ((struct uip_eth_hdr *)&uip_buf[0])
|
||||||
|
|
||||||
|
#define DEBUG 0
|
||||||
|
#if DEBUG
|
||||||
|
#define PRINTF(...) fprintf(stderr, __VA_ARGS__)
|
||||||
|
#else
|
||||||
|
#define PRINTF(...)
|
||||||
|
#endif
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
int
|
int
|
||||||
tapdev_fd(void)
|
tapdev_fd(void)
|
||||||
@ -83,7 +90,7 @@ remove_route(void)
|
|||||||
char buf[1024];
|
char buf[1024];
|
||||||
snprintf(buf, sizeof(buf), "route delete -net 172.18.0.0");
|
snprintf(buf, sizeof(buf), "route delete -net 172.18.0.0");
|
||||||
system(buf);
|
system(buf);
|
||||||
printf("%s\n", buf);
|
fprintf(stderr, "%s\n", buf);
|
||||||
|
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
@ -112,7 +119,7 @@ tapdev_init(void)
|
|||||||
|
|
||||||
snprintf(buf, sizeof(buf), "ifconfig tap0 inet 172.18.0.1/16");
|
snprintf(buf, sizeof(buf), "ifconfig tap0 inet 172.18.0.1/16");
|
||||||
system(buf);
|
system(buf);
|
||||||
printf("%s\n", buf);
|
fprintf(stderr, "%s\n", buf);
|
||||||
#ifdef linux
|
#ifdef linux
|
||||||
/* route add for linux */
|
/* route add for linux */
|
||||||
snprintf(buf, sizeof(buf), "route add -net 172.18.0.0/16 dev tap0");
|
snprintf(buf, sizeof(buf), "route add -net 172.18.0.0/16 dev tap0");
|
||||||
@ -122,7 +129,7 @@ tapdev_init(void)
|
|||||||
#endif /* linux */
|
#endif /* linux */
|
||||||
|
|
||||||
system(buf);
|
system(buf);
|
||||||
printf("%s\n", buf);
|
fprintf(stderr, "%s\n", buf);
|
||||||
atexit(remove_route);
|
atexit(remove_route);
|
||||||
|
|
||||||
lasttime = 0;
|
lasttime = 0;
|
||||||
@ -149,6 +156,7 @@ tapdev_poll(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
ret = read(fd, uip_buf, UIP_BUFSIZE);
|
ret = read(fd, uip_buf, UIP_BUFSIZE);
|
||||||
|
PRINTF("tapdev_poll: read %d bytes\n", ret);
|
||||||
|
|
||||||
if(ret == -1) {
|
if(ret == -1) {
|
||||||
perror("tapdev_poll: read");
|
perror("tapdev_poll: read");
|
||||||
@ -171,11 +179,12 @@ tapdev_send(void)
|
|||||||
#if DROP
|
#if DROP
|
||||||
drop++;
|
drop++;
|
||||||
if(drop % 8 == 7) {
|
if(drop % 8 == 7) {
|
||||||
printf("Dropped an output packet!\n");
|
fprintf(stderr, "Dropped an output packet!\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif /* DROP */
|
#endif /* DROP */
|
||||||
|
|
||||||
|
PRINTF("tapdev_send: sending %d bytes\n", uip_len);
|
||||||
ret = write(fd, uip_buf, uip_len);
|
ret = write(fd, uip_buf, uip_len);
|
||||||
|
|
||||||
if(ret == -1) {
|
if(ret == -1) {
|
||||||
|
@ -46,9 +46,9 @@ clock_time_t
|
|||||||
clock_time(void)
|
clock_time(void)
|
||||||
{
|
{
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
|
|
||||||
gettimeofday(&tv, NULL);
|
gettimeofday(&tv, NULL);
|
||||||
|
|
||||||
return tv.tv_sec * 1000 + tv.tv_usec / 1000;
|
return tv.tv_sec * 1000 + tv.tv_usec / 1000;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
@ -56,9 +56,9 @@ unsigned long
|
|||||||
clock_seconds(void)
|
clock_seconds(void)
|
||||||
{
|
{
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
|
|
||||||
gettimeofday(&tv, NULL);
|
gettimeofday(&tv, NULL);
|
||||||
|
|
||||||
return tv.tv_sec;
|
return tv.tv_sec;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
@ -221,9 +221,9 @@ main(int argc, char **argv)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
serial_line_init();
|
serial_line_init();
|
||||||
|
|
||||||
autostart_start(autostart_processes);
|
autostart_start(autostart_processes);
|
||||||
|
|
||||||
/* Make standard output unbuffered. */
|
/* Make standard output unbuffered. */
|
||||||
setvbuf(stdout, (char *)NULL, _IONBF, 0);
|
setvbuf(stdout, (char *)NULL, _IONBF, 0);
|
||||||
|
|
||||||
@ -271,12 +271,12 @@ main(int argc, char **argv)
|
|||||||
void
|
void
|
||||||
log_message(char *m1, char *m2)
|
log_message(char *m1, char *m2)
|
||||||
{
|
{
|
||||||
printf("%s%s\n", m1, m2);
|
fprintf(stderr, "%s%s\n", m1, m2);
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
uip_log(char *m)
|
uip_log(char *m)
|
||||||
{
|
{
|
||||||
printf("%s\n", m);
|
fprintf(stderr, "%s\n", m);
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
@ -53,9 +53,9 @@ eeprom_write(eeprom_addr_t addr, unsigned char *buf, int size)
|
|||||||
lseek(f, addr, SEEK_SET);
|
lseek(f, addr, SEEK_SET);
|
||||||
write(f, buf, size);
|
write(f, buf, size);
|
||||||
close(f);
|
close(f);
|
||||||
|
|
||||||
printf("eeprom_write(addr 0x%02x, buf %p, size %d);\n", addr, buf, size);
|
printf("eeprom_write(addr 0x%02x, buf %p, size %d);\n", addr, buf, size);
|
||||||
|
|
||||||
memcpy(&eeprom[addr], buf, size);
|
memcpy(&eeprom[addr], buf, size);
|
||||||
}
|
}
|
||||||
void
|
void
|
||||||
|
@ -56,9 +56,9 @@ xmem_pwrite(const void *buf, int size, unsigned long offset)
|
|||||||
lseek(f, addr, SEEK_SET);
|
lseek(f, addr, SEEK_SET);
|
||||||
write(f, buf, size);
|
write(f, buf, size);
|
||||||
close(f);*/
|
close(f);*/
|
||||||
|
|
||||||
/* printf("xmem_write(offset 0x%02x, buf %p, size %l);\n", offset, buf, size);*/
|
/* printf("xmem_write(offset 0x%02x, buf %p, size %l);\n", offset, buf, size);*/
|
||||||
|
|
||||||
memcpy(&xmem[offset], buf, size);
|
memcpy(&xmem[offset], buf, size);
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user