uci-i2c-bus/readme.md

36 lines
1.6 KiB
Markdown
Raw Normal View History

# uCOMmandIt (UCI) - I2C Bus Class
## Raspberry Pi ONLY!
2017-01-12 19:50:06 -08:00
<!-- find and replace the package name to match -->
[![Build Status](https://img.shields.io/travis/uCOMmandIt/uci-i2c-bus.svg?branch=master)](https://travis-ci.org/uCOMmandIt/uci-i2c-bus)
[![Inline docs](http://inch-ci.org/github/uCOMmandIt/uci-i2c-bus.svg?branch=master)](http://inch-ci.org/github/uCOMmandIt/uci-i2c-bus)
[![Dependencies](https://img.shields.io/david/uCOMmandIt/uci-i2c-bus.svg)](https://david-dm.org/uCOMmandIt/uci-i2c-bus)
[![devDependencies](https://img.shields.io/david/dev/uCOMmandIt/uci-i2c-bus.svg)](https://david-dm.org/uCOMmandIt/uci-i2c-bus?type=dev)
[![codecov](https://img.shields.io/codecov/c/github/uCOMmandIt/uci-i2c-bus/master.svg)](https://codecov.io/gh/uCOMmandIt/uci-i2c-bus)
This is an Raspberry Pi only I2C bus socket packet listener and I2C bus master processor. See /examples/bus.js for how to implement an instance. The rest of the examples are client examples that will talk to a running i2c-bus instance
Here is a simple script to get an instance going (on an RPI only)
```
/*
* Raspberry Pi (only) I2C-Bus listener
* named pipe socket 'i2c-bus' is always created by default /tmp directory unless
* env variable SOCKETS_DIR='' is used to create a 'i2c-bus.sock' in a particular directory
* e.g. command >SOCKETS_DIR=/opt/sockets node -r esm i2cbus
* add TCP listener with tcp:true. Will listen on port 1776 by default
*/
import Bus from '@uci/i2c-bus'
;
(async () => {
let i2cbus = new Bus({id:'i2c-bus',tcp:true})
await i2cbus.init()
})().catch(err => {
console.error('FATAL: UNABLE TO START SYSTEM!\n',err)
})
```