Mbed with some light patches

@Olli-Pekka Puolitaival Olli-Pekka Puolitaival authored on 23 Jan 2018
.github PR template: Feature -> functionality change 5 years ago
TESTS Merge pull request #7781 from deepikabhavnani/crc_safety 5 years ago
TEST_APPS Icetea support 6 years ago
UNITTESTS Unittests: update documentation for Windows 5 years ago
cmsis Remove uVisor from mbed-os 5 years ago
drivers Merge pull request #7781 from deepikabhavnani/crc_safety 5 years ago
events Merge pull request #7810 from kegilbert/eventqueue-templatewall-rework 5 years ago
features Icetea support 6 years ago
hal Merge pull request #7592 from orenc17/remove_uvisor 5 years ago
mbed-client-cli Icetea support 6 years ago
platform Merge pull request #7794 from c1728p9/boot_overhaul 5 years ago
rtos Refactor boot process 5 years ago
source Icetea support 6 years ago
targets Merge pull request #7778 from SeppoTakalo/provide_default_mesh 5 years ago
test Icetea support 6 years ago
tools Icetea support 6 years ago
.astyleignore AStyle: ignore hal storage abstraction 5 years ago
.astylerc AStyle: fix indentation for longer lines 5 years ago
.coveragerc Exclude libraries and tests from coverage numbers 6 years ago
.gitattributes Added .gitattributes for automatic LF line ending conversion 10 years ago
.gitignore Icetea support 6 years ago
.mbedignore Icetea support 6 years ago
.pylintrc Add pylint configuration file 7 years ago
.travis.yml Adopted travis changes from littlefs v1.6 5 years ago
.yotta_ignore ARM: at91: add basic sama5d2 support 4 years ago
CONTRIBUTING.md Update link in CONTRIBUTING.md 6 years ago
DOXYGEN_FRONTPAGE.md Very minimal text 7 years ago
Jenkinsfile Updated file comment 5 years ago
LICENSE Add Apache v2 LICENSE file 10 years ago
Makefile Icetea support 6 years ago
README.md Icetea support 6 years ago
doxyfile_options Merge pull request #7819 from lorjala/unittests 5 years ago
doxygen_options.json Merge pull request #7592 from orenc17/remove_uvisor 5 years ago
logo.png Readme updates for style and branding 6 years ago
mbed.h Separate version header file to get version updates in Mbed OS 5 years ago
module.json Icetea support 6 years ago
requirements.txt Remove extra package used for CI debugging 5 years ago
target.json ARM: at91: add basic sama5d2 support 4 years ago
test_suite.json Icetea support 6 years ago
README.md

Mbed OS

Build status release Build status master Tools coverage status PR progress

Arm Mbed OS is an open source embedded operating system designed specifically for the "things" in the Internet of Things. It includes all the features you need to develop a connected product based on an Arm Cortex-M microcontroller, including security, connectivity, an RTOS and drivers for sensors and I/O devices.

Mbed OS provides a platform that includes:

  • Security foundations.
  • Cloud management services.
  • Drivers for sensors, I/O devices and connectivity.

Release notes

The release notes detail the current release. You can also find information about previous versions.

Getting started for developers

We have a developer website for asking questions, engaging with others, finding information on boards and components, using an online IDE and compiler, reading the documentation and learning about what's new and what's coming next in Mbed OS.

Getting started for contributors

We also have a contributing and publishing guide that covers licensing, contributor agreements and style guidelines.

mbed-client-cli

This is the Command Line Library for a CLI application. This library provides methods for:

  • Adding commands to the interpreter.
  • Deleting commands from the interpreter.
  • Executing commands.
  • Adding command aliases to the interpreter.
  • Searching command arguments.

API

Command Line Library API is described in the snipplet below:

// if thread safety for CLI terminal output is needed
// configure output mutex wait cb before initialization so it's available immediately
cmd_set_mutex_wait_func( (func)(void) );
// configure output mutex release cb before initialization so it's available immediately
cmd_set_mutex_wait_func( (func)(void) );
// initialize cmdline with print function
cmd_init( (func)(const char* fmt, va_list ap) );
// configure ready cb
cmd_set_ready_cb( (func)(int retcode)  );
// register command for library
cmd_add( <command>, (int func)(int argc, char *argv[]), <help>, <man>); 
//execute some existing commands
cmd_exe( <command> );

Tracing

Command Line Library has trace messages, which are disabled by default. "MBED_CLIENT_CLI_TRACE_ENABLE" flag if defined, enables all the trace prints for debugging.

Usage example

Adding new commands to the Command Line Library and executing the commands:

//example print function
void myprint(const char* fmt, va_list ap){ vprintf(fmt, ap); }

// ready cb, calls next command to be executed
void cmd_ready_cb(int retcode) { cmd_next( retcode ); }

// dummy command with some option
int cmd_dummy(int argc, char *argv[]){
  if( cmd_has_option(argc, argv, "o") ) {
    cmd_printf("This is o option");
  } else {
        return CMDLINE_RETCODE_INVALID_PARAMETERS;
  }
  return CMDLINE_RETCODE_SUCCESS;
}

// timer cb (pseudo-timer-code)
void timer_ready_cb(void) {
   cmd_ready(CMDLINE_RETCODE_SUCCESS);
}

// long command, that needs for example some events to complete the command execution
int cmd_long(int argc, char *argv[] ) {
   timer_start( 5000, timer_ready_cb ); //pseudo timer code
   return CMDLINE_RETCODE_EXCUTING_CONTINUE;
}
void main(void) {
   cmd_init( &myprint );              // initialize cmdline with print function
   cmd_set_ready_cb( cmd_ready_cb );  // configure ready cb
   cmd_add("dummy", cmd_dummy, 0, 0); // add one dummy command
   cmd_add("long", cmd_long, 0, 0);   // add one dummy command
   //execute dummy and long commands
   cmd_exe( "dummy;long" );
}

Thread safety

The CLI library is not thread safe, but the CLI terminal output can be locked against other output streams, for example if both traces and CLI output are using serial out.

static Mutex MyMutex;

// mutex wait cb, acquires the mutex, waiting if necessary
static void mutex_wait(void)
{
    MyMutex.lock();
}

// mutex release cb, releases the mutex
static void my_mutex_release(void)
{
    MyMutex.unlock();
}

void main(void) {
   cmd_mutex_wait_func( my_mutex_wait ); // configure mutex wait function before initializing
   cmd_mutex_release_func( my_mutex_release ); // configure mutex release function before initializing
   cmd_init( &myprint );              // initialize cmdline with print function
   cmd_set_ready_cb( cmd_ready_cb );  // configure ready cb.
   //CLI terminal output now locks against MyMutex
}