Reference   Language | Libraries | Comparison | Changes

Ciao

Shell connector

Description

This Connector allows to execute Shell commands for Linux side from an Arduino sketch. Below the steps that you should follow to use the File connector:

  • setup Shell connector;
  • enable the connector;
  • write a simple sketch;
  • upload the sketch and enjoy.

Setup connector

You can find File Connector configuration file at the following path: /usr/lib/python2.7/ciao/connectors/shell/shell.json.conf

{
 "name":"shell",
 "description":"Shell connector for the Ciao Core",
 "authors":["Arduino Team <swdev@arduino.org>;"],
 "repository":"https://github.com/arduino-org/Ciao",
 "version":"0.0.1",
 "params": {
                  "working_directory":"/root",
                  "read_max_size":1024
                  },
 "log":{
          "level":"debug"
          }
}

The parameters at the beginning are for internal use, do NOT edit them (name, description, version, ciao) unless you know exactly what you are doing.

The configurable part is the one identified by "params" key:

  • “working_directory”: specifies the current working directory from where the command is executed.
  • “read_max_size”: specifies the max byte value that Connector can read.

Enable connector

Each Ciao connector must have a configuration file for the Ciao Core, this simple file is mandatory to enable the connector.

To enable Shell connector please edit the file at the following path: /usr/lib/python2.7/ciao/conf/shell.ciao.json.conf

{
 "name":"shell",
 "enabled":true,
 "type":"managed",
 [...]
}

The key enabled must be set to true (boolean value). This is the only parameter you are required to edit in order to enable the Shell Connector. Once done Ciao Core will be ready and configured to use Shell Connector.

Example

#include <Ciao.h>

void setup() {
  //init Ciao
  Ciao.begin();
  Serial.begin(9600);
}
void loop() {
  //Run commands in Linino OS to get date
  CiaoData data = Ciao.write("shell", "date");
  if (!data.isEmpty()) {
    //Get data back
    String usage = data.get(2);
    Serial.println(usage);
  }
  delay(10000);
}
Reference Home

Corrections, suggestions, and new documentation should be posted to the Forum.

The text of the Arduino reference is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.