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/30 20:13:59 UTC
[1/3] incubator-mynewt-core git commit: Added ticks on/off to console
shell
Repository: incubator-mynewt-core
Updated Branches:
refs/heads/develop 899270594 -> 13fd07eff
Added ticks on/off to console shell
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/f3e755d8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/f3e755d8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/f3e755d8
Branch: refs/heads/develop
Commit: f3e755d829828cade6dc0cfebb651e4169b0f4f6
Parents: 8c949ec
Author: David G. Simmons <sa...@mac.com>
Authored: Mon Nov 28 10:28:30 2016 -0500
Committer: David G. Simmons <sa...@mac.com>
Committed: Tue Nov 29 09:32:21 2016 -0500
----------------------------------------------------------------------
sys/console/full/include/console/ticks.h | 41 ++++++++++++++++++
sys/console/full/src/cons_fmt.c | 23 +++++-----
sys/console/full/src/prompt.c | 6 +++
sys/console/full/src/ticks.c | 46 ++++++++++++++++++++
sys/console/full/syscfg.yml | 4 +-
sys/console/stub/include/console/ticks.h | 41 ++++++++++++++++++
sys/shell/include/shell/shell_tick.h | 33 ++++++++++++++
sys/shell/src/shell.c | 12 +++++-
sys/shell/src/shell_prompt.c | 30 +++++++------
sys/shell/src/shell_tick.c | 62 +++++++++++++++++++++++++++
10 files changed, 274 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f3e755d8/sys/console/full/include/console/ticks.h
----------------------------------------------------------------------
diff --git a/sys/console/full/include/console/ticks.h b/sys/console/full/include/console/ticks.h
new file mode 100644
index 0000000..eebdac7
--- /dev/null
+++ b/sys/console/full/include/console/ticks.h
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef __CONSOLE_TICKS_H__
+#define __CONSOLE_TICKS_H__
+
+#include <stdarg.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+void console_no_ticks(void);
+
+void console_yes_ticks(void);
+
+char console_get_ticks(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __CONSOLE_PROMPT_H__ */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f3e755d8/sys/console/full/src/cons_fmt.c
----------------------------------------------------------------------
diff --git a/sys/console/full/src/cons_fmt.c b/sys/console/full/src/cons_fmt.c
index dc3f0a5..83c9ca0 100644
--- a/sys/console/full/src/cons_fmt.c
+++ b/sys/console/full/src/cons_fmt.c
@@ -20,10 +20,12 @@
#include <stdio.h>
#include "syscfg/syscfg.h"
#include "console/console.h"
+#include "console/ticks.h"
#include "os/os_time.h"
#define CONS_OUTPUT_MAX_LINE 128
+
#if MYNEWT_VAL(BASELIBC_PRESENT)
size_t console_file_write(FILE *p, const char *str, size_t cnt);
@@ -40,12 +42,12 @@ void
console_printf(const char *fmt, ...)
{
va_list args;
-
- /* Prefix each line with a timestamp. */
- if (!console_is_midline) {
- fprintf((FILE *)&console_file, "%lu:", (unsigned long)os_time_get());
+ if (console_get_ticks()) {
+ /* Prefix each line with a timestamp. */
+ if (!console_is_midline) {
+ fprintf((FILE *)&console_file, "%lu:", (unsigned long)os_time_get());
+ }
}
-
va_start(args, fmt);
vfprintf((FILE *)&console_file, fmt, args);
va_end(args);
@@ -59,11 +61,12 @@ console_printf(const char *fmt, ...)
va_list args;
char buf[CONS_OUTPUT_MAX_LINE];
int len;
-
- /* Prefix each line with a timestamp. */
- if (!console_is_midline) {
- len = snprintf(buf, sizeof(buf), "%lu:", (unsigned long)os_time_get());
- console_write(buf, len);
+ if (console_get_ticks()) {
+ /* Prefix each line with a timestamp. */
+ if (!console_is_midline) {
+ len = snprintf(buf, sizeof(buf), "%lu:", (unsigned long)os_time_get());
+ console_write(buf, len);
+ }
}
va_start(args, fmt);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f3e755d8/sys/console/full/src/prompt.c
----------------------------------------------------------------------
diff --git a/sys/console/full/src/prompt.c b/sys/console/full/src/prompt.c
index f4b9768..251c249 100644
--- a/sys/console/full/src/prompt.c
+++ b/sys/console/full/src/prompt.c
@@ -41,6 +41,12 @@ console_no_prompt(void)
do_prompt = 0;
}
+void
+console_yes_prompt(void)
+{
+ do_prompt = 1;
+}
+
/* print the prompt to the console */
void
console_print_prompt(void)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f3e755d8/sys/console/full/src/ticks.c
----------------------------------------------------------------------
diff --git a/sys/console/full/src/ticks.c b/sys/console/full/src/ticks.c
new file mode 100644
index 0000000..1a442aa
--- /dev/null
+++ b/sys/console/full/src/ticks.c
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+#include "console/console.h"
+#include "console/prompt.h"
+#include "syscfg/syscfg.h"
+
+static char do_ticks = MYNEWT_VAL(CONSOLE_TICKS);
+
+/* Turn OS Ticks off */
+void
+console_no_ticks(void)
+{
+ do_ticks = 0;
+}
+
+/* Turn OS Ticks on */
+void
+console_yes_ticks(void)
+{
+ do_ticks = 1;
+}
+
+/* return value of CONSOLE_TICKS */
+char console_get_ticks(void)
+{
+ return do_ticks;
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f3e755d8/sys/console/full/syscfg.yml
----------------------------------------------------------------------
diff --git a/sys/console/full/syscfg.yml b/sys/console/full/syscfg.yml
index fd16737..68eedaf 100644
--- a/sys/console/full/syscfg.yml
+++ b/sys/console/full/syscfg.yml
@@ -31,7 +31,9 @@ syscfg.defs:
CONSOLE_RX_BUF_SIZE:
description: 'Console receive buffer size.'
value: 128
-
+ CONSOLE_TICKS:
+ description: 'Print OS Ticks'
+ value: '1'
CONSOLE_PROMPT:
description: 'Default console prompt '
value: '0'
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f3e755d8/sys/console/stub/include/console/ticks.h
----------------------------------------------------------------------
diff --git a/sys/console/stub/include/console/ticks.h b/sys/console/stub/include/console/ticks.h
new file mode 100644
index 0000000..eebdac7
--- /dev/null
+++ b/sys/console/stub/include/console/ticks.h
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef __CONSOLE_TICKS_H__
+#define __CONSOLE_TICKS_H__
+
+#include <stdarg.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+void console_no_ticks(void);
+
+void console_yes_ticks(void);
+
+char console_get_ticks(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __CONSOLE_PROMPT_H__ */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f3e755d8/sys/shell/include/shell/shell_tick.h
----------------------------------------------------------------------
diff --git a/sys/shell/include/shell/shell_tick.h b/sys/shell/include/shell/shell_tick.h
new file mode 100644
index 0000000..0d0b2e6
--- /dev/null
+++ b/sys/shell/include/shell/shell_tick.h
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef H_SHELL_TICKS_
+#define H_SHELL_TICKS_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int shell_ticks_cmd(int argc, char **argv);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f3e755d8/sys/shell/src/shell.c
----------------------------------------------------------------------
diff --git a/sys/shell/src/shell.c b/sys/shell/src/shell.c
index 2f04520..2b11efc 100644
--- a/sys/shell/src/shell.c
+++ b/sys/shell/src/shell.c
@@ -25,6 +25,7 @@
#include "syscfg/syscfg.h"
#include "console/console.h"
#include "console/prompt.h"
+#include "console/ticks.h"
#include "os/os.h"
#include "os/endian.h"
#include "base64/base64.h"
@@ -43,6 +44,8 @@ static struct os_mqueue g_shell_nlip_mq;
static int shell_echo_cmd(int argc, char **argv);
static int shell_help_cmd(int argc, char **argv);
int shell_prompt_cmd(int argc, char **argv);
+int shell_ticks_cmd(int argc, char **argv);
+
static void shell_event_console_rdy(struct os_event *ev);
@@ -60,6 +63,10 @@ static struct shell_cmd g_shell_help_cmd = {
static struct shell_cmd g_shell_prompt_cmd = {
.sc_cmd = "prompt",
.sc_cmd_func = shell_prompt_cmd
+};
+static struct shell_cmd g_shell_ticks_cmd = {
+ .sc_cmd = "ticks",
+ .sc_cmd_func = shell_ticks_cmd
};
static struct shell_cmd g_shell_os_tasks_display_cmd = {
.sc_cmd = "tasks",
@@ -553,7 +560,10 @@ shell_init(void)
rc = shell_cmd_register(&g_shell_help_cmd);
SYSINIT_PANIC_ASSERT(rc == 0);
- rc = shell_cmd_register(&g_shell_prompt_cmd);
+ rc = shell_cmd_register(&g_shell_prompt_cmd);
+ SYSINIT_PANIC_ASSERT(rc == 0);
+
+ rc = shell_cmd_register(&g_shell_ticks_cmd);
SYSINIT_PANIC_ASSERT(rc == 0);
rc = shell_cmd_register(&g_shell_os_tasks_display_cmd);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f3e755d8/sys/shell/src/shell_prompt.c
----------------------------------------------------------------------
diff --git a/sys/shell/src/shell_prompt.c b/sys/shell/src/shell_prompt.c
index 526bbea..801d7ca 100644
--- a/sys/shell/src/shell_prompt.c
+++ b/sys/shell/src/shell_prompt.c
@@ -20,7 +20,7 @@
#include <string.h>
#include "shell/shell.h"
#include <console/console.h>
-
+#include <console/prompt.h>
static char shell_prompt = '>';
void console_set_prompt(char p);
@@ -40,30 +40,36 @@ shell_prompt_cmd(int argc, char **argv)
if (rc != 0) {
return -1;
}
- if(argc > 1){
- if(!strcmp(argv[1], "show")){
- console_printf("Prompt character: %c\n", shell_prompt);
+ if (argc > 1) {
+ if (!strcmp(argv[1], "show")) {
+ console_printf(" Prompt character: %c\n", shell_prompt);
}
- else if (!strcmp(argv[1],"set")){
+ else if (!strcmp(argv[1],"set")) {
shell_prompt = argv[2][0];
- console_printf("Prompt set to: %c\n", argv[2][0]);
+ console_printf(" Prompt set to: %c\n", argv[2][0]);
console_set_prompt(argv[2][0]);
}
+ else if (!strcmp(argv[1], "on")) {
+ console_yes_prompt();
+ console_printf(" Prompt now on.\n");
+ }
+ else if (!strcmp(argv[1], "off")) {
+ console_no_prompt();
+ console_printf(" Prompt now off.\n");
+ }
else {
goto usage;
}
-
}
else {
goto usage;
-
}
+ shell_cmd_list_unlock();
+ return 0;
usage:
- console_printf("Usage: prompt [set|show] [prompt_char]\n");
-
+ console_printf("Usage: prompt [on|off]|[set|show] [prompt_char]\n");
shell_cmd_list_unlock();
-
- return (0);
+ return 0;
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f3e755d8/sys/shell/src/shell_tick.c
----------------------------------------------------------------------
diff --git a/sys/shell/src/shell_tick.c b/sys/shell/src/shell_tick.c
new file mode 100644
index 0000000..ec2fdff
--- /dev/null
+++ b/sys/shell/src/shell_tick.c
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <string.h>
+#include "shell/shell.h"
+#include <console/console.h>
+#include <console/ticks.h>
+#include "syscfg/syscfg.h"
+
+/**
+ * Handles the 'ticks' command
+ */
+int
+shell_ticks_cmd(int argc, char **argv)
+{
+ int rc;
+
+ rc = shell_cmd_list_lock();
+ if (rc != 0) {
+ return -1;
+ }
+ if (argc > 1) {
+ if (!strcmp(argv[1], "on")) {
+ console_yes_ticks();
+ console_printf(" Console Ticks on\n");
+ }
+ else if (!strcmp(argv[1],"off")) {
+ console_printf(" Console Ticks off\n");
+ console_no_ticks();
+ }
+ else {
+ goto usage;
+ }
+ }
+ else {
+ goto usage;
+ }
+ shell_cmd_list_unlock();
+ return 0;
+usage:
+ console_printf(" Usage: ticks [on|off]\n");
+ shell_cmd_list_unlock();
+ return 0;
+
+}
+
\ No newline at end of file
[3/3] incubator-mynewt-core git commit: This closes #128.
Posted by cc...@apache.org.
This closes #128.
Merge remote-tracking branch 'davidgs/ticks2' into develop
* davidgs/ticks2:
Added ticks on/off to console shell
missing function declaration
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/13fd07ef
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/13fd07ef
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/13fd07ef
Branch: refs/heads/develop
Commit: 13fd07eff8e709f15213f2a494fba63991f2abc7
Parents: 8992705 f3e755d
Author: Christopher Collins <cc...@apache.org>
Authored: Wed Nov 30 12:08:34 2016 -0800
Committer: Christopher Collins <cc...@apache.org>
Committed: Wed Nov 30 12:08:34 2016 -0800
----------------------------------------------------------------------
sys/console/full/include/console/prompt.h | 2 +
sys/console/full/include/console/ticks.h | 41 +++++++++++++++++
sys/console/full/src/cons_fmt.c | 23 +++++-----
sys/console/full/src/prompt.c | 6 +++
sys/console/full/src/ticks.c | 46 +++++++++++++++++++
sys/console/full/syscfg.yml | 4 +-
sys/console/stub/include/console/ticks.h | 41 +++++++++++++++++
sys/shell/include/shell/shell_tick.h | 33 ++++++++++++++
sys/shell/src/shell.c | 12 ++++-
sys/shell/src/shell_prompt.c | 30 ++++++++-----
sys/shell/src/shell_tick.c | 62 ++++++++++++++++++++++++++
11 files changed, 276 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
[2/3] incubator-mynewt-core git commit: missing function declaration
Posted by cc...@apache.org.
missing function declaration
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/8c949ec6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/8c949ec6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/8c949ec6
Branch: refs/heads/develop
Commit: 8c949ec68e1431062c10bd5ba84b95ee1e81f32c
Parents: d36a403
Author: David G. Simmons <sa...@mac.com>
Authored: Mon Nov 28 13:45:19 2016 -0500
Committer: David G. Simmons <sa...@mac.com>
Committed: Tue Nov 29 09:32:21 2016 -0500
----------------------------------------------------------------------
sys/console/full/include/console/prompt.h | 2 ++
1 file changed, 2 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8c949ec6/sys/console/full/include/console/prompt.h
----------------------------------------------------------------------
diff --git a/sys/console/full/include/console/prompt.h b/sys/console/full/include/console/prompt.h
index ae29e59..d4bf8bf 100644
--- a/sys/console/full/include/console/prompt.h
+++ b/sys/console/full/include/console/prompt.h
@@ -34,6 +34,8 @@ void console_set_prompt(char);
void console_no_prompt(void);
+void console_yes_prompt(void);
+
#ifdef __cplusplus
}
#endif