You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2016/11/01 19:53:52 UTC

incubator-mynewt-core git commit: Additional fixes required for evq callback change.

Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop 07c10e000 -> dd37e5886


Additional fixes required for evq callback change.

There were some apps that didn't set the default event queue.  As a
consequence, taskless packages failed to run.


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/dd37e588
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/dd37e588
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/dd37e588

Branch: refs/heads/develop
Commit: dd37e588618f492f9fa71df4803958c0982b8c4e
Parents: 07c10e0
Author: Christopher Collins <cc...@apache.org>
Authored: Tue Nov 1 12:52:54 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Tue Nov 1 12:52:54 2016 -0700

----------------------------------------------------------------------
 apps/ocf_sample/src/main.c               |  4 +-
 apps/slinky/src/main.c                   |  6 +--
 apps/slinky_oic/src/main.c               | 43 ++++++++++++++++-----
 apps/spitest/src/main.c                  | 51 ++++++++++++++++++++-----
 apps/timtest/src/main.c                  | 54 +++++++++++++++++++++------
 net/oic/src/port/mynewt/serial_adaptor.c | 11 +++---
 6 files changed, 126 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/dd37e588/apps/ocf_sample/src/main.c
----------------------------------------------------------------------
diff --git a/apps/ocf_sample/src/main.c b/apps/ocf_sample/src/main.c
index cc34bdb..2d7c93c 100644
--- a/apps/ocf_sample/src/main.c
+++ b/apps/ocf_sample/src/main.c
@@ -267,7 +267,7 @@ ocf_aux_task_handler(void *arg)
 }
 
 static void
-ocf_main_task_init(void)
+ocf_init_tasks(void)
 {
     int rc;
 
@@ -304,7 +304,7 @@ main(int argc, char **argv)
     ocf_ble_init();
 #endif
 
-    ocf_main_task_init();
+    ocf_init_tasks();
 
     /* Start the OS */
     os_start();

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/dd37e588/apps/slinky/src/main.c
----------------------------------------------------------------------
diff --git a/apps/slinky/src/main.c b/apps/slinky/src/main.c
index cb808de..500653b 100755
--- a/apps/slinky/src/main.c
+++ b/apps/slinky/src/main.c
@@ -50,9 +50,6 @@
 #include <mcu/mcu_sim.h>
 #endif
 
-/* Init all tasks */
-static volatile int tasks_initialized;
-
 /* Task 1 */
 #define TASK1_PRIO (8)
 #define TASK1_STACK_SIZE    OS_STACK_ALIGN(192)
@@ -239,6 +236,7 @@ static void
 init_tasks(void)
 {
     os_stack_t *pstack;
+
     /* Initialize global test semaphore */
     os_sem_init(&g_test_sem, 0);
 
@@ -266,8 +264,6 @@ init_tasks(void)
      */
     os_eventq_init(&slinky_evq);
     os_eventq_dflt_set(&slinky_evq);
-
-    tasks_initialized = 1;
 }
 
 /**

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/dd37e588/apps/slinky_oic/src/main.c
----------------------------------------------------------------------
diff --git a/apps/slinky_oic/src/main.c b/apps/slinky_oic/src/main.c
index b45f1f4..e26a3c0 100755
--- a/apps/slinky_oic/src/main.c
+++ b/apps/slinky_oic/src/main.c
@@ -43,10 +43,6 @@
 #include <mcu/mcu_sim.h>
 #endif
 
-/* Init all tasks */
-static volatile int tasks_initialized;
-int init_tasks(void);
-
 /* Task 1 */
 #define TASK1_PRIO (8)
 #define TASK1_STACK_SIZE    OS_STACK_ALIGN(192)
@@ -56,9 +52,16 @@ static volatile int g_task1_loops;
 
 /* Task 2 */
 #define TASK2_PRIO (9)
-#define TASK2_STACK_SIZE    OS_STACK_ALIGN(128)
+#define TASK2_STACK_SIZE    OS_STACK_ALIGN(64)
 static struct os_task task2;
 
+/* Task 3 */
+#define TASK3_PRIO (10)
+#define TASK3_STACK_SIZE    OS_STACK_ALIGN(384)
+static struct os_task task3;
+
+static struct os_eventq slinky_oic_evq;
+
 static struct log my_log;
 
 static volatile int g_task2_loops;
@@ -203,6 +206,18 @@ task2_handler(void *arg)
 }
 
 /**
+ * This task serves as a container for the shell and newtmgr packages.  These
+ * packages enqueue timer events when they need this task to do work.
+ */
+static void
+task3_handler(void *arg)
+{
+    while (1) {
+        os_eventq_run(&slinky_oic_evq);
+    }
+}
+
+/**
  * init_tasks
  *
  * Called by main.c after sysinit(). This function performs initializations
@@ -210,7 +225,7 @@ task2_handler(void *arg)
  *
  * @return int 0 success; error otherwise.
  */
-int
+static void
 init_tasks(void)
 {
     os_stack_t *pstack;
@@ -229,8 +244,18 @@ init_tasks(void)
     os_task_init(&task2, "task2", task2_handler, NULL,
             TASK2_PRIO, OS_WAIT_FOREVER, pstack, TASK2_STACK_SIZE);
 
-    tasks_initialized = 1;
-    return 0;
+    pstack = malloc(sizeof(os_stack_t)*TASK3_STACK_SIZE);
+    assert(pstack);
+
+    os_task_init(&task3, "task3", task3_handler, NULL,
+            TASK3_PRIO, OS_WAIT_FOREVER, pstack, TASK3_STACK_SIZE);
+
+    /* Initialize eventq and designate it as the default.  Packages that need
+     * to schedule work items will piggyback on this eventq.  Example packages
+     * which do this are sys/shell and mgmt/newtmgr.
+     */
+    os_eventq_init(&slinky_oic_evq);
+    os_eventq_dflt_set(&slinky_oic_evq);
 }
 
 /**
@@ -279,7 +304,7 @@ main(int argc, char **argv)
     }
 #endif
 
-    rc = init_tasks();
+    init_tasks();
 
     os_start();
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/dd37e588/apps/spitest/src/main.c
----------------------------------------------------------------------
diff --git a/apps/spitest/src/main.c b/apps/spitest/src/main.c
index 792923a..5927af8 100755
--- a/apps/spitest/src/main.c
+++ b/apps/spitest/src/main.c
@@ -45,15 +45,17 @@ struct sblinky_spi_cb_arg
 struct sblinky_spi_cb_arg spi_cb_obj;
 void *spi_cb_arg;
 
-/* Init all tasks */
-volatile int tasks_initialized;
-int init_tasks(void);
-
 /* Task 1 */
 #define TASK1_PRIO (1)
 #define TASK1_STACK_SIZE    OS_STACK_ALIGN(1024)
 struct os_task task1;
-os_stack_t stack1[TASK1_STACK_SIZE];
+
+/* Task 3 */
+#define TASK2_PRIO (2)
+#define TASK2_STACK_SIZE    OS_STACK_ALIGN(384)
+static struct os_task task2;
+
+static struct os_eventq spitest_evq;
 
 /* Global test semaphore */
 struct os_sem g_test_sem;
@@ -390,6 +392,18 @@ task1_handler(void *arg)
 #endif
 
 /**
+ * This task serves as a container for the shell and newtmgr packages.  These
+ * packages enqueue timer events when they need this task to do work.
+ */
+static void
+task2_handler(void *arg)
+{
+    while (1) {
+        os_eventq_run(&spitest_evq);
+    }
+}
+
+/**
  * init_tasks
  *
  * Called by main.c after sysinit(). This function performs initializations
@@ -397,17 +411,34 @@ task1_handler(void *arg)
  *
  * @return int 0 success; error otherwise.
  */
-int
+static void
 init_tasks(void)
 {
+    os_stack_t *pstack;
+
     /* Initialize global test semaphore */
     os_sem_init(&g_test_sem, 0);
 
+#ifdef SPI_SLAVE
+    pstack = malloc(sizeof(os_stack_t)*TASK1_STACK_SIZE);
+    assert(pstack);
+
     os_task_init(&task1, "task1", task1_handler, NULL,
-            TASK1_PRIO, OS_WAIT_FOREVER, stack1, TASK1_STACK_SIZE);
+            TASK1_PRIO, OS_WAIT_FOREVER, pstack, TASK1_STACK_SIZE);
+#endif
+
+    pstack = malloc(sizeof(os_stack_t)*TASK2_STACK_SIZE);
+    assert(pstack);
 
-    tasks_initialized = 1;
-    return 0;
+    os_task_init(&task2, "task2", task2_handler, NULL,
+            TASK2_PRIO, OS_WAIT_FOREVER, pstack, TASK2_STACK_SIZE);
+
+    /* Initialize eventq and designate it as the default.  Packages that need
+     * to schedule work items will piggyback on this eventq.  Example packages
+     * which do this are sys/shell and mgmt/newtmgr.
+     */
+    os_eventq_init(&spitest_evq);
+    os_eventq_dflt_set(&spitest_evq);
 }
 
 /**
@@ -429,7 +460,7 @@ main(int argc, char **argv)
 #endif
 
     sysinit();
-    rc = init_tasks();
+    init_tasks();
     os_start();
 
     /* os start should never return. If it does, this should be an error */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/dd37e588/apps/timtest/src/main.c
----------------------------------------------------------------------
diff --git a/apps/timtest/src/main.c b/apps/timtest/src/main.c
index 8fea4b6..d55ced0 100755
--- a/apps/timtest/src/main.c
+++ b/apps/timtest/src/main.c
@@ -27,15 +27,10 @@
 #include <assert.h>
 #include <string.h>
 
-/* Init all tasks */
-volatile int tasks_initialized;
-int init_tasks(void);
-
 /* Task 1 */
 #define TASK1_PRIO (1)
 #define TASK1_STACK_SIZE    OS_STACK_ALIGN(64)
 struct os_task task1;
-os_stack_t stack1[TASK1_STACK_SIZE];
 
 #define TASK1_TIMER_NUM     (1)
 #define TASK1_TIMER_FREQ    (4000000)
@@ -44,7 +39,13 @@ os_stack_t stack1[TASK1_STACK_SIZE];
 #define TASK2_PRIO (2)
 #define TASK2_STACK_SIZE    OS_STACK_ALIGN(64)
 struct os_task task2;
-os_stack_t stack2[TASK2_STACK_SIZE];
+
+/* Task 3 */
+#define TASK3_PRIO (3)
+#define TASK3_STACK_SIZE    OS_STACK_ALIGN(384)
+static struct os_task task3;
+
+static struct os_eventq timtest_evq;
 
 #define TASK2_TIMER_NUM     (2)
 #define TASK2_TIMER_FREQ    (31250)
@@ -144,6 +145,18 @@ task2_handler(void *arg)
 }
 
 /**
+ * This task serves as a container for the shell and newtmgr packages.  These
+ * packages enqueue timer events when they need this task to do work.
+ */
+static void
+task3_handler(void *arg)
+{
+    while (1) {
+        os_eventq_run(&timtest_evq);
+    }
+}
+
+/**
  * init_tasks
  *
  * Called by main.c after sysinit(). This function performs initializations
@@ -151,11 +164,12 @@ task2_handler(void *arg)
  *
  * @return int 0 success; error otherwise.
  */
-int
+static void
 init_tasks(void)
 {
     int rc;
     uint32_t res;
+    os_stack_t *pstack;
 
     /* Initialize global test semaphore */
     os_sem_init(&g_test_sem, 0);
@@ -174,14 +188,30 @@ init_tasks(void)
     res = hal_timer_get_resolution(TASK2_TIMER_NUM);
     assert(res == (1000000000 / TASK2_TIMER_FREQ));
 
+    pstack = malloc(sizeof(os_stack_t)*TASK1_STACK_SIZE);
+    assert(pstack);
+
     os_task_init(&task1, "task1", task1_handler, NULL,
-            TASK1_PRIO, OS_WAIT_FOREVER, stack1, TASK1_STACK_SIZE);
+            TASK1_PRIO, OS_WAIT_FOREVER, pstack, TASK1_STACK_SIZE);
+
+    pstack = malloc(sizeof(os_stack_t)*TASK1_STACK_SIZE);
+    assert(pstack);
 
     os_task_init(&task2, "task2", task2_handler, NULL,
-            TASK2_PRIO, OS_WAIT_FOREVER, stack2, TASK2_STACK_SIZE);
+            TASK2_PRIO, OS_WAIT_FOREVER, pstack, TASK2_STACK_SIZE);
+
+    pstack = malloc(sizeof(os_stack_t)*TASK3_STACK_SIZE);
+    assert(pstack);
+
+    os_task_init(&task3, "task3", task3_handler, NULL,
+            TASK3_PRIO, OS_WAIT_FOREVER, pstack, TASK3_STACK_SIZE);
 
-    tasks_initialized = 1;
-    return 0;
+    /* Initialize eventq and designate it as the default.  Packages that need
+     * to schedule work items will piggyback on this eventq.  Example packages
+     * which do this are sys/shell and mgmt/newtmgr.
+     */
+    os_eventq_init(&timtest_evq);
+    os_eventq_dflt_set(&timtest_evq);
 }
 
 /**
@@ -199,7 +229,7 @@ main(int argc, char **argv)
     int rc;
 
     sysinit();
-    rc = init_tasks();
+    init_tasks();
     os_start();
 
     assert(0);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/dd37e588/net/oic/src/port/mynewt/serial_adaptor.c
----------------------------------------------------------------------
diff --git a/net/oic/src/port/mynewt/serial_adaptor.c b/net/oic/src/port/mynewt/serial_adaptor.c
index 5bb676d..e1d20c0 100644
--- a/net/oic/src/port/mynewt/serial_adaptor.c
+++ b/net/oic/src/port/mynewt/serial_adaptor.c
@@ -33,7 +33,7 @@ struct os_mqueue oc_serial_mqueue;
 static int
 oc_serial_in(struct os_mbuf *m, void *arg)
 {
-    return os_mqueue_put(&oc_serial_mqueue, oc_evq(), m);
+    return os_mqueue_put(&oc_serial_mqueue, oc_evq_get(), m);
 }
 
 void
@@ -60,12 +60,11 @@ oc_connectivity_init_serial(void) {
         goto err;
     }
 
-    rc = os_mqueue_init(&oc_serial_mqueue, NULL);
+    rc = os_mqueue_init(&oc_serial_mqueue, oc_event_serial, NULL);
     if (rc != 0) {
         goto err;
     }
-    /* override the eventq type */
-    oc_serial_mqueue.mq_ev.ev_cb = oc_event_serial;
+
     return 0;
 
 err:
@@ -74,7 +73,9 @@ err:
 }
 
 
-void oc_send_buffer_serial(oc_message_t *message) {
+void
+oc_send_buffer_serial(oc_message_t *message)
+{
     int rc;
     struct os_mbuf *m;