Commit 9db63059 authored by Robert Hartung's avatar Robert Hartung
Browse files

Cleanup and increases stack size for dump thread

parent 967385a8
...@@ -43,11 +43,10 @@ ...@@ -43,11 +43,10 @@
#error NODE_ID undefined #error NODE_ID undefined
#endif #endif
char dump_thread_stack[256]; /// 512 required for samr21-xpro, 256 sufficuent for INGA and telosb
char dump_thread_stack[512];
char send_thread_stack[512];
static msg_t dump_thread_msg_queue[RCV_QUEUE_SIZE]; static msg_t dump_thread_msg_queue[RCV_QUEUE_SIZE];
static kernel_pid_t dump_thread_pid;
char send_thread_stack[256];
static gnrc_netif_t *ieee802154_netif = NULL;
typedef struct { typedef struct {
char magic_string[8]; char magic_string[8];
...@@ -141,12 +140,9 @@ void *dump_thread(void *arg) ...@@ -141,12 +140,9 @@ void *dump_thread(void *arg)
return NULL; return NULL;
} }
static netopt_enable_t enable = true;
static netopt_enable_t disable = false;
void *send_thread(void *arg) void *send_thread(void *arg)
{ {
(void) arg; gnrc_netif_t *ieee802154_netif = arg;
/* /*
struct iovec vector[2]; struct iovec vector[2];
...@@ -171,22 +167,35 @@ void *send_thread(void *arg) ...@@ -171,22 +167,35 @@ void *send_thread(void *arg)
gnrc_pktsnip_t *pkt, *hdr; gnrc_pktsnip_t *pkt, *hdr;
gnrc_netif_hdr_t *nethdr; gnrc_netif_hdr_t *nethdr;
netopt_enable_t enable = true;
netopt_enable_t disable = false;
int ret; int ret;
ret = gnrc_netapi_set(ieee802154_netif->pid, NETOPT_PROMISCUOUSMODE, 0, &enable, sizeof(netopt_enable_t)); ret = gnrc_netapi_set(ieee802154_netif->pid, NETOPT_PROMISCUOUSMODE, 0, &enable, sizeof(netopt_enable_t));
if(ret < 0) {
puts("Unable to set promiscous mode");
}
ret = gnrc_netapi_set(ieee802154_netif->pid, NETOPT_AUTOACK, 0, &disable, sizeof(netopt_enable_t)); ret = gnrc_netapi_set(ieee802154_netif->pid, NETOPT_AUTOACK, 0, &disable, sizeof(netopt_enable_t));
if(ret < 0) {
puts("Unable to disable auto ack");
}
ret = gnrc_netapi_set(ieee802154_netif->pid, NETOPT_CSMA, 0, &disable, sizeof(netopt_enable_t)); ret = gnrc_netapi_set(ieee802154_netif->pid, NETOPT_CSMA, 0, &disable, sizeof(netopt_enable_t));
if(ret < 0) {
puts("Unable to disable CSMA");
}
uint8_t retrans = 0; uint8_t retrans = 0;
ret = gnrc_netapi_set(ieee802154_netif->pid, NETOPT_RETRANS, 0, &retrans, sizeof(retrans)); ret = gnrc_netapi_set(ieee802154_netif->pid, NETOPT_RETRANS, 0, &retrans, sizeof(retrans));
if(ret < 0) {
puts("Unable to set retrans = 0");
}
int8_t retries = 7; int8_t retries = 7;
ret = gnrc_netapi_set(ieee802154_netif->pid, NETOPT_CSMA_RETRIES, 0, &retries, sizeof(retries)); ret = gnrc_netapi_set(ieee802154_netif->pid, NETOPT_CSMA_RETRIES, 0, &retries, sizeof(retries));
if(ret < 0) {
(void)ret; puts("Unable to set CSMA retries = 0");
}
uint8_t flags = 0 | GNRC_NETIF_HDR_FLAGS_BROADCAST; uint8_t flags = 0 | GNRC_NETIF_HDR_FLAGS_BROADCAST;
//uint8_t data[25];
//uint8_t size;
uint8_t payload_length = sprintf((char*)eval_message.payload, "Hello from %2d", NODE_ID); uint8_t payload_length = sprintf((char*)eval_message.payload, "Hello from %2d", NODE_ID);
while(1) { while(1) {
...@@ -194,8 +203,6 @@ void *send_thread(void *arg) ...@@ -194,8 +203,6 @@ void *send_thread(void *arg)
printf("send... "); printf("send... ");
eval_message.seq_nr++; eval_message.seq_nr++;
/* put packet together */
pkt = gnrc_pktbuf_add(NULL, &eval_message, sizeof(eval_message) - MAX_PAYLOAD_LENGTH + payload_length, GNRC_NETTYPE_UNDEF); pkt = gnrc_pktbuf_add(NULL, &eval_message, sizeof(eval_message) - MAX_PAYLOAD_LENGTH + payload_length, GNRC_NETTYPE_UNDEF);
if (pkt == NULL) { if (pkt == NULL) {
puts("ERROR: packet buffer full"); puts("ERROR: packet buffer full");
...@@ -211,9 +218,9 @@ void *send_thread(void *arg) ...@@ -211,9 +218,9 @@ void *send_thread(void *arg)
LL_PREPEND(pkt, hdr); LL_PREPEND(pkt, hdr);
nethdr = (gnrc_netif_hdr_t *)hdr->data; nethdr = (gnrc_netif_hdr_t *)hdr->data;
nethdr->flags = flags; nethdr->flags = flags;
/* and send it */ ret = gnrc_netapi_send(ieee802154_netif->pid, pkt);
if (gnrc_netapi_send(ieee802154_netif->pid, pkt) < 1) { if (ret < 1) {
puts("ERROR: unable to send"); printf("ERROR: unable to send: %d\n", ret);
gnrc_pktbuf_release(pkt); gnrc_pktbuf_release(pkt);
} else { } else {
puts("OK"); puts("OK");
...@@ -225,18 +232,19 @@ void *send_thread(void *arg) ...@@ -225,18 +232,19 @@ void *send_thread(void *arg)
int main(void) int main(void)
{ {
/// +1 -> INGA working, but TelosB/Sky not /// +1 -> INGA working, but TelosB/Sky not
dump_thread_pid = thread_create(dump_thread_stack, sizeof(dump_thread_stack), THREAD_PRIORITY_MAIN + 2, 0, dump_thread, NULL, "dump_thread"); thread_create(dump_thread_stack, sizeof(dump_thread_stack), THREAD_PRIORITY_MAIN + 2, 0, dump_thread, NULL, "dump_thread");
gnrc_netif_t *netif = NULL; gnrc_netif_t *netif = NULL;
if((netif = gnrc_netif_iter(netif))) { if((netif = gnrc_netif_iter(netif))) {
puts("Found gnrc netif"); gnrc_netif_t *ieee802154_netif = netif;
ieee802154_netif = netif; printf("Found gnrc netif: %d %d", netif->pid, ieee802154_netif->pid);
/// +2 -> INGA working, but TelosB/Sky not /// +2 -> INGA working, but TelosB/Sky not
thread_create(send_thread_stack, sizeof(send_thread_stack), THREAD_PRIORITY_MAIN + 1, THREAD_CREATE_STACKTEST, send_thread, NULL, "send_thread"); thread_create(send_thread_stack, sizeof(send_thread_stack), THREAD_PRIORITY_MAIN + 1, 0, send_thread, ieee802154_netif, "send_thread");
} else { }
else {
puts("Unable to find netif"); puts("Unable to find netif");
} }
(void) puts("Welcome to RIOT!"); (void) puts("Welcome to RIOT!");
printf("This is node %d\n", NODE_ID); printf("This is node %d\n", NODE_ID);
char line_buf[SHELL_DEFAULT_BUFSIZE]; char line_buf[SHELL_DEFAULT_BUFSIZE];
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment