You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by vi...@apache.org on 2017/03/21 18:47:41 UTC
[1/4] incubator-mynewt-core git commit: MYNEWT-678 SensorAPI: Shell:
Repository: incubator-mynewt-core
Updated Branches:
refs/heads/develop ea98953df -> 68265625d
MYNEWT-678 SensorAPI: Shell:
- Add support for polling at a given interval for a
specific duration
- Initial commit
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/c93c7bea
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/c93c7bea
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/c93c7bea
Branch: refs/heads/develop
Commit: c93c7bea45ee2b525ac5c6d209b10ad2b495f21e
Parents: ea98953
Author: Vipul Rahane <vi...@apache.org>
Authored: Thu Mar 16 16:05:56 2017 -0700
Committer: Vipul Rahane <vi...@apache.org>
Committed: Tue Mar 21 11:44:18 2017 -0700
----------------------------------------------------------------------
hw/sensor/src/sensor_shell.c | 148 ++++++++++++++++++++++++++++++++++----
1 file changed, 136 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c93c7bea/hw/sensor/src/sensor_shell.c
----------------------------------------------------------------------
diff --git a/hw/sensor/src/sensor_shell.c b/hw/sensor/src/sensor_shell.c
index 8fe2b21..250478e 100644
--- a/hw/sensor/src/sensor_shell.c
+++ b/hw/sensor/src/sensor_shell.c
@@ -40,6 +40,10 @@
#include "console/console.h"
#include "shell/shell.h"
#include "hal/hal_i2c.h"
+#include "hal/hal_timer.h"
+
+#define SENSOR_SHELL_TIMER_NUM (1)
+#define SENSOR_SHELL_TIMER_CLOCK_FREQ (100000)
static int sensor_cmd_exec(int, char **);
static struct shell_cmd shell_sensor_cmd = {
@@ -47,13 +51,31 @@ static struct shell_cmd shell_sensor_cmd = {
.sc_cmd_func = sensor_cmd_exec
};
+struct os_sem g_sensor_shell_sem;
+struct hal_timer g_sensor_shell_timer;
+uint32_t sensor_shell_timer_arg = 0xdeadc0de;
+uint8_t g_timer_is_config;
+
+struct sensor_poll_data {
+ int spd_nsamples;
+ int spd_poll_itvl;
+ int spd_poll_duration;
+ int spd_poll_delay;
+};
+
static void
sensor_display_help(void)
{
console_printf("Possible commands for sensor are:\n");
console_printf(" list\n");
- console_printf(" read\n");
- console_printf(" i2cscan\n");
+ console_printf(" list of sensors registered\n");
+ console_printf(" read <sensor_name> <type> [-n nsamples] [-i poll_itvl(ms)] [-d poll_duration(ms)]\n");
+ console_printf(" read <no_of_samples> from sensor<sensor_name> of type:<type> at preset interval or \n");
+ console_printf(" at <poll_interval> rate for <poll_duration>");
+ console_printf(" i2cscan <I2C num>\n");
+ console_printf(" scan I2C bus for connected devices\n");
+ console_printf(" type <sensor_name>\n");
+ console_printf(" types supported by registered sensor\n");
}
static void
@@ -254,13 +276,29 @@ sensor_shell_read_listener(struct sensor *sensor, void *arg, void *data)
return (0);
}
+void
+sensor_shell_timer_cb(void *arg)
+{
+ int timer_arg_val;
+ int rc;
+
+ timer_arg_val = *(int *)arg;
+ rc = hal_timer_start(&g_sensor_shell_timer, timer_arg_val);
+ assert(rc == 0);
+ os_sem_release(&g_sensor_shell_sem);
+}
+
static int
-sensor_cmd_read(char *name, sensor_type_t type, int nsamples)
+sensor_cmd_read(char *name, sensor_type_t type, struct sensor_poll_data *spd)
{
struct sensor *sensor;
struct sensor_listener listener;
struct sensor_shell_read_ctx ctx;
int rc;
+ int duration;
+ int64_t start_ts;
+ int newline;
+ char ch;
/* Look up sensor by name */
sensor = sensor_mgr_find_next_bydevname(name, NULL);
@@ -291,22 +329,90 @@ sensor_cmd_read(char *name, sensor_type_t type, int nsamples)
return rc;
}
+ if (spd->spd_poll_itvl) {
+
+ if (!g_timer_is_config) {
+ rc = hal_timer_config(SENSOR_SHELL_TIMER_NUM, SENSOR_SHELL_TIMER_CLOCK_FREQ);
+ assert(rc == 0);
+ g_timer_is_config = 1;
+ }
+
+ sensor_shell_timer_arg = 1000 * spd->spd_poll_itvl;
+ rc = hal_timer_set_cb(SENSOR_SHELL_TIMER_NUM, &g_sensor_shell_timer, sensor_shell_timer_cb,
+ &sensor_shell_timer_arg);
+ assert(rc == 0);
+
+ rc = hal_timer_start(&g_sensor_shell_timer, sensor_shell_timer_arg);
+ } assert(rc == 0);
+
+ start_ts = 0;
+ duration = 0;
+
while (1) {
+ if (spd->spd_poll_itvl) {
+ /*
+ * Wait for semaphore from callback,
+ * this semaphore should only be considered when a
+ * a poll interval is specified
+ */
+ os_sem_pend(&g_sensor_shell_sem, OS_TIMEOUT_NEVER);
+ }
+
rc = sensor_read(sensor, type, NULL, NULL, OS_TIMEOUT_NEVER);
if (rc) {
console_printf("Cannot read sensor %s\n", name);
goto err;
}
- if (ctx.num_entries >= nsamples) {
+
+ /* Condition for number of samples */
+ if (spd->spd_nsamples && ctx.num_entries >= spd->spd_nsamples) {
+ hal_timer_stop(&g_sensor_shell_timer);
break;
}
- }
- sensor_unregister_listener(sensor, &listener);
+ /*
+ * Incrementing duration based on interval if specified or
+ * os_time if interval is not specified and checking duration
+ */
+ if (spd->spd_poll_duration) {
+ if (spd->spd_poll_itvl) {
+ duration += spd->spd_poll_itvl;
+ } else {
+ if (!start_ts) {
+ start_ts = os_get_uptime_usec()/1000;
+ } else {
+ duration = os_get_uptime_usec()/1000 - start_ts;
+ }
+
+ }
+
+ if (duration >= spd->spd_poll_duration) {
+ hal_timer_stop(&g_sensor_shell_timer);
+ console_printf("Sensor polling done\n");
+ break;
+ }
+ }
+
+ ch = 0;
+ /* Check for escape sequence */
+ rc = console_read(&ch, 1, &newline);
+ if (rc) {
+ hal_timer_stop(&g_sensor_shell_timer);
+ goto err;
+ }
+ /* ^C or q or Q gets it out of the sampling loop */
+ if (ch == 3 || ch == 'q' || ch == 'Q') {
+ hal_timer_stop(&g_sensor_shell_timer);
+ console_printf("Sensor polling stopped\n");
+ break;
+ }
+ }
- return 0;
err:
+ os_sem_release(&g_sensor_shell_sem);
+
sensor_unregister_listener(sensor, &listener);
+
return rc;
}
@@ -375,8 +481,10 @@ err:
static int
sensor_cmd_exec(int argc, char **argv)
{
+ struct sensor_poll_data spd;
char *subcmd;
int rc;
+ int i;
if (argc <= 1) {
sensor_display_help();
@@ -388,15 +496,31 @@ sensor_cmd_exec(int argc, char **argv)
if (!strcmp(subcmd, "list")) {
sensor_cmd_list_sensors();
} else if (!strcmp(subcmd, "read")) {
- if (argc != 5) {
- console_printf("Three arguments required for read: device name, "
- "sensor type and number of samples, only %d provided.\n",
- argc - 2);
+ if (argc < 6) {
+ console_printf("Too few arguments: %d\n"
+ "Usage: sensor read <sensor_name> <type>"
+ "[-n nsamples] [-i poll_itvl(ms)] [-d poll_duration(ms)]\n",
+ argc - 2);
rc = SYS_EINVAL;
goto err;
}
- rc = sensor_cmd_read(argv[2], (sensor_type_t) strtol(argv[3], NULL, 0), atoi(argv[4]));
+ i = 4;
+ memset(&spd, 0, sizeof(struct sensor_poll_data));
+ if (!strcmp(argv[i], "-n")) {
+ spd.spd_nsamples = atoi(argv[++i]);
+ i++;
+ }
+ if (!strcmp(argv[i], "-i")) {
+ spd.spd_poll_itvl = atoi(argv[++i]);
+ i++;
+ }
+ if (!strcmp(argv[i], "-d")) {
+ spd.spd_poll_duration = atoi(argv[++i]);
+ i++;
+ }
+
+ rc = sensor_cmd_read(argv[2], (sensor_type_t) strtol(argv[3], NULL, 0), &spd);
if (rc) {
goto err;
}
[4/4] incubator-mynewt-core git commit: MYNEWT-678 SensorAPI: Shell:
Posted by vi...@apache.org.
MYNEWT-678 SensorAPI: Shell:
- Add support for polling at a given interval for a
specific duration(Use os_cputime instead of a dedicated HW hal_timer)
"sensor read <sensor_name> <type> [-n nsamples] [-i poll_itvl] [-d duration]"
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/68265625
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/68265625
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/68265625
Branch: refs/heads/develop
Commit: 68265625d5c27ebaddd5d4b1d64acbbb30d3db90
Parents: d23fab9
Author: Vipul Rahane <vi...@apache.org>
Authored: Tue Mar 21 11:37:54 2017 -0700
Committer: Vipul Rahane <vi...@apache.org>
Committed: Tue Mar 21 11:46:30 2017 -0700
----------------------------------------------------------------------
hw/sensor/src/sensor_shell.c | 50 +++++++++++++--------------------------
hw/sensor/syscfg.yml | 8 -------
2 files changed, 16 insertions(+), 42 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/68265625/hw/sensor/src/sensor_shell.c
----------------------------------------------------------------------
diff --git a/hw/sensor/src/sensor_shell.c b/hw/sensor/src/sensor_shell.c
index 3b6dc43..8d96445 100644
--- a/hw/sensor/src/sensor_shell.c
+++ b/hw/sensor/src/sensor_shell.c
@@ -40,7 +40,7 @@
#include "console/console.h"
#include "shell/shell.h"
#include "hal/hal_i2c.h"
-#include "hal/hal_timer.h"
+#include "os/os_cputime.h"
static int sensor_cmd_exec(int, char **);
static struct shell_cmd shell_sensor_cmd = {
@@ -51,7 +51,6 @@ static struct shell_cmd shell_sensor_cmd = {
struct os_sem g_sensor_shell_sem;
struct hal_timer g_sensor_shell_timer;
uint32_t sensor_shell_timer_arg = 0xdeadc0de;
-uint8_t g_timer_is_config;
struct sensor_poll_data {
int spd_nsamples;
@@ -277,38 +276,22 @@ void
sensor_shell_timer_cb(void *arg)
{
int timer_arg_val;
- int rc;
timer_arg_val = *(uint32_t *)arg;
+ os_cputime_timer_relative(&g_sensor_shell_timer, timer_arg_val);
os_sem_release(&g_sensor_shell_sem);
- rc = hal_timer_start(&g_sensor_shell_timer, timer_arg_val);
- assert(rc == 0);
}
-/* HAL timer configuration */
+/* os cputime timer configuration and initialization */
static void
sensor_shell_config_timer(struct sensor_poll_data *spd)
{
- int rc;
-
- if (!g_timer_is_config) {
- rc = hal_timer_config(MYNEWT_VAL(SENSOR_SHELL_TIMER_NUM),
- MYNEWT_VAL(SENSOR_SHELL_TIMER_FREQ));
- assert(rc == 0);
- g_timer_is_config = 1;
- }
-
- sensor_shell_timer_arg =
- (spd->spd_poll_itvl * 1000000) / hal_timer_get_resolution(MYNEWT_VAL(SENSOR_SHELL_TIMER_NUM));
+ sensor_shell_timer_arg = os_cputime_usecs_to_ticks(spd->spd_poll_itvl * 1000);
- rc = hal_timer_set_cb(MYNEWT_VAL(SENSOR_SHELL_TIMER_NUM),
- &g_sensor_shell_timer,
- sensor_shell_timer_cb,
+ os_cputime_timer_init(&g_sensor_shell_timer, sensor_shell_timer_cb,
&sensor_shell_timer_arg);
- assert(rc == 0);
- rc = hal_timer_start(&g_sensor_shell_timer, sensor_shell_timer_arg);
- assert(rc == 0);
+ os_cputime_timer_relative(&g_sensor_shell_timer, sensor_shell_timer_arg);
}
/* Check for number of samples */
@@ -318,7 +301,7 @@ sensor_shell_chk_nsamples(struct sensor_poll_data *spd,
{
/* Condition for number of samples */
if (spd->spd_nsamples && ctx->num_entries >= spd->spd_nsamples) {
- hal_timer_stop(&g_sensor_shell_timer);
+ os_cputime_timer_stop(&g_sensor_shell_timer);
return 0;
}
@@ -338,7 +321,7 @@ sensor_shell_chk_escape_seq(void)
rc = console_read(&ch, 1, &newline);
/* ^C or q or Q gets it out of the sampling loop */
if (rc || (ch == 3 || ch == 'q' || ch == 'Q')) {
- hal_timer_stop(&g_sensor_shell_timer);
+ os_cputime_timer_stop(&g_sensor_shell_timer);
console_printf("Sensor polling stopped rc:%u\n", rc);
return 0;
}
@@ -351,24 +334,23 @@ sensor_shell_chk_escape_seq(void)
* os_time if interval is not specified and checking duration
*/
static int
-sensor_shell_polling_done(struct sensor_poll_data *spd,
- int64_t *start_ts,
- int *duration)
+sensor_shell_polling_done(struct sensor_poll_data *spd, int64_t *duration,
+ int64_t *start_ts)
{
if (spd->spd_poll_duration) {
if (spd->spd_poll_itvl) {
- *duration += spd->spd_poll_itvl;
+ *duration += spd->spd_poll_itvl * 1000;
} else {
if (!*start_ts) {
- *start_ts = os_get_uptime_usec()/1000;
+ *start_ts = os_get_uptime_usec();
} else {
- *duration = os_get_uptime_usec()/1000 - *start_ts;
+ *duration = os_get_uptime_usec() - *start_ts;
}
}
- if (*duration >= spd->spd_poll_duration) {
- hal_timer_stop(&g_sensor_shell_timer);
+ if (*duration >= spd->spd_poll_duration * 1000) {
+ os_cputime_timer_stop(&g_sensor_shell_timer);
console_printf("Sensor polling done\n");
return 0;
}
@@ -384,7 +366,7 @@ sensor_cmd_read(char *name, sensor_type_t type, struct sensor_poll_data *spd)
struct sensor_listener listener;
struct sensor_shell_read_ctx ctx;
int rc;
- int duration;
+ int64_t duration;
int64_t start_ts;
/* Look up sensor by name */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/68265625/hw/sensor/syscfg.yml
----------------------------------------------------------------------
diff --git a/hw/sensor/syscfg.yml b/hw/sensor/syscfg.yml
index a4b6ee9..879fbb2 100644
--- a/hw/sensor/syscfg.yml
+++ b/hw/sensor/syscfg.yml
@@ -26,11 +26,3 @@ syscfg.defs:
SENSOR_CLI:
description: 'Whether or not to enable the sensor shell support'
value: 1
-
- SENSOR_SHELL_TIMER_FREQ:
- description: 'Frequency of sensor shell timer'
- value: 100000
-
- SENSOR_SHELL_TIMER_NUM:
- description: 'Timer number to use for sensor shell, 1 by default.'
- value: 1
[3/4] incubator-mynewt-core git commit: MYNEWT-678 SensorAPI: Shell:
Posted by vi...@apache.org.
MYNEWT-678 SensorAPI: Shell:
- Add support for polling at a given interval for a
specific duration
- Add hal_timer config and clean up
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/d23fab9e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/d23fab9e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/d23fab9e
Branch: refs/heads/develop
Commit: d23fab9eea2d9edf61833a3ce22e8d9754cc3eb9
Parents: b5e0947
Author: Vipul Rahane <vi...@apache.org>
Authored: Sun Mar 19 22:52:53 2017 -0700
Committer: Vipul Rahane <vi...@apache.org>
Committed: Tue Mar 21 11:45:22 2017 -0700
----------------------------------------------------------------------
hw/sensor/src/sensor_shell.c | 168 ++++++++++++++++++++++++--------------
hw/sensor/syscfg.yml | 8 ++
2 files changed, 116 insertions(+), 60 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d23fab9e/hw/sensor/src/sensor_shell.c
----------------------------------------------------------------------
diff --git a/hw/sensor/src/sensor_shell.c b/hw/sensor/src/sensor_shell.c
index 250478e..3b6dc43 100644
--- a/hw/sensor/src/sensor_shell.c
+++ b/hw/sensor/src/sensor_shell.c
@@ -42,9 +42,6 @@
#include "hal/hal_i2c.h"
#include "hal/hal_timer.h"
-#define SENSOR_SHELL_TIMER_NUM (1)
-#define SENSOR_SHELL_TIMER_CLOCK_FREQ (100000)
-
static int sensor_cmd_exec(int, char **);
static struct shell_cmd shell_sensor_cmd = {
.sc_cmd = "sensor",
@@ -282,10 +279,102 @@ sensor_shell_timer_cb(void *arg)
int timer_arg_val;
int rc;
- timer_arg_val = *(int *)arg;
+ timer_arg_val = *(uint32_t *)arg;
+ os_sem_release(&g_sensor_shell_sem);
rc = hal_timer_start(&g_sensor_shell_timer, timer_arg_val);
assert(rc == 0);
- os_sem_release(&g_sensor_shell_sem);
+}
+
+/* HAL timer configuration */
+static void
+sensor_shell_config_timer(struct sensor_poll_data *spd)
+{
+ int rc;
+
+ if (!g_timer_is_config) {
+ rc = hal_timer_config(MYNEWT_VAL(SENSOR_SHELL_TIMER_NUM),
+ MYNEWT_VAL(SENSOR_SHELL_TIMER_FREQ));
+ assert(rc == 0);
+ g_timer_is_config = 1;
+ }
+
+ sensor_shell_timer_arg =
+ (spd->spd_poll_itvl * 1000000) / hal_timer_get_resolution(MYNEWT_VAL(SENSOR_SHELL_TIMER_NUM));
+
+ rc = hal_timer_set_cb(MYNEWT_VAL(SENSOR_SHELL_TIMER_NUM),
+ &g_sensor_shell_timer,
+ sensor_shell_timer_cb,
+ &sensor_shell_timer_arg);
+ assert(rc == 0);
+
+ rc = hal_timer_start(&g_sensor_shell_timer, sensor_shell_timer_arg);
+ assert(rc == 0);
+}
+
+/* Check for number of samples */
+static int
+sensor_shell_chk_nsamples(struct sensor_poll_data *spd,
+ struct sensor_shell_read_ctx *ctx)
+{
+ /* Condition for number of samples */
+ if (spd->spd_nsamples && ctx->num_entries >= spd->spd_nsamples) {
+ hal_timer_stop(&g_sensor_shell_timer);
+ return 0;
+ }
+
+ return -1;
+}
+
+/* Check for escape sequence */
+static int
+sensor_shell_chk_escape_seq(void)
+{
+ char ch;
+ int newline;
+ int rc;
+
+ ch = 0;
+ /* Check for escape sequence */
+ rc = console_read(&ch, 1, &newline);
+ /* ^C or q or Q gets it out of the sampling loop */
+ if (rc || (ch == 3 || ch == 'q' || ch == 'Q')) {
+ hal_timer_stop(&g_sensor_shell_timer);
+ console_printf("Sensor polling stopped rc:%u\n", rc);
+ return 0;
+ }
+
+ return -1;
+}
+
+/*
+ * Incrementing duration based on interval if specified or
+ * os_time if interval is not specified and checking duration
+ */
+static int
+sensor_shell_polling_done(struct sensor_poll_data *spd,
+ int64_t *start_ts,
+ int *duration)
+{
+
+ if (spd->spd_poll_duration) {
+ if (spd->spd_poll_itvl) {
+ *duration += spd->spd_poll_itvl;
+ } else {
+ if (!*start_ts) {
+ *start_ts = os_get_uptime_usec()/1000;
+ } else {
+ *duration = os_get_uptime_usec()/1000 - *start_ts;
+ }
+ }
+
+ if (*duration >= spd->spd_poll_duration) {
+ hal_timer_stop(&g_sensor_shell_timer);
+ console_printf("Sensor polling done\n");
+ return 0;
+ }
+ }
+
+ return -1;
}
static int
@@ -297,8 +386,6 @@ sensor_cmd_read(char *name, sensor_type_t type, struct sensor_poll_data *spd)
int rc;
int duration;
int64_t start_ts;
- int newline;
- char ch;
/* Look up sensor by name */
sensor = sensor_mgr_find_next_bydevname(name, NULL);
@@ -306,8 +393,7 @@ sensor_cmd_read(char *name, sensor_type_t type, struct sensor_poll_data *spd)
console_printf("Sensor %s not found!\n", name);
}
- /* Register a listener and then trigger/read a bunch of samples.
- */
+ /* Register a listener and then trigger/read a bunch of samples */
memset(&ctx, 0, sizeof(ctx));
if (!(type & sensor->s_types)) {
@@ -329,24 +415,14 @@ sensor_cmd_read(char *name, sensor_type_t type, struct sensor_poll_data *spd)
return rc;
}
- if (spd->spd_poll_itvl) {
+ /* Initialize the semaphore*/
+ os_sem_init(&g_sensor_shell_sem, 0);
- if (!g_timer_is_config) {
- rc = hal_timer_config(SENSOR_SHELL_TIMER_NUM, SENSOR_SHELL_TIMER_CLOCK_FREQ);
- assert(rc == 0);
- g_timer_is_config = 1;
- }
-
- sensor_shell_timer_arg = 1000 * spd->spd_poll_itvl;
- rc = hal_timer_set_cb(SENSOR_SHELL_TIMER_NUM, &g_sensor_shell_timer, sensor_shell_timer_cb,
- &sensor_shell_timer_arg);
- assert(rc == 0);
-
- rc = hal_timer_start(&g_sensor_shell_timer, sensor_shell_timer_arg);
- } assert(rc == 0);
+ if (spd->spd_poll_itvl) {
+ sensor_shell_config_timer(spd);
+ }
- start_ts = 0;
- duration = 0;
+ start_ts = duration = 0;
while (1) {
if (spd->spd_poll_itvl) {
@@ -364,46 +440,18 @@ sensor_cmd_read(char *name, sensor_type_t type, struct sensor_poll_data *spd)
goto err;
}
- /* Condition for number of samples */
- if (spd->spd_nsamples && ctx.num_entries >= spd->spd_nsamples) {
- hal_timer_stop(&g_sensor_shell_timer);
+ /* Check number of samples if provided */
+ if (!sensor_shell_chk_nsamples(spd, &ctx)) {
break;
}
- /*
- * Incrementing duration based on interval if specified or
- * os_time if interval is not specified and checking duration
- */
- if (spd->spd_poll_duration) {
- if (spd->spd_poll_itvl) {
- duration += spd->spd_poll_itvl;
- } else {
- if (!start_ts) {
- start_ts = os_get_uptime_usec()/1000;
- } else {
- duration = os_get_uptime_usec()/1000 - start_ts;
- }
-
- }
-
- if (duration >= spd->spd_poll_duration) {
- hal_timer_stop(&g_sensor_shell_timer);
- console_printf("Sensor polling done\n");
- break;
- }
+ /* Check duration if provided */
+ if (!sensor_shell_polling_done(spd, &start_ts, &duration)) {
+ break;
}
- ch = 0;
- /* Check for escape sequence */
- rc = console_read(&ch, 1, &newline);
- if (rc) {
- hal_timer_stop(&g_sensor_shell_timer);
- goto err;
- }
- /* ^C or q or Q gets it out of the sampling loop */
- if (ch == 3 || ch == 'q' || ch == 'Q') {
- hal_timer_stop(&g_sensor_shell_timer);
- console_printf("Sensor polling stopped\n");
+ /* Check escape sequence */
+ if(!sensor_shell_chk_escape_seq()) {
break;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d23fab9e/hw/sensor/syscfg.yml
----------------------------------------------------------------------
diff --git a/hw/sensor/syscfg.yml b/hw/sensor/syscfg.yml
index 879fbb2..a4b6ee9 100644
--- a/hw/sensor/syscfg.yml
+++ b/hw/sensor/syscfg.yml
@@ -26,3 +26,11 @@ syscfg.defs:
SENSOR_CLI:
description: 'Whether or not to enable the sensor shell support'
value: 1
+
+ SENSOR_SHELL_TIMER_FREQ:
+ description: 'Frequency of sensor shell timer'
+ value: 100000
+
+ SENSOR_SHELL_TIMER_NUM:
+ description: 'Timer number to use for sensor shell, 1 by default.'
+ value: 1
[2/4] incubator-mynewt-core git commit: No Ticket - correct
os_sem_init() comment
Posted by vi...@apache.org.
No Ticket - correct os_sem_init() comment
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/b5e0947a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/b5e0947a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/b5e0947a
Branch: refs/heads/develop
Commit: b5e0947a0bc368cb8ac6adf7e10801e09fdfa17d
Parents: c93c7be
Author: Vipul Rahane <vi...@apache.org>
Authored: Sun Mar 19 22:42:16 2017 -0700
Committer: Vipul Rahane <vi...@apache.org>
Committed: Tue Mar 21 11:45:21 2017 -0700
----------------------------------------------------------------------
kernel/os/src/os_sem.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b5e0947a/kernel/os/src/os_sem.c
----------------------------------------------------------------------
diff --git a/kernel/os/src/os_sem.c b/kernel/os/src/os_sem.c
index d347a61..02fecbf 100644
--- a/kernel/os/src/os_sem.c
+++ b/kernel/os/src/os_sem.c
@@ -35,9 +35,9 @@
*/
/**
- * os sem create
+ * os sem initialize
*
- * Create a semaphore and initialize it.
+ * Initialize a semaphore
*
* @param sem Pointer to semaphore
* tokens: # of tokens the semaphore should contain initially.