Removed reliance on a large uIP buffer configuration. Now internally uses 2048 bytes buffers regardless of uIP buffer size

This commit is contained in:
adamdunkels 2007-03-29 22:25:25 +00:00
parent 4a3f6b5e97
commit 8935ccb74f
2 changed files with 24 additions and 17 deletions

View file

@ -30,7 +30,7 @@
*
* Author: Adam Dunkels <adam@sics.se>
*
* $Id: ether.c,v 1.6 2007/03/22 18:59:34 adamdunkels Exp $
* $Id: ether.c,v 1.7 2007/03/29 22:25:25 adamdunkels Exp $
*/
/**
* \file
@ -74,12 +74,13 @@
MEMB(packets, struct ether_packet, 20000);
LIST(active_packets);
static u8_t rxbuffer[2000];
static u8_t rxbuffer[2048];
static clock_time_t timer;
#define BUF ((struct uip_tcpip_hdr *)&uip_buf[UIP_LLH_LEN])
#define PRINTF(x) printf x
#define PRINTF(...)
/*#define PRINTF(x) printf x*/
static int s, sc;
@ -257,13 +258,18 @@ ether_client_read(u8_t *buf, int bufsize)
return 0;
}
if(FD_ISSET(sc, &fdset)) {
ret = recv(sc, &rxbuffer[0], bufsize, 0);
ret = recv(sc, &rxbuffer[0], sizeof(rxbuffer), 0);
if(ret == -1) {
perror("ether_client_poll: read");
return 0;
}
len = ret;
if(len > bufsize) {
PRINTF("ether_client_read: packet truncated from %d to %d\n",
len, bufsize);
len = bufsize;
}
memcpy(buf, &rxbuffer[sizeof(struct ether_hdr)], len);
radio_sensor_signal = hdr->signal;
@ -309,14 +315,15 @@ ether_server_poll(void)
return;
}
if(FD_ISSET(s, &fdset)) {
ret = recv(s, &rxbuffer[0], UIP_BUFSIZE, 0);
ret = recv(s, &rxbuffer[0], sizeof(rxbuffer), 0);
if(ret == -1) {
perror("ether_poll: read");
return;
}
switch(hdr->type) {
case PTYPE_DATA:
/* printf("ether_poll: read %d bytes from (%d, %d)\n", ret, hdr->srcx, hdr->srcy);*/
PRINTF("ether_poll: read %d bytes from (%d, %d)\n",
ret, hdr->srcx, hdr->srcy);
ether_put(rxbuffer, ret, hdr->srcx, hdr->srcy);
break;
case PTYPE_LEDS:
@ -493,7 +500,7 @@ node_send_packet(char *data, int len)
u8_t
ether_send(char *data, int len)
{
char tmpbuf[UIP_BUFSIZE + UIP_LLH_LEN + sizeof(struct ether_hdr)];
char tmpbuf[2048];
struct ether_hdr *hdr = (struct ether_hdr *)tmpbuf;

View file

@ -30,7 +30,7 @@
*
* Author: Adam Dunkels <adam@sics.se>
*
* $Id: ethernode.c,v 1.6 2007/03/22 18:59:34 adamdunkels Exp $
* $Id: ethernode.c,v 1.7 2007/03/29 22:25:52 adamdunkels Exp $
*/
/**
* \file
@ -53,8 +53,8 @@
#define BUF ((uip_tcpip_hdr *)&uip_buf[HDR_LEN])
/*#define PRINTF(x)*/
#define PRINTF(x) printf x; fflush(NULL)
#define PRINTF(...)
/*#define PRINTF(x) printf x; fflush(NULL)*/
struct {
u8_t id;
@ -90,7 +90,7 @@ do_send(u8_t type, u8_t dest, struct hdr *hdr, int len)
++state.seqno;
/* printf("ether_send len %d\n", len);*/
PRINTF("ether_send len %d\n", len);
return ether_send((char *)hdr, len);
}
@ -125,10 +125,10 @@ int
ethernode_read(u8_t *buf, int bufsize)
{
int len;
u8_t tmpbuf[UIP_BUFSIZE];
u8_t tmpbuf[2048];
struct hdr *hdr = (struct hdr *)tmpbuf;
len = ether_client_read(tmpbuf, UIP_BUFSIZE);
len = ether_client_read(tmpbuf, sizeof(tmpbuf));
if(len == 0) {
return 0;
}
@ -170,11 +170,11 @@ u8_t
ethernode_send(void)
{
int len;
static char tmpbuf[UIP_BUFSIZE + HDR_LEN];
static char tmpbuf[2048];
struct hdr *hdr = (struct hdr *)tmpbuf;
u8_t dest;
if(uip_len > UIP_BUFSIZE) {
if(uip_len > sizeof(tmpbuf)) {
PRINTF(("Ethernode_send: too large uip_len %d\n", uip_len));
return UIP_FW_TOOLARGE;
}
@ -194,7 +194,7 @@ ethernode_send(void)
void
ethernode_send_buf(u8_t *buf, int len)
{
char tmpbuf[UIP_BUFSIZE + HDR_LEN];
char tmpbuf[2048];
struct hdr *hdr = (struct hdr *)tmpbuf;
u8_t dest;