Skip to content
Snippets Groups Projects
Commit 9db63059 authored by Robert Hartung's avatar Robert Hartung
Browse files

Cleanup and increases stack size for dump thread

parent 967385a8
No related branches found
No related tags found
No related merge requests found
......@@ -43,11 +43,10 @@
#error NODE_ID undefined
#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 kernel_pid_t dump_thread_pid;
char send_thread_stack[256];
static gnrc_netif_t *ieee802154_netif = NULL;
typedef struct {
char magic_string[8];
......@@ -141,12 +140,9 @@ void *dump_thread(void *arg)
return NULL;
}
static netopt_enable_t enable = true;
static netopt_enable_t disable = false;
void *send_thread(void *arg)
{
(void) arg;
gnrc_netif_t *ieee802154_netif = arg;
/*
struct iovec vector[2];
......@@ -171,22 +167,35 @@ void *send_thread(void *arg)
gnrc_pktsnip_t *pkt, *hdr;
gnrc_netif_hdr_t *nethdr;
netopt_enable_t enable = true;
netopt_enable_t disable = false;
int ret;
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));
if(ret < 0) {
puts("Unable to disable auto ack");
}
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;
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;
ret = gnrc_netapi_set(ieee802154_netif->pid, NETOPT_CSMA_RETRIES, 0, &retries, sizeof(retries));
(void)ret;
if(ret < 0) {
puts("Unable to set CSMA retries = 0");
}
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);
while(1) {
......@@ -194,8 +203,6 @@ void *send_thread(void *arg)
printf("send... ");
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);
if (pkt == NULL) {
puts("ERROR: packet buffer full");
......@@ -211,9 +218,9 @@ void *send_thread(void *arg)
LL_PREPEND(pkt, hdr);
nethdr = (gnrc_netif_hdr_t *)hdr->data;
nethdr->flags = flags;
/* and send it */
if (gnrc_netapi_send(ieee802154_netif->pid, pkt) < 1) {
puts("ERROR: unable to send");
ret = gnrc_netapi_send(ieee802154_netif->pid, pkt);
if (ret < 1) {
printf("ERROR: unable to send: %d\n", ret);
gnrc_pktbuf_release(pkt);
} else {
puts("OK");
......@@ -225,18 +232,19 @@ void *send_thread(void *arg)
int main(void)
{
/// +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;
if((netif = gnrc_netif_iter(netif))) {
puts("Found gnrc netif");
ieee802154_netif = netif;
gnrc_netif_t *ieee802154_netif = netif;
printf("Found gnrc netif: %d %d", netif->pid, ieee802154_netif->pid);
/// +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");
} else {
thread_create(send_thread_stack, sizeof(send_thread_stack), THREAD_PRIORITY_MAIN + 1, 0, send_thread, ieee802154_netif, "send_thread");
}
else {
puts("Unable to find netif");
}
(void) puts("Welcome to RIOT!");
printf("This is node %d\n", NODE_ID);
char line_buf[SHELL_DEFAULT_BUFSIZE];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment