Allow debugging output to be written from the bridge mote and be printed out by the tapslip6 program

This commit is contained in:
adamdunkels 2009-11-02 11:46:49 +00:00
parent 5bd2008def
commit 0a12f6da77
4 changed files with 64 additions and 14 deletions

View file

@ -20,7 +20,7 @@ all: uip6-bridge-tap.sky
upload: uip6-bridge-tap.ihex
cp $< $(IHEXFILE)
$(MAKE) sky-u.$(subst /,-,$(word 1, $(MOTES)))
$(MAKE) sky-u.$(subst /,-,$(word $(MOTE), $(MOTES)))
include $(CONTIKI)/Makefile.include
@ -35,10 +35,6 @@ connect: ../../tapslip6
sudo ../../tapslip6 -t tap0 -s $(USBDEVPREFIX)$(word $(MOTE), $(CMOTES)) 127.0.0.1 255.0.0.0
bridge:
sudo sysctl net.ipv6.conf.all.forwarding=1
sudo ifconfig tap0 down
sudo ifconfig tap0 hw ether $(MAC)
sudo ifconfig tap0 up
sudo service radvd restart
sudo route add -6 aaaa::/64 tap0
sudo ip -6 address add aaaa::1/64 dev tap0

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: bridge-conf.h,v 1.3 2009/10/26 13:34:08 adamdunkels Exp $
* $Id: bridge-conf.h,v 1.4 2009/11/02 11:46:49 adamdunkels Exp $
*/
/**
@ -55,4 +55,5 @@
#define CC2420_CONF_AUTOACK 1
#endif /* __BRIDGE_CONF_H__ */

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: uip6-bridge-tap.c,v 1.1 2009/05/08 12:49:36 joxe Exp $
* $Id: uip6-bridge-tap.c,v 1.2 2009/11/02 11:46:49 adamdunkels Exp $
*
*/
@ -43,6 +43,9 @@
#include "dev/slip.h"
#include "dev/leds.h"
#include "sicslow_ethernet.h"
#include "net/rime/packetbuf.h"
#include <stdio.h>
#include <string.h>
@ -59,6 +62,9 @@ tcpip_output(uip_lladdr_t *a)
{
if(outputfunc != NULL) {
outputfunc(a);
/* printf("pppp o %u tx %u rx %u\n", UIP_IP_BUF->proto,
packetbuf_attr(PACKETBUF_ATTR_TRANSMIT_TIME),
packetbuf_attr(PACKETBUF_ATTR_LISTEN_TIME));*/
leds_invert(LEDS_GREEN);
}
return 0;
@ -85,7 +91,9 @@ tcpip_input(void)
if(uip_len > 0) {
mac_LowpanToEthernet();
if(uip_len > 0) {
/* slip_write(UIP_IP_BUF, uip_len); */
/* printf("pppp i %u tx %u rx %u\n", UIP_IP_BUF->proto,
packetbuf_attr(PACKETBUF_ATTR_TRANSMIT_TIME),
packetbuf_attr(PACKETBUF_ATTR_LISTEN_TIME));*/
slip_write(uip_buf, uip_len);
leds_invert(LEDS_RED);
uip_len = 0;
@ -124,3 +132,28 @@ PROCESS_THREAD(uip6_bridge, ev, data)
PROCESS_END();
}
/*---------------------------------------------------------------------------*/
int
putchar(int c)
{
#define SLIP_END 0300
static char debug_frame = 0;
if(!debug_frame) { /* Start of debug output */
slip_arch_writeb(SLIP_END);
slip_arch_writeb('\r'); /* Type debug line == '\r' */
debug_frame = 1;
}
slip_arch_writeb((char)c);
/*
* Line buffered output, a newline marks the end of debug output and
* implicitly flushes debug output.
*/
if(c == '\n') {
slip_arch_writeb(SLIP_END);
debug_frame = 0;
}
return c;
}
/*---------------------------------------------------------------------------*/

View file

@ -29,7 +29,7 @@
*
* This file is part of the uIP TCP/IP stack.
*
* $Id: tapslip6.c,v 1.1 2009/05/08 12:37:34 joxe Exp $
* $Id: tapslip6.c,v 1.2 2009/11/02 11:46:49 adamdunkels Exp $
*
*/
@ -100,6 +100,22 @@ print_packet(u_int8_t *p, int len) {
printf("\n");
}
int
is_sensible_string(const unsigned char *s, int len)
{
int i;
for(i = 1; i < len; i++) {
if(s[i] == 0 || s[i] == '\r' || s[i] == '\n' || s[i] == '\t') {
continue;
} else if(s[i] < ' ' || '~' < s[i]) {
return 0;
}
}
return 1;
}
/*
* Read from serial, when we have a packet write it to tun. No output
* buffering, input buffered by stdio.
@ -142,7 +158,6 @@ serial_to_tun(FILE *inslip, int outfd)
switch(c) {
case SLIP_END:
if(inbufptr > 0) {
if(uip.inbuf[0] == '!') {
if (uip.inbuf[1] == 'M') {
/* Read gateway MAC address and autoconfigure tap0 interface */
@ -161,9 +176,14 @@ serial_to_tun(FILE *inslip, int outfd)
ssystem("ifconfig %s hw ether %s", tundev, &macs[6]);
ssystem("ifconfig %s up", tundev);
}
#define DEBUG_LINE_MARKER '\r'
} else if(uip.inbuf[0] == DEBUG_LINE_MARKER) {
fwrite(uip.inbuf + 1, inbufptr - 1, 1, stdout);
} else if(is_sensible_string(uip.inbuf, inbufptr)) {
fwrite(uip.inbuf, inbufptr, 1, stdout);
} else {
printf("Writing to tun len: %d\n", inbufptr);
print_packet(uip.inbuf, inbufptr);
/* print_packet(uip.inbuf, inbufptr);*/
if(write(outfd, uip.inbuf, inbufptr) != inbufptr) {
err(1, "serial_to_tun: write");
}
@ -244,14 +264,14 @@ write_to_serial(int outfd, void *inbuf, int len)
u_int8_t *p = inbuf;
int i, ecode;
printf("Got packet of length %d - write SLIP\n", len);
print_packet(p, len);
/* printf("Got packet of length %d - write SLIP\n", len);*/
/* print_packet(p, len);*/
/* It would be ``nice'' to send a SLIP_END here but it's not
* really necessary.
*/
/* slip_send(outfd, SLIP_END); */
printf("writing packet to serial!!! %d\n", len);
/* printf("writing packet to serial!!! %d\n", len);*/
for(i = 0; i < len; i++) {
switch(p[i]) {
case SLIP_END: