Code Monkey home page Code Monkey logo

rpc-service-spi's Introduction

RPC Service - I2C

This service provides an ability to manage I2C peripherals on devices remotely. It is possible to call this service programmatically via serial, HTTP/RESTful, Websocket, MQTT or other transports (see RPC section) or via the mos tool.

Below is a list of exported RPC methods and arguments:

I2C.Scan

Scan the I2C bus, return a list of available device addresses. Arguments: none.

Example usage:

mos call I2C.Scan
[
  31    # There is only 1 device with address 31 attached to the I2C bus
]

I2C.Read

Read data from the I2C device. Arguments:

{
  "addr: 31,    // Required. Device address.
  "len": 2      // Required. Number of bytes to read.
}

Reply:

{
  // Hex-encoded data. Each byte is encoded as XX hex code, e.g. 0x00 0x1d:
  "data_hex": "001d"
}

Example usage:

mos call I2C.Read '{"addr": 31, "len": 2}'
{
  "data_hex": "001d"
}

I2C.Write

Write data to the I2C device. Arguments:

{
  "addr: 31,              // Required. Device address.
  "data_hext": "1f3c6a"   // Required. Hex-encoded data to write
}

Example usage (showing failed write):

mos call I2C.Write '{"addr": 31, "data_hex": "1f3c6a"}'
Error: remote error: I2C write failed

I2C.ReadRegB

Read 1-byte register value. Arguments:

{
  "addr: 31,  // Required. Device address.
  "reg": 0    // Required. Register number.
}

Example usage:

mos call I2C.ReadRegB '{"addr": 31, "reg": 0}'
{
  "value": 0
}

I2C.WriteRegB

Write 1-byte register value. Arguments:

{
  "addr: 31,    // Required. Device address.
  "reg": 0,     // Required. Register number.
  "value": 0    // Required. 1-byte value to write.
}

Example usage:

mos call I2C.WriteRegB '{"addr": 31, "reg": 0, "value": 0}'

I2C.ReadRegW

Same as I2C.ReadRegB, but read 2-byte (word) register value.

I2C.WriteRegW

Same as I2C.WriteRegB, but write 2-byte (word) register value.

rpc-service-spi's People

Contributors

7v0lk0v avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.