Skip to content
Snippets Groups Projects
Commit af3e20a8 authored by f4grx's avatar f4grx
Browse files

reduce cpu load

parent df45c194
No related branches found
No related tags found
No related merge requests found
......@@ -77,7 +77,7 @@ int config_list(void)
else if(type == EECONFIG_TYPE_IP)
{
struct in_addr val;
ret = hn70ap_eeconfig_getip(name, &val);
ret = hn70ap_eeconfig_getip(name, &val.s_addr);
if(ret == OK)
{
printf("%s\n", inet_ntoa(val));
......
......@@ -425,6 +425,7 @@ int hn70ap_lcd_drawchar(int row, int col, char ch)
errcode);
}
#endif
return 0;
}
/****************************************************************************
......
......@@ -149,6 +149,10 @@ void *hn70ap_radio_rxthread(void *arg)
//syslog(LOG_ERR, "radio rx failed -> errno=%d\n", errno);
}
} //callback defined
else
{
pthread_yield();
}
} //radio alive
syslog(LOG_INFO, "Stopped radio RX thread\n");
return NULL;
......@@ -170,6 +174,7 @@ int hn70ap_radio_devinit(struct radio_s *radio, const char *dev)
goto lret;
}
radio->callback = NULL;
radio->alive = true;
ret = pthread_create(&radio->rxthread, NULL, hn70ap_radio_rxthread, NULL);
if(ret < 0)
......
......@@ -110,9 +110,9 @@ int hn70ap_system_init(void)
}
strncpy(tunname, "uhf0", IFNAMSIZ);
#if 0
#if 1
ret = hn70ap_tun_devinit(tunname);
if(ret != 0)
if(ret < 0)
{
syslog(LOG_ERR, "WARNING: Failed to initialize TUN interface\n");
}
......
......@@ -35,6 +35,7 @@
#include <nuttx/config.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
......@@ -81,6 +82,8 @@ void *hn70ap_tun_rxthread(void *arg)
if(tunnel->callback)
{
//Wait for messages on the air
printf("t");
fflush(stdout);
ret = read(tunnel->fd, tunnel->userbuf, tunnel->userbuflen);
if(ret > 0)
{
......@@ -90,8 +93,13 @@ void *hn70ap_tun_rxthread(void *arg)
else
{
//syslog(LOG_ERR, "tunnel rx failed -> errno=%d\n", errno);
}
printf("T");
}
} //callback defined
else
{
pthread_yield();
}
} //tunnel alive
syslog(LOG_INFO, "Stopped tunnel RX thread\n");
return NULL;
......@@ -153,7 +161,7 @@ int hn70ap_tun_devinit(char name[IFNAMSIZ])
return -1;
}
if ((fd = open("/dev/tun", O_RDWR | O_NONBLOCK)) < 0)
if ((fd = open("/dev/tun", O_RDWR)) < 0)
{
return fd;
}
......@@ -165,7 +173,8 @@ int hn70ap_tun_devinit(char name[IFNAMSIZ])
strncpy(ifr.ifr_name, name, IFNAMSIZ);
}
if ((errcode = ioctl(fd, TUNSETIFF, (unsigned long)&ifr)) < 0)
errcode = ioctl(fd, TUNSETIFF, (unsigned long)&ifr);
if(errcode < 0)
{
close(fd);
return errcode;
......
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