Dear Support,
After successfully enabled the console and shell in bletiny project; i
used the same method with blinky project but the console only echo back
the word i typed without any other response. (LED blinking worked as it
should)
I have attached output.png, main.c, pkg.yml and syscfg.yml. Changes made
as followed:
1. pkg.yml - added "@apache-mynewt-core/sys/console/full"
"@apache-mynewt-core/sys/shell"
"@apache-mynewt-core/sys/sysinit"
2. main.c - added #include "console/console.h"
#include "shell/shell.h"
#include "syscfg/syscfg.h"
rc = console_init(NULL);
assert(rc == 0);
3. syscfg.yml - Added
#Package: apps/bletiny
syscfg.vals:
# Enable the shell task.
SHELL_TASK: 1
CONSOLE_TICKS: 1
CONSOLE_PROMPT: 1
Please let me know is there any important initializing step i missed out.
Thank you.
Regards,
Then Yoong Ze
#
# 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.
#
pkg.name: apps/blinky
pkg.type: app
pkg.description: Basic example application which blinks an LED.
pkg.author: "Apache Mynewt <[email protected]>"
pkg.homepage: "http://mynewt.apache.org/"
pkg.keywords:
pkg.deps:
- "@apache-mynewt-core/kernel/os"
- "@apache-mynewt-core/hw/hal"
- "@apache-mynewt-core/sys/console/full"
- "@apache-mynewt-core/sys/shell"
- "@apache-mynewt-core/sys/sysinit"
#Package: apps/bletiny
syscfg.vals:
# Enable the shell task.
SHELL_TASK: 1
CONSOLE_TICKS: 1
CONSOLE_PROMPT: 1/**
* 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 <assert.h>
#include <string.h>
#include "console/console.h"
#include "shell/shell.h"
#include "syscfg/syscfg.h"
#include "sysinit/sysinit.h"
#include "os/os.h"
#include "bsp/bsp.h"
#include "hal/hal_gpio.h"
#ifdef ARCH_sim
#include "mcu/mcu_sim.h"
#endif
/* Init all tasks */
volatile int tasks_initialized;
int init_tasks(void);
/* Task 1 */
#define BLINKY_TASK_PRIO (1)
#define BLINKY_STACK_SIZE OS_STACK_ALIGN(256)
struct os_task blinky_task;
os_stack_t blinky_stack[BLINKY_STACK_SIZE];
static volatile int g_task1_loops;
/* For LED toggling */
int g_led_pin;
void
blinky_task_handler(void *arg)
{
struct os_task *t;
g_led_pin = LED_BLINK_PIN;
hal_gpio_init_out(g_led_pin, 1);
while (1) {
t = os_sched_get_current_task();
assert(t->t_func == blinky_task_handler);
++g_task1_loops;
/* Wait one second */
os_time_delay(OS_TICKS_PER_SEC);
os_time_delay(OS_TICKS_PER_SEC);
/* Toggle the LED */
hal_gpio_toggle(g_led_pin);
}
}
/**
* init_tasks
*
* Called by main.c after os_init(). This function performs initializations
* that are required before tasks are running.
*
* @return int 0 success; error otherwise.
*/
int
init_tasks(void)
{
os_task_init(&blinky_task, "blinky", blinky_task_handler, NULL,
BLINKY_TASK_PRIO, OS_WAIT_FOREVER, blinky_stack, BLINKY_STACK_SIZE);
tasks_initialized = 1;
return 0;
}
// struct os_eventq blinky_evq;
/**
* main
*
* The main function for the project. This function initializes the os, calls
* init_tasks to initialize tasks (and possibly other objects), then starts the
* OS. We should not return from os start.
*
* @return int NOTE: this function should never return!
*/
int
main(int argc, char **argv)
{
int rc;
#ifdef ARCH_sim
mcu_sim_parse_args(argc, argv);
#endif
sysinit();
/* Initialize eventq for the application task. */
// os_eventq_init(&blinky_evq);
/* Set the default eventq for packages that lack a dedicated task. */
// os_eventq_dflt_set(&blinky_evq);
rc = init_tasks();
assert(rc == 0);
/* Init the console */
rc = console_init(NULL);
assert(rc == 0);
os_start();
/* os start should never return. If it does, this should be an error */
assert(0);
return rc;
}