[1/2] incubator-mynewt-larva git commit: If a task was waiting on a semaphore with a timeout and the timeout occurred, the task was not removed from the list of tasks waiting on the semaphore. Modify

2015-12-03 Thread wes3
Repository: incubator-mynewt-larva
Updated Branches:
  refs/heads/master f945610a8 -> 61e8c4733


If a task was waiting on a semaphore with a timeout and the timeout occurred, 
the task was not removed from the list of tasks waiting on the semaphore. 
Modify semaphore, mutex and task code to use the same pointer (t_obj) in the 
task structure when a task is waiting on an object. Add mutex wait flag (set 
when a task is waiting on a mutex) and add simple tests


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/61e8c473
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/61e8c473
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/61e8c473

Branch: refs/heads/master
Commit: 61e8c4733ecd00c2037030284d0eb84f401242a5
Parents: 3b25ce3
Author: wes3 
Authored: Thu Dec 3 23:23:41 2015 -0800
Committer: wes3 
Committed: Thu Dec 3 23:23:51 2015 -0800

--
 libs/os/include/os/os_mutex.h |  2 +-
 libs/os/include/os/os_sem.h   |  2 +-
 libs/os/include/os/os_task.h  | 15 ++-
 libs/os/src/os_mutex.c| 19 ---
 libs/os/src/os_sched.c| 13 -
 libs/os/src/os_sem.c  | 11 +++
 libs/os/src/test/mutex_test.c |  9 +
 libs/os/src/test/sem_test.c   |  2 +-
 8 files changed, 45 insertions(+), 28 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/61e8c473/libs/os/include/os/os_mutex.h
--
diff --git a/libs/os/include/os/os_mutex.h b/libs/os/include/os/os_mutex.h
index 716ba60..a16c370 100644
--- a/libs/os/include/os/os_mutex.h
+++ b/libs/os/include/os/os_mutex.h
@@ -22,11 +22,11 @@
 
 struct os_mutex
 {
+SLIST_HEAD(, os_task) mu_head;  /* chain of waiting tasks */
 uint8_t _pad;
 uint8_t mu_prio;/* owner's default priority*/
 uint16_tmu_level;   /* call nesting level */
 struct os_task *mu_owner;   /* owners task */
-SLIST_HEAD(, os_task) mu_head;  /* chain of waiting tasks */
 };
 
 /* 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/61e8c473/libs/os/include/os/os_sem.h
--
diff --git a/libs/os/include/os/os_sem.h b/libs/os/include/os/os_sem.h
index 73e84ee..b0eb8bf 100644
--- a/libs/os/include/os/os_sem.h
+++ b/libs/os/include/os/os_sem.h
@@ -21,9 +21,9 @@
 
 struct os_sem
 {
+SLIST_HEAD(, os_task) sem_head; /* chain of waiting tasks */
 uint16_t_pad;
 uint16_tsem_tokens; /* # of tokens */
-SLIST_HEAD(, os_task) sem_head; /* chain of waiting tasks */
 };
 
 /* 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/61e8c473/libs/os/include/os/os_task.h
--
diff --git a/libs/os/include/os/os_task.h b/libs/os/include/os/os_task.h
index 3f75432..ae44a73 100644
--- a/libs/os/include/os/os_task.h
+++ b/libs/os/include/os/os_task.h
@@ -29,6 +29,18 @@
 #define OS_TASK_NAME_SIZE (36) 
 #endif 
 
+/* 
+ * Generic "object" structure. All objects that a task can wait on must
+ * have a SLIST_HEAD(, os_task) head_name as the first element in the object 
+ * structure. The element 'head_name' can be any name. See os_mutex.h or
+ * os_sem.h for an example.
+ */
+struct os_task_obj
+{
+SLIST_HEAD(, os_task) obj_head; /* chain of waiting tasks */
+};
+
+/* Task states */
 typedef enum os_task_state {
 OS_TASK_READY = 1, 
 OS_TASK_SLEEP = 2
@@ -37,6 +49,7 @@ typedef enum os_task_state {
 /* Task flags */
 #define OS_TASK_FLAG_NO_TIMEOUT (0x0001U)
 #define OS_TASK_FLAG_SEM_WAIT   (0x0002U)
+#define OS_TASK_FLAG_MUTEX_WAIT (0x0004U)
 
 typedef void (*os_task_func_t)(void *);
 
@@ -54,7 +67,7 @@ struct os_task {
 os_task_func_t t_func;
 void *t_arg;
 
-struct os_mutex *t_mutex;
+void *t_obj;
 
 struct os_sanity_check t_sanity_check; 
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/61e8c473/libs/os/src/os_mutex.c
--
diff --git a/libs/os/src/os_mutex.c b/libs/os/src/os_mutex.c
index 3ad3151..0965be8 100644
--- a/libs/os/src/os_mutex.c
+++ b/libs/os/src/os_mutex.c
@@ -98,11 +98,7 @@ os_mutex_release(struct os_mutex *mu)
 rdy = SLIST_FIRST(>mu_head);
 if (rdy) {
 /* There is one waiting. Wake it up */
-assert(rdy->t_mutex);
-rdy->t_mutex = NULL;
-
-SLIST_REMOVE_HEAD(>mu_head, t_obj_list);
-SLIST_NEXT(rdy, t_obj_list) = NULL;
+assert(rdy->t_obj);
 os_sched_wakeup(rdy);
 
 /* Set mutex internals */
@@ 

[2/2] incubator-mynewt-larva git commit: Need to add stdint.h for some targets

2015-12-03 Thread wes3
Need to add stdint.h for some targets


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/3b25ce3d
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/3b25ce3d
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/3b25ce3d

Branch: refs/heads/master
Commit: 3b25ce3d3e0c55fc24c1c0925e1fdbef70f8e3e5
Parents: f945610
Author: wes3 
Authored: Thu Dec 3 23:19:56 2015 -0800
Committer: wes3 
Committed: Thu Dec 3 23:23:51 2015 -0800

--
 libs/util/include/util/base64.h | 2 ++
 1 file changed, 2 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/3b25ce3d/libs/util/include/util/base64.h
--
diff --git a/libs/util/include/util/base64.h b/libs/util/include/util/base64.h
index 8d978c5..fff40fd 100644
--- a/libs/util/include/util/base64.h
+++ b/libs/util/include/util/base64.h
@@ -16,6 +16,8 @@
 #ifndef __UTIL_BASE64_H 
 #define __UTIL_BASE64_H 
 
+#include 
+
 int base64_encode(const void *, int, char *, uint8_t);
 int base64_decode(const char *, void *buf);
 



[1/3] incubator-mynewt-larva git commit: Rename ble_hs_att_* to ble_att_*

2015-12-03 Thread ccollins
Repository: incubator-mynewt-larva
Updated Branches:
  refs/heads/master 8598e84fb -> 31f0c10b6


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/31f0c10b/net/nimble/host/src/test/ble_hs_att_svr_test.c
--
diff --git a/net/nimble/host/src/test/ble_hs_att_svr_test.c 
b/net/nimble/host/src/test/ble_hs_att_svr_test.c
index 4cd7045..c7fff45 100644
--- a/net/nimble/host/src/test/ble_hs_att_svr_test.c
+++ b/net/nimble/host/src/test/ble_hs_att_svr_test.c
@@ -24,19 +24,19 @@
 #include "ble_l2cap.h"
 #include "ble_hs_test_util.h"
 #include "ble_hs_conn.h"
-#include "ble_hs_att.h"
-#include "ble_hs_att_cmd.h"
+#include "ble_att.h"
+#include "ble_att_cmd.h"
 
-static uint8_t *ble_hs_att_svr_test_attr_r_1;
-static int ble_hs_att_svr_test_attr_r_1_len;
-static uint8_t *ble_hs_att_svr_test_attr_r_2;
-static int ble_hs_att_svr_test_attr_r_2_len;
+static uint8_t *ble_att_svr_test_attr_r_1;
+static int ble_att_svr_test_attr_r_1_len;
+static uint8_t *ble_att_svr_test_attr_r_2;
+static int ble_att_svr_test_attr_r_2_len;
 
-static uint8_t ble_hs_att_svr_test_attr_w_1[1024];
-static int ble_hs_att_svr_test_attr_w_1_len;
+static uint8_t ble_att_svr_test_attr_w_1[1024];
+static int ble_att_svr_test_attr_w_1_len;
 
 static void
-ble_hs_att_svr_test_misc_init(struct ble_hs_conn **conn,
+ble_att_svr_test_misc_init(struct ble_hs_conn **conn,
   struct ble_l2cap_chan **att_chan)
 {
 ble_hs_test_util_init();
@@ -50,14 +50,14 @@ ble_hs_att_svr_test_misc_init(struct ble_hs_conn **conn,
 }
 
 static int
-ble_hs_att_svr_test_misc_attr_fn_r_1(struct ble_hs_att_svr_entry *entry,
+ble_att_svr_test_misc_attr_fn_r_1(struct ble_att_svr_entry *entry,
  uint8_t op,
- union ble_hs_att_svr_handle_arg *arg)
+ union ble_att_svr_handle_arg *arg)
 {
 switch (op) {
-case BLE_HS_ATT_OP_READ_REQ:
-arg->aha_read.attr_data = ble_hs_att_svr_test_attr_r_1;
-arg->aha_read.attr_len = ble_hs_att_svr_test_attr_r_1_len;
+case BLE_ATT_OP_READ_REQ:
+arg->aha_read.attr_data = ble_att_svr_test_attr_r_1;
+arg->aha_read.attr_len = ble_att_svr_test_attr_r_1_len;
 return 0;
 
 default:
@@ -66,14 +66,14 @@ ble_hs_att_svr_test_misc_attr_fn_r_1(struct 
ble_hs_att_svr_entry *entry,
 }
 
 static int
-ble_hs_att_svr_test_misc_attr_fn_r_2(struct ble_hs_att_svr_entry *entry,
+ble_att_svr_test_misc_attr_fn_r_2(struct ble_att_svr_entry *entry,
  uint8_t op,
- union ble_hs_att_svr_handle_arg *arg)
+ union ble_att_svr_handle_arg *arg)
 {
 switch (op) {
-case BLE_HS_ATT_OP_READ_REQ:
-arg->aha_read.attr_data = ble_hs_att_svr_test_attr_r_2;
-arg->aha_read.attr_len = ble_hs_att_svr_test_attr_r_2_len;
+case BLE_ATT_OP_READ_REQ:
+arg->aha_read.attr_data = ble_att_svr_test_attr_r_2;
+arg->aha_read.attr_len = ble_att_svr_test_attr_r_2_len;
 return 0;
 
 default:
@@ -82,20 +82,20 @@ ble_hs_att_svr_test_misc_attr_fn_r_2(struct 
ble_hs_att_svr_entry *entry,
 }
 
 static int
-ble_hs_att_svr_test_misc_attr_fn_w_1(struct ble_hs_att_svr_entry *entry,
+ble_att_svr_test_misc_attr_fn_w_1(struct ble_att_svr_entry *entry,
  uint8_t op,
- union ble_hs_att_svr_handle_arg *arg)
+ union ble_att_svr_handle_arg *arg)
 {
 struct os_mbuf_pkthdr *omp;
 int rc;
 
 switch (op) {
-case BLE_HS_ATT_OP_WRITE_REQ:
+case BLE_ATT_OP_WRITE_REQ:
 omp = OS_MBUF_PKTHDR(arg->aha_write.om);
 rc = os_mbuf_copydata(arg->aha_write.om, 0, arg->aha_write.attr_len,
-  ble_hs_att_svr_test_attr_w_1);
+  ble_att_svr_test_attr_w_1);
 TEST_ASSERT(rc == 0);
-ble_hs_att_svr_test_attr_w_1_len = arg->aha_write.attr_len;
+ble_att_svr_test_attr_w_1_len = arg->aha_write.attr_len;
 return 0;
 
 default:
@@ -106,18 +106,18 @@ ble_hs_att_svr_test_misc_attr_fn_w_1(struct 
ble_hs_att_svr_entry *entry,
 }
 
 static void
-ble_hs_att_svr_test_misc_verify_tx_err_rsp(struct ble_l2cap_chan *chan,
+ble_att_svr_test_misc_verify_tx_err_rsp(struct ble_l2cap_chan *chan,
uint8_t req_op, uint16_t handle,
uint8_t error_code)
 {
-struct ble_hs_att_error_rsp rsp;
-uint8_t buf[BLE_HS_ATT_ERROR_RSP_SZ];
+struct ble_att_error_rsp rsp;
+uint8_t buf[BLE_ATT_ERROR_RSP_SZ];
 int rc;
 
 rc = os_mbuf_copydata(ble_hs_test_util_prev_tx, 0, sizeof buf, buf);
 TEST_ASSERT(rc == 0);
 
-rc = ble_hs_att_error_rsp_parse(buf, sizeof buf, );
+rc = ble_att_error_rsp_parse(buf, sizeof buf, );
  

incubator-mynewt-larva git commit: Add calls to os_mbuf_pullup; more GATT.

2015-12-03 Thread ccollins
Repository: incubator-mynewt-larva
Updated Branches:
  refs/heads/master 31f0c10b6 -> bf65252ed


Add calls to os_mbuf_pullup; more GATT.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/bf65252e
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/bf65252e
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/bf65252e

Branch: refs/heads/master
Commit: bf65252ed86acd84ab3f1219ae1fbd2ddbb31c58
Parents: 31f0c10
Author: Christopher Collins 
Authored: Thu Dec 3 14:33:06 2015 -0800
Committer: Christopher Collins 
Committed: Thu Dec 3 14:33:06 2015 -0800

--
 net/nimble/host/include/host/ble_gatt.h|  18 ++
 net/nimble/host/src/ble_att.c  |   8 +-
 net/nimble/host/src/ble_att.h  |  34 ++--
 net/nimble/host/src/ble_att_clt.c  | 204 
 net/nimble/host/src/ble_att_cmd.c  |  74 ---
 net/nimble/host/src/ble_att_cmd.h  |   4 +-
 net/nimble/host/src/ble_att_svr.c  | 115 ++-
 net/nimble/host/src/ble_gatt.c | 110 ++-
 net/nimble/host/src/ble_hs.c   |   5 -
 net/nimble/host/src/ble_hs_conn.c  |   2 -
 net/nimble/host/src/ble_l2cap.c|   2 +-
 net/nimble/host/src/ble_l2cap.h|   2 +-
 net/nimble/host/src/ble_l2cap_sig.c|   2 +-
 net/nimble/host/src/test/ble_hs_att_clt_test.c |  32 +--
 net/nimble/host/src/test/ble_hs_att_svr_test.c |   2 +-
 15 files changed, 277 insertions(+), 337 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/bf65252e/net/nimble/host/include/host/ble_gatt.h
--
diff --git a/net/nimble/host/include/host/ble_gatt.h 
b/net/nimble/host/include/host/ble_gatt.h
index d1d6084..de1fc73 100644
--- a/net/nimble/host/include/host/ble_gatt.h
+++ b/net/nimble/host/include/host/ble_gatt.h
@@ -4,6 +4,21 @@
 #include 
 struct ble_hs_conn;
 struct ble_att_error_rsp;
+struct ble_att_clt_adata;
+
+struct ble_gatt_service {
+uint16_t start_handle;
+uint16_t end_handle;
+uint8_t uuid128[16];
+};
+
+typedef int ble_gatt_disc_service_fn(uint16_t conn_handle,
+ struct ble_att_clt_adata *adata,
+ void *arg);
+
+int ble_gatt_disc_all_services(uint16_t conn_handle,
+   ble_gatt_disc_service_fn *cb,
+   void *cb_arg);
 
 void ble_gatt_rx_error(struct ble_hs_conn *conn,
struct ble_att_error_rsp *rsp);
@@ -12,6 +27,9 @@ void ble_gatt_rx_mtu(struct ble_hs_conn *conn, uint16_t 
chan_mtu);
 int ble_gatt_mtu(uint16_t conn_handle);
 void ble_gatt_rx_find_info(struct ble_hs_conn *conn, int status,
uint16_t last_handle_id);
+void ble_gatt_rx_read_group_type_adata(struct ble_hs_conn *conn,
+   struct ble_att_clt_adata *adata);
+void ble_gatt_rx_read_group_type_complete(struct ble_hs_conn *conn, int rc);
 int ble_gatt_find_info(uint16_t conn_handle_id, uint16_t att_start_handle,
uint16_t att_end_handle);
 int ble_gatt_init(void);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/bf65252e/net/nimble/host/src/ble_att.c
--
diff --git a/net/nimble/host/src/ble_att.c b/net/nimble/host/src/ble_att.c
index 3d2dc7a..1f63ac6 100644
--- a/net/nimble/host/src/ble_att.c
+++ b/net/nimble/host/src/ble_att.c
@@ -22,8 +22,8 @@
 
 /** Dispatch table for incoming ATT requests.  Sorted by op code. */
 typedef int ble_att_rx_fn(struct ble_hs_conn *conn,
- struct ble_l2cap_chan *chan,
- struct os_mbuf *om);
+  struct ble_l2cap_chan *chan,
+  struct os_mbuf **om);
 struct ble_att_rx_dispatch_entry {
 uint8_t bde_op;
 ble_att_rx_fn *bde_fn;
@@ -65,13 +65,13 @@ ble_att_rx_dispatch_entry_find(uint8_t op)
 
 static int
 ble_att_rx(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan,
-   struct os_mbuf *om)
+   struct os_mbuf **om)
 {
 struct ble_att_rx_dispatch_entry *entry;
 uint8_t op;
 int rc;
 
-rc = os_mbuf_copydata(om, 0, 1, );
+rc = os_mbuf_copydata(*om, 0, 1, );
 if (rc != 0) {
 return EMSGSIZE;
 }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/bf65252e/net/nimble/host/src/ble_att.h
--
diff --git a/net/nimble/host/src/ble_att.h 

[2/2] incubator-mynewt-larva git commit: Fix issues with starting a timer that has already been set. Assert if that happens

2015-12-03 Thread wes3
Fix issues with starting a timer that has already been set. Assert if that 
happens


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/165affba
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/165affba
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/165affba

Branch: refs/heads/master
Commit: 165affbad1018bd553372d31d69d5cbb9a2ae54a
Parents: bf65252
Author: wes3 
Authored: Thu Dec 3 15:19:13 2015 -0800
Committer: wes3 
Committed: Thu Dec 3 15:35:50 2015 -0800

--
 hw/mcu/nordic/nrf52xxx/src/hal_cputime.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/165affba/hw/mcu/nordic/nrf52xxx/src/hal_cputime.c
--
diff --git a/hw/mcu/nordic/nrf52xxx/src/hal_cputime.c 
b/hw/mcu/nordic/nrf52xxx/src/hal_cputime.c
index fa56939..6f43740 100644
--- a/hw/mcu/nordic/nrf52xxx/src/hal_cputime.c
+++ b/hw/mcu/nordic/nrf52xxx/src/hal_cputime.c
@@ -110,6 +110,7 @@ cputime_chk_expiration(void)
 while ((timer = TAILQ_FIRST(_cputimer_q)) != NULL) {
 if ((int32_t)(cputime_get32() - timer->cputime) >= 0) {
 TAILQ_REMOVE(_cputimer_q, timer, link);
+timer->link.tqe_prev = NULL;
 timer->cb(timer->arg);
 } else {
 break;
@@ -474,6 +475,7 @@ cputime_timer_init(struct cpu_timer *timer, cputimer_func 
fp, void *arg)
  *  
  * Start a cputimer that will expire at 'cputime'. If cputime has already 
  * passed, the timer callback will still be called (at interrupt context). 
+ * Cannot be called when the timer has already started. 
  * 
  * @param timer Pointer to timer to start. Cannot be NULL.
  * @param cputime   The cputime at which the timer should expire.
@@ -485,6 +487,7 @@ cputime_timer_start(struct cpu_timer *timer, uint32_t 
cputime)
 uint32_t ctx;
 
 assert(timer != NULL);
+assert(timer->link.tqe_prev == NULL);
 
 /* XXX: should this use a mutex? not sure... */
 __HAL_DISABLE_INTERRUPTS(ctx);
@@ -537,7 +540,7 @@ cputime_timer_relative(struct cpu_timer *timer, uint32_t 
usecs)
  *  
  * Stops a cputimer from running. The timer is removed from the timer queue 
  * and interrupts are disabled if no timers are left on the queue. Can be 
- * called even if timer is running. 
+ * called even if timer is not running. 
  * 
  * @param timer Pointer to cputimer to stop. Cannot be NULL.
  */
@@ -552,14 +555,15 @@ cputime_timer_stop(struct cpu_timer *timer)
 
 __HAL_DISABLE_INTERRUPTS(ctx);
 
-/* If first on queue, we will need to reset OCMP */
 if (timer->link.tqe_prev != NULL) {
 reset_ocmp = 0;
 if (timer == TAILQ_FIRST(_cputimer_q)) {
+/* If first on queue, we will need to reset OCMP */
 entry = TAILQ_NEXT(timer, link);
 reset_ocmp = 1;
 }
 TAILQ_REMOVE(_cputimer_q, timer, link);
+timer->link.tqe_prev = NULL;
 if (reset_ocmp) {
 if (entry) {
 cputime_set_ocmp(entry);



[1/2] incubator-mynewt-newt git commit: Move newtvm so that it is a sibling of newt.

2015-12-03 Thread ccollins
Repository: incubator-mynewt-newt
Updated Branches:
  refs/heads/master 8a61764b4 -> acd9c3337


Move newtvm so that it is a sibling of newt.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/52e1f4c9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/52e1f4c9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/52e1f4c9

Branch: refs/heads/master
Commit: 52e1f4c9fdc856b044e4fcebe9dafb67d12ae2e5
Parents: 8a61764
Author: Christopher Collins 
Authored: Thu Dec 3 16:33:13 2015 -0800
Committer: Christopher Collins 
Committed: Thu Dec 3 16:33:13 2015 -0800

--
 newtvm/newtvm.go | 174 ++
 1 file changed, 174 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/52e1f4c9/newtvm/newtvm.go
--
diff --git a/newtvm/newtvm.go b/newtvm/newtvm.go
new file mode 100644
index 000..09274ce
--- /dev/null
+++ b/newtvm/newtvm.go
@@ -0,0 +1,174 @@
+// newtvm is a Windows wrapper for the newt tool.  It runs the specified
+// commands within a Linux docker instance, giving access to newt and the
+// utilities that it depends on.
+
+package main
+
+import (
+   "bufio"
+   "fmt"
+   "io"
+   "os"
+   "os/exec"
+   "regexp"
+   "strings"
+)
+
+const debug bool = false
+const dockerMachineName string = "default"
+const newtvmImage = "mynewt/mynewt"
+const newtvmVersion = "0.0.2"
+
+// Sets the necessary environment variables to allow docker to run.
+func configEnv() error {
+   re, err := regexp.Compile("^SET ([^ ]+)=(.+)")
+   if err != nil {
+   return err
+   }
+
+   cmd := exec.Command("docker-machine", "env", "--shell", "cmd", 
"default")
+   outputBytes, err := cmd.CombinedOutput()
+   if err != nil {
+   return err
+   }
+
+   output := string(outputBytes[:])
+   lines := strings.Split(output, "\n")
+
+   for _, line := range lines {
+   matches := re.FindStringSubmatch(line)
+   if matches != nil {
+   if debug {
+   fmt.Fprintf(os.Stderr, "os.Setenv(\"%s\", 
\"%s\")\n",
+   matches[1], matches[2])
+   }
+   err = os.Setenv(matches[1], matches[2])
+   if err != nil {
+   return err
+   }
+   }
+   }
+
+   return nil
+}
+
+// Calculates a virtualbox-compatible representation of the present working
+// directory.
+//
+// E.g.,
+// C:\Users\me\Documents
+//
+// becomes:
+// /c/Users/me/documents
+func fixedPwd() (string, error) {
+   var pwd string
+   var err error
+
+   if pwd, err = os.Getwd(); err != nil {
+   return "", err
+   }
+
+   // Begin with a slash; convert drive letter to lowercase.
+   pwd = "/" + strings.ToLower(pwd[0:1]) + pwd[2:]
+
+   // Replace backslashes with slashes.
+   pwd = strings.Replace(pwd, "\\", "/", -1)
+
+   return pwd, nil
+}
+
+// Constructs a command that will run the specified shell tokens in the
+// docker environment.
+//
+// E.g., the args parameter might be: { "echo", "'hello", "world'" }
+func buildCmd(args []string) (*exec.Cmd, error) {
+   pwd, err := fixedPwd()
+   if err != nil {
+   return nil, err
+   }
+
+   fullArgs := []string{
+   "run", "--rm=true", "-v", fmt.Sprintf("%s:/larva", pwd),
+   "-w", "/larva", fmt.Sprintf("%s:%s", newtvmImage, 
newtvmVersion),
+   "script", "-qc",
+   strings.Join(args, " "), "/dev/null"}
+
+   return exec.Command("docker", fullArgs...), nil
+}
+
+// Executes the specified command, displaying output as it is generated.
+func execCmd(cmd *exec.Cmd) error {
+   // Reader / scanner pair for printing stdout output.
+   stdoutReader, err := cmd.StdoutPipe()
+   if err != nil {
+   return err
+   }
+
+   stdoutScanner := bufio.NewScanner(stdoutReader)
+   go func() {
+   for stdoutScanner.Scan() {
+   fmt.Println(stdoutScanner.Text())
+   }
+   }()
+
+   // Reader / scanner pair for printing stderr output.
+   stderrReader, err := cmd.StderrPipe()
+   if err != nil {
+   return err
+   }
+
+   stderrScanner := bufio.NewScanner(stderrReader)
+   go func() {
+   for stderrScanner.Scan() {
+   fmt.Fprintln(os.Stderr, stderrScanner.Text())
+   }
+   }()
+
+   

incubator-mynewt-newt git commit: change the incubator path

2015-12-03 Thread sterling
Repository: incubator-mynewt-newt
Updated Branches:
  refs/heads/master acd9c3337 -> cf1f9dd26


change the incubator path


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/cf1f9dd2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/cf1f9dd2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/cf1f9dd2

Branch: refs/heads/master
Commit: cf1f9dd26c4e88d6216795627da44c9f2595ed84
Parents: acd9c33
Author: Sterling Hughes 
Authored: Thu Dec 3 16:38:50 2015 -0800
Committer: Sterling Hughes 
Committed: Thu Dec 3 16:38:59 2015 -0800

--
 newt/newt.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/cf1f9dd2/newt/newt.go
--
diff --git a/newt/newt.go b/newt/newt.go
index 86d32b4..236602b 100644
--- a/newt/newt.go
+++ b/newt/newt.go
@@ -17,7 +17,7 @@ package main
 
 import (
"fmt"
-   "git-wip-us.apache.org/repos/asf/incubator-mynewt-newt.git/newt/cli"
+   "git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/newt/cli"
"github.com/spf13/cobra"
"log"
"os"



incubator-mynewt-larva git commit: Make sure directory name ends in '/' before trying to inspect files within that directory.

2015-12-03 Thread marko
Repository: incubator-mynewt-larva
Updated Branches:
  refs/heads/master 6a4288c93 -> 3de06a111


Make sure directory name ends in '/' before trying to inspect
files within that directory.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/3de06a11
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/3de06a11
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/3de06a11

Branch: refs/heads/master
Commit: 3de06a1115deba319fbd98ca7bf948a0e9016a6c
Parents: 6a4288c
Author: Marko Kiiskila 
Authored: Thu Dec 3 10:24:26 2015 -0800
Committer: Marko Kiiskila 
Committed: Thu Dec 3 10:24:26 2015 -0800

--
 libs/fs/src/fs_cli.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/3de06a11/libs/fs/src/fs_cli.c
--
diff --git a/libs/fs/src/fs_cli.c b/libs/fs/src/fs_cli.c
index d6cc182..45bdbf2 100644
--- a/libs/fs/src/fs_cli.c
+++ b/libs/fs/src/fs_cli.c
@@ -65,7 +65,6 @@ fs_ls_cmd(int argc, char **argv)
 return 1;
 }
 
-plen = strlen(path);
 rc = fs_open(path, FS_ACCESS_READ, );
 if (rc == 0) {
 fs_ls_file(path, file);
@@ -74,7 +73,13 @@ fs_ls_cmd(int argc, char **argv)
 goto done;
 }
 
-strncpy(name, path, sizeof(name) - 1);
+plen = strlen(path);
+strncpy(name, path, sizeof(name) - 2);
+if (name[plen - 1] != '/') {
+name[plen++] = '/';
+name[plen] = '\0';
+}
+
 rc = fs_opendir(path, );
 if (rc == 0) {
 do {