You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2016/11/08 21:27:24 UTC
[1/3] incubator-mynewt-core git commit: inet_def_service;
previous commit was incomplete. Now actually fix the build.
Repository: incubator-mynewt-core
Updated Branches:
refs/heads/develop cd9214edc -> ed475682d
inet_def_service; previous commit was incomplete. Now actually fix the build.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/60310863
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/60310863
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/60310863
Branch: refs/heads/develop
Commit: 603108638f80ef3484c2c4769abd98b8defce604
Parents: cd9214e
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Tue Nov 8 13:24:11 2016 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Tue Nov 8 13:24:11 2016 -0800
----------------------------------------------------------------------
net/ip/inet_def_service/src/inet_def_service.c | 301 +++++++++++---------
1 file changed, 173 insertions(+), 128 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/60310863/net/ip/inet_def_service/src/inet_def_service.c
----------------------------------------------------------------------
diff --git a/net/ip/inet_def_service/src/inet_def_service.c b/net/ip/inet_def_service/src/inet_def_service.c
index f5fc037..3bbe59e 100644
--- a/net/ip/inet_def_service/src/inet_def_service.c
+++ b/net/ip/inet_def_service/src/inet_def_service.c
@@ -37,25 +37,22 @@ enum inet_def_type {
INET_DEF_MAXTYPE
};
-#define INET_DEF_FROM_EVENT_TYPE(a) ((a) - OS_EVENT_T_PERUSER)
-#define INET_EVENT_TYPE_FROM_DEF(a) ((a) + OS_EVENT_T_PERUSER)
-
#define CHARGEN_WRITE_SZ 512
static const char chargen_pattern[] = "1234567890";
#define CHARGEN_PATTERN_SZ (sizeof(chargen_pattern) - 1)
static struct os_eventq *inet_def_evq;
-static void inet_def_event_echo(struct os_event *ev);
-static void inet_def_event_discard(struct os_event *ev);
-static void inet_def_event_chargen(struct os_event *ev);
-static void inet_def_event_start(struct os_event *ev);
+struct inet_def_event {
+ struct os_event ide_ev;
+ enum inet_def_type ide_type;
+};
/*
* UDP service.
*/
struct inet_def_udp {
- struct os_event ev; /* Datagram RX reported via event */
+ struct inet_def_event ev; /* Datagram RX reported via event */
struct mn_socket *socket;
uint32_t pkt_cnt;
};
@@ -64,7 +61,7 @@ struct inet_def_udp {
* Connected TCP socket.
*/
struct inet_def_tcp {
- struct os_event ev; /* Data RX reported with this event */
+ struct inet_def_event ev; /* Data RX reported with this event */
SLIST_ENTRY(inet_def_tcp) list;
struct mn_socket *socket;
int closed;
@@ -82,28 +79,9 @@ static struct inet_def {
struct inet_def_listen tcp_service[INET_DEF_MAXTYPE];
struct inet_def_udp udp_service[INET_DEF_MAXTYPE];
SLIST_HEAD(, inet_def_tcp) tcp_conns; /* List of connected TCP sockets */
-} inet_def = {
- .udp_service = {
- [INET_DEF_ECHO] = {
- .ev.ev_cb = inet_def_event_echo,
- .ev.ev_arg = (void *)MN_SOCK_DGRAM,
- },
- [INET_DEF_DISCARD] = {
- .ev.ev_cb = inet_def_event_discard,
- .ev.ev_arg = (void *)MN_SOCK_DGRAM,
- },
- [INET_DEF_CHARGEN] = {
- .ev.ev_cb = inet_def_event_chargen,
- .ev.ev_arg = (void *)MN_SOCK_DGRAM,
- },
- }
-};
+} inet_def;
-static struct os_eventq *
-inet_def_evq_get(void)
-{
- return inet_def_evq;
-}
+static void inet_def_event(struct os_event *ev);
/*
* UDP socket callbacks. Called in context of IP stack task.
@@ -113,7 +91,7 @@ inet_def_udp_readable(void *arg, int err)
{
struct inet_def_udp *idu = (struct inet_def_udp *)arg;
- os_eventq_put(&inet_def_evq, &idu->ev);
+ os_eventq_put(inet_def_evq, &idu->ev.ide_ev);
}
static const union mn_socket_cb inet_udp_cbs = {
@@ -136,7 +114,7 @@ inet_def_tcp_readable(void *arg, int err)
*/
SLIST_REMOVE(&inet_def.tcp_conns, idt, inet_def_tcp, list);
}
- os_eventq_put(&inet_def_evq, &idt->ev);
+ os_eventq_put(inet_def_evq, &idt->ev.ide_ev);
}
static const union mn_socket_cb inet_tcp_cbs = {
@@ -166,8 +144,9 @@ static int inet_def_newconn(void *arg, struct mn_socket *new)
* Ev_arg says whether it's TCP or UDP.
*/
type = idl - &inet_def.tcp_service[0];
- idt->ev.ev_type = INET_EVENT_TYPE_FROM_DEF(type);
- idt->ev.ev_arg = (void *)MN_SOCK_STREAM;
+ idt->ev.ide_type = type;
+ idt->ev.ide_ev.ev_cb = inet_def_event;
+ idt->ev.ide_ev.ev_arg = (void *)MN_SOCK_STREAM;
mn_socket_set_cbs(new, idt, &inet_tcp_cbs);
SLIST_INSERT_HEAD(&inet_def.tcp_conns, idt, list);
@@ -175,7 +154,7 @@ static int inet_def_newconn(void *arg, struct mn_socket *new)
/*
* Start transmitting right away.
*/
- os_eventq_put(&inet_def_evq, &idt->ev);
+ os_eventq_put(inet_def_evq, &idt->ev.ide_ev);
}
return 0;
}
@@ -237,104 +216,54 @@ err:
return -1;
}
-static struct mn_socket *
-inet_def_socket_from_event(struct os_event *ev,
- struct inet_def_udp **out_idu,
- struct inet_def_tcp **out_idt)
+static void
+inet_def_event(struct os_event *ev)
{
+ struct inet_def_event *ide;
struct inet_def_udp *idu;
struct inet_def_tcp *idt;
struct mn_socket *sock;
+ struct mn_sockaddr_in msin;
+ struct os_mbuf *m;
+ int rc;
+ int off;
+ int loop_cnt;
+ ide = (struct inet_def_event *)ev;
+ idt = (struct inet_def_tcp *)ev;
+ idu = (struct inet_def_udp *)ev;
if ((int)ev->ev_arg == MN_SOCK_DGRAM) {
- idu = (struct inet_def_udp *)ev;
- idt = NULL;
sock = idu->socket;
} else {
- idt = (struct inet_def_tcp *)ev;
- idu = NULL;
sock = idt->socket;
}
-
- if (out_idu != NULL) {
- *out_idu = idu;
- }
- if (out_idt != NULL) {
- *out_idt = idt;
- }
-
- return sock;
-}
-
-static void
-inet_def_free_closed_tcp_sock(struct inet_def_tcp *idt)
-{
- if (idt != NULL && idt->closed) {
- /*
- * Remote end has closed the connection, as indicated in the
- * callback. Close the socket and free the memory.
- */
- mn_socket_set_cbs(idt->socket, NULL, NULL);
- os_eventq_remove(inet_def_evq_get(), &idt->ev);
- mn_close(idt->socket);
- os_free(idt);
- }
-}
-
-static void
-inet_def_event_echo(struct os_event *ev)
-{
- struct mn_sockaddr_in msin;
- struct inet_def_tcp *idt;
- struct mn_socket *sock;
- struct os_mbuf *m;
- int rc;
-
- sock = inet_def_socket_from_event(ev, NULL, &idt);
- while (mn_recvfrom(sock, &m, (struct mn_sockaddr *)&msin) == 0) {
- console_printf("echo %d bytes\n", OS_MBUF_PKTLEN(m));
- rc = mn_sendto(sock, m, (struct mn_sockaddr *)&msin);
- if (rc) {
- console_printf(" failed: %d!!!!\n", rc);
+ switch (ide->ide_type) {
+ case INET_DEF_ECHO:
+ while (mn_recvfrom(sock, &m, (struct mn_sockaddr *)&msin) == 0) {
+ console_printf("echo %d bytes\n", OS_MBUF_PKTLEN(m));
+ rc = mn_sendto(sock, m, (struct mn_sockaddr *)&msin);
+ if (rc) {
+ console_printf(" failed: %d!!!!\n", rc);
+ os_mbuf_free_chain(m);
+ }
+ }
+ break;
+ case INET_DEF_DISCARD:
+ while (mn_recvfrom(sock, &m, NULL) == 0) {
+ console_printf("discard %d bytes\n", OS_MBUF_PKTLEN(m));
os_mbuf_free_chain(m);
}
- }
-
- inet_def_free_closed_tcp_sock(idt);
-}
-
-static void
-inet_def_event_discard(struct os_event *ev)
-{
- struct inet_def_tcp *idt;
- struct mn_socket *sock;
- struct os_mbuf *m;
-
- sock = inet_def_socket_from_event(ev, NULL, NULL);
- while (mn_recvfrom(sock, &m, NULL) == 0) {
- console_printf("discard %d bytes\n", OS_MBUF_PKTLEN(m));
- os_mbuf_free_chain(m);
- }
-
- inet_def_free_closed_tcp_sock(idt);
-}
-
-static void
-inet_def_event_chargen(struct os_event *ev)
-{
- struct inet_def_tcp *idt;
- struct mn_socket *sock;
- struct os_mbuf *m;
- int loop_cnt;
-
- sock = inet_def_socket_from_event(ev, NULL, &idt);
- while (mn_recvfrom(sock, &m, NULL) == 0) {
- os_mbuf_free_chain(m);
- }
- if (idt == NULL || !idt->closed) {
- /*
- * Don't try to send tons of data to a closed socket.
- */
+ break;
+ case INET_DEF_CHARGEN:
+ while (mn_recvfrom(sock, &m, NULL) == 0) {
+ os_mbuf_free_chain(m);
+ }
+ if ((int)ev->ev_arg == MN_SOCK_STREAM && idt->closed) {
+ /*
+ * Don't try to send tons of data to a closed socket.
+ */
+ break;
+ }
loop_cnt = 0;
do {
m = os_msys_get(CHARGEN_WRITE_SZ, 0);
@@ -362,24 +291,140 @@ inet_def_event_chargen(struct os_event *ev)
}
loop_cnt++;
} while (loop_cnt < 32);
+ break;
+ default:
+ assert(0);
+ break;
+ }
+ if ((int)ev->ev_arg == MN_SOCK_STREAM && idt->closed) {
+ /*
+ * Remote end has closed the connection, as indicated in the
+ * callback. Close the socket and free the memory.
+ */
+ mn_socket_set_cbs(idt->socket, NULL, NULL);
+ os_eventq_remove(inet_def_evq, &idt->ev.ide_ev);
+ mn_close(idt->socket);
+ os_free(idt);
}
-
- inet_def_free_closed_tcp_sock(idt);
}
+#if 0
static void
-inet_def_event_start(void)
+inet_def_srv(void *arg)
{
- inet_def_create_srv(INET_DEF_ECHO, ECHO_PORT);
- inet_def_create_srv(INET_DEF_DISCARD, DISCARD_PORT);
- inet_def_create_srv(INET_DEF_CHARGEN, CHARGEN_PORT);
+ struct inet_def_udp *idu;
+ struct inet_def_tcp *idt;
+ struct mn_socket *sock;
+ struct os_event *ev;
+ struct mn_sockaddr_in msin;
+ struct os_mbuf *m;
+ enum inet_def_type type;
+ int rc;
+ int off;
+ int loop_cnt;
+
+ while (1) {
+ /*
+ * Wait here. When event comes, check what type of socket got it,
+ * and then act on it.
+ */
+ ev = os_eventq_get(inet_def_evq);
+ type = ev->ev_type;
+ idt = (struct inet_def_tcp *)ev;
+ idu = (struct inet_def_udp *)ev;
+ if ((int)ev->ev_arg == MN_SOCK_DGRAM) {
+ sock = idu->socket;
+ } else {
+ sock = idt->socket;
+ }
+ switch (type) {
+ case INET_DEF_ECHO:
+ while (mn_recvfrom(sock, &m, (struct mn_sockaddr *)&msin) == 0) {
+ console_printf("echo %d bytes\n", OS_MBUF_PKTLEN(m));
+ rc = mn_sendto(sock, m, (struct mn_sockaddr *)&msin);
+ if (rc) {
+ console_printf(" failed: %d!!!!\n", rc);
+ os_mbuf_free_chain(m);
+ }
+ }
+ break;
+ case INET_DEF_DISCARD:
+ while (mn_recvfrom(sock, &m, NULL) == 0) {
+ console_printf("discard %d bytes\n", OS_MBUF_PKTLEN(m));
+ os_mbuf_free_chain(m);
+ }
+ break;
+ case INET_DEF_CHARGEN:
+ while (mn_recvfrom(sock, &m, NULL) == 0) {
+ os_mbuf_free_chain(m);
+ }
+ if ((int)ev->ev_arg == MN_SOCK_STREAM && idt->closed) {
+ /*
+ * Don't try to send tons of data to a closed socket.
+ */
+ break;
+ }
+ loop_cnt = 0;
+ do {
+ m = os_msys_get(CHARGEN_WRITE_SZ, 0);
+ if (m) {
+ for (off = 0;
+ OS_MBUF_TRAILINGSPACE(m) >= CHARGEN_PATTERN_SZ;
+ off += CHARGEN_PATTERN_SZ) {
+ os_mbuf_copyinto(m, off, chargen_pattern,
+ CHARGEN_PATTERN_SZ);
+ }
+ console_printf("chargen %d bytes\n", m->om_len);
+ rc = mn_sendto(sock, m, NULL); /* assumes TCP for now */
+ if (rc) {
+ os_mbuf_free_chain(m);
+ if (rc != MN_ENOBUFS && rc != MN_EAGAIN) {
+ console_write(" sendto fail!!! %d\n", rc);
+ }
+ break;
+ }
+ } else {
+ /*
+ * Mbuf shortage. Wait for them to appear.
+ */
+ os_time_delay(1);
+ }
+ loop_cnt++;
+ } while (loop_cnt < 32);
+ break;
+ default:
+ assert(0);
+ break;
+ }
+ if ((int)ev->ev_arg == MN_SOCK_STREAM && idt->closed) {
+ /*
+ * Remote end has closed the connection, as indicated in the
+ * callback. Close the socket and free the memory.
+ */
+ mn_socket_set_cbs(idt->socket, NULL, NULL);
+ os_eventq_remove(&inet_def_evq, &idt->ev);
+ mn_close(idt->socket);
+ os_free(idt);
+ }
+ }
}
+#endif
void
inet_def_service_init(struct os_eventq *evq)
{
+ int i;
+
+ inet_def_create_srv(INET_DEF_ECHO, ECHO_PORT);
+ inet_def_create_srv(INET_DEF_DISCARD, DISCARD_PORT);
+ inet_def_create_srv(INET_DEF_CHARGEN, CHARGEN_PORT);
+
inet_def_evq = evq;
- os_eventq_ensure(&inet_def_evq, NULL);
SLIST_INIT(&inet_def.tcp_conns);
+ for (i = 0; i < 3; i++) {
+ inet_def.udp_service[i].ev.ide_type = i;
+ inet_def.udp_service[i].ev.ide_ev.ev_cb = inet_def_event;
+ inet_def.udp_service[i].ev.ide_ev.ev_arg = (void *)MN_SOCK_DGRAM;
+ }
}
[2/3] incubator-mynewt-core git commit: wifi;
bring back the task to get this to build again.
Posted by ma...@apache.org.
wifi; bring back the task to get this to build again.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/eefa203f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/eefa203f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/eefa203f
Branch: refs/heads/develop
Commit: eefa203fd730b08582c0f7b95d9526c244c18e24
Parents: 6031086
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Tue Nov 8 13:25:31 2016 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Tue Nov 8 13:25:31 2016 -0800
----------------------------------------------------------------------
net/wifi/wifi_mgmt/src/wifi.c | 27 +++++++++++----------------
1 file changed, 11 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/eefa203f/net/wifi/wifi_mgmt/src/wifi.c
----------------------------------------------------------------------
diff --git a/net/wifi/wifi_mgmt/src/wifi.c b/net/wifi/wifi_mgmt/src/wifi.c
index f0be059..75cdd6a 100644
--- a/net/wifi/wifi_mgmt/src/wifi.c
+++ b/net/wifi/wifi_mgmt/src/wifi.c
@@ -31,28 +31,15 @@
#include "wifi_priv.h"
static struct os_task wifi_os_task;
-struct os_eventq *wifi_evq;
+struct os_eventq wifi_evq;
static struct wifi_ap *wifi_find_ap(struct wifi_if *wi, char *ssid);
-static void wifi_events(void *arg);
+static void wifi_events(struct os_event *);
static void wifi_event_state(struct os_event *ev);
static struct wifi_if *wifi_if;
-static struct os_eventq *
-wifi_evq_get(void)
-{
- os_eventq_ensure(&wifi_evq, NULL);
- return wifi_evq;
-}
-
-void
-wifi_evq_set(struct os_eventq *evq)
-{
- os_eventq_designate(&wifi_evq, evq, NULL);
-}
-
/*
* Looks up interface based on port number.
*/
@@ -184,7 +171,7 @@ wifi_find_ap(struct wifi_if *wi, char *ssid)
}
static void
-wifi_events(void *arg)
+wifi_events(struct os_event *ev)
{
/*
* Expire connection attempts. Periodic scanning if tgt AP not visible.
@@ -334,6 +321,14 @@ wifi_event_state(struct os_event *ev)
}
}
+static void
+wifi_task(void *arg)
+{
+ while (1) {
+ os_eventq_run(&wifi_evq);
+ }
+}
+
int
wifi_task_init(uint8_t prio, os_stack_t *stack, uint16_t stack_size)
{
[3/3] incubator-mynewt-core git commit: shell;
adjust tasks cli command output a bit.
Posted by ma...@apache.org.
shell; adjust tasks cli command output a bit.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/ed475682
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/ed475682
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/ed475682
Branch: refs/heads/develop
Commit: ed475682d620382487748b45ecaede1ebb9cea0d
Parents: eefa203
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Tue Nov 8 13:26:24 2016 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Tue Nov 8 13:26:24 2016 -0800
----------------------------------------------------------------------
sys/shell/src/shell_os.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/ed475682/sys/shell/src/shell_os.c
----------------------------------------------------------------------
diff --git a/sys/shell/src/shell_os.c b/sys/shell/src/shell_os.c
index aa20419..14b8657 100644
--- a/sys/shell/src/shell_os.c
+++ b/sys/shell/src/shell_os.c
@@ -47,7 +47,7 @@ shell_os_tasks_display_cmd(int argc, char **argv)
console_printf("Tasks: \n");
prev_task = NULL;
- console_printf(" %8s %3s %3s %8s %8s %8s %8s %8s %8s %3s\n",
+ console_printf("%8s %3s %3s %8s %8s %8s %8s %8s %8s %3s\n",
"task", "pri", "tid", "runtime", "csw", "stksz", "stkuse",
"lcheck", "ncheck", "flg");
while (1) {
@@ -64,7 +64,7 @@ shell_os_tasks_display_cmd(int argc, char **argv)
}
}
- console_printf(" %8s %3u %3u %8lu %8lu %8u %8u %8lu %8lu %3x\n",
+ console_printf("%8s %3u %3u %8lu %8lu %8u %8u %8lu %8lu %3x\n",
oti.oti_name, oti.oti_prio, oti.oti_taskid,
(unsigned long)oti.oti_runtime, (unsigned long)oti.oti_cswcnt,
oti.oti_stksize, oti.oti_stkusage,