npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ds2482

v0.3.0

Published

Provides an interface for the Dallas DS2482 onewire bridge

Downloads

8

Readme

DS2482 Onewire Bridge

![Gitter](https://badges.gitter.im/Join Chat.svg)

Provides an interface for the Dallas DS2482 onewire bridge

Install

$ npm install ds2482

Usage

const DS2482 = require('ds2482');

const wire = new DS2482();

wire.init()
.then(() => wire.search())

.then(found => {
  console.log(found); // Returns a list of ROM addresses as hex encoded strings
})

.catch(err => {
  console.error(err);
});

API

new DS2482([options])

Creates an interface for a Dallas DS2482 i2c to onewire bridge chip

Options:

  • i2c an instance of i2c
  • address the i2c address of the bridge chip, default: 0x18
  • device the location of the i2c interface, default: /dev/i2c-1

wire.init() alias: wire.reset()

Resets the bridge chip and any onewire devices connected to it

Returns: Promise <Uint8> resolves with status register


wire.configureBridge([options])

Configures the onewire interface for subsequent communication

Options:

  • activePullup controls whether to use active or passive pullup
  • strongPullup enables strong pullup only after next command then resets
  • overdrive enable overdrive speed for the bridge chip

Returns: Promise <Uint8> resolves with configuration register


wire.selectChannel([channel])

Select the onewire channel to use for subsequent commands

Note: Only for use with DS2482-800

Arguments:

  • channel channel to select, defaults to 0

Returns: Promise <Uint8> resolves with channel selection register


wire.sendCommand(command [, rom])

Sends a command to a onewire device if specified or all onewire devices if omitted

Arguments:

  • command command to send as an unsigned integer
  • rom optional ROM address of the device to send the command to as a 16 character hex encoded string

Returns: Promise <Uint8> resolves with status register


wire.search()

Searches the bus for all onewire devices and returns a list of ROM addresses as hex encoded strings

Returns: Promise <String[]> resolves with list of roms

[
  "2826274402000012",
  "2889075f0200003e",
  "3ae9f412000000a6"
]

wire.searchByFamily(family)

Searches the bus for all onewire devices of a particular family and returns a list of ROM addresses as hex encoded strings

Arguments:

  • family the family to search as either an unsigned integer or 2 character hex encoded string

Returns: Promise <String[]> resolves with list of roms

[
  "2826274402000012",
  "2889075f0200003e"
]

wire.searchROM()

Searches the bus for the next onewire device and returns the ROM address as a hex encoded string

Returns: Promise <String> resolves with rom

"2826274402000012"

wire.readROM()

Reads the ROM address of the single onewire device and returns it as a hex encoded string

NOTE: Will return a CRC mismatch error if multiple devices are on the bus

Returns: Promise <String> resolves with rom


wire.matchROM(rom)

Selects a single onewire device to send a command to

Arguments:

  • rom the ROM address of the device to select as a 16 character hex encoded string

Returns: Promise <Uint8> resolves with status register


wire.skipROM()

Selects all onewire devices to send a command to

NOTE: Can only be used for commands that don't return a response

Returns: Promise <Uint8> resolves with status register


wire.writeData(data)

Writes one or more bytes to the onewire bus

Arguments:

  • data a single byte, array of bytes or data buffer to be written out

Returns: Promise <Uint8> resolves with status register


wire.readData(size)

Reads one or more bytes from the onewire bus and returns a data buffer

Arguments:

  • size number of bytes to be read in

Returns: Promise <Buffer> resolves with data buffer


DS2482.checkCRC(buffer)

Checks that the crc in the last byte matches the rest of the buffer

Arguments:

  • buffer the data buffer to be checked

Returns: Boolean