Skip to content
This repository has been archived by the owner on Aug 5, 2022. It is now read-only.

Latest commit

 

History

History
67 lines (50 loc) · 3.65 KB

README.md

File metadata and controls

67 lines (50 loc) · 3.65 KB

Board API

The Board API provides low level interfaces for I/O operations:

Hardware pin names are usually marked on the circuit boards, that defines a board namespace for pins. However, operating systems, such as Linux, or Zephyr define a pin name mapping that is consistent across the boards supported by the OS. This API supports both board and OS (system) defined namespaces. Pin names are opaque to the application, either strings or numbers that gain meaning in either the board or OS namespace. Also, the API exposes board name, OS name (including OS version) and API version for all board APIs.

Since it is generally easier for developers to just look at a given board and use the names printed there in the API, by default the board namespace is used, but developers can specify to use the system namespace as well. If a given pin value is not found in the default (or provided) namespace, an error is thrown: there is no fallback search in the other namespace.

Examples for the supported board namespaces are listed in this directory:

For the supported OS pin namespace, consult the documentation of the implementation and its underlying OS documentation.

The full Web IDL definition for Board and IO APIs can be found in webidl.md.

The Board API object

The API entry point is a Board object provided by an implementation (module). When requiring "board", the following steps are run:

  • If there is no permission for using the functionality, throw SecurityError.
  • If the Board functionality is not supported on the board, throw "NotSupportedError".
  • Let board be the Board API object, and initialize it by fetching board name and OS name. Return board.
var board = require("board");

console.log("Connected to board: " + board.name + " running " + board.os);

If the functionality is not supported by the platform, require should throw NotSupportedError.

The Board interface

Represents a hardware circuit board such as Arduino 101.

Property Type Optional Default value Represents
name String no undefined board name
os String no undefined OS name
apiVersion String no versions.board in package.json API version
Event name Event callback argument
error Error object

The name property is read-only, and provides the board name.

The os property is read-only, and provides the underlying operating system name.

The apiVersion property is read-only, and provides the provides the Board API version, as specified in the versions.board property of package.json.

Board errors are represented as augmented Error objects. The following Error names are used for signaling issues:

  • BoardDisconnectError
  • BoardTimeoutError
  • BoardIOError.