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

1-wire-js

v1.4.3

Published

1-Wire USB Interface

Downloads

284

Readme

1-Wire® for Javascript

Project

1-Wire® Communication implemented in Javascript for Chrome using chrome.udb.

Getting Started

You have following options to get started:

  • Download the latest release
  • Clone the repo: git clone git://github.com/KeiserCorp/1-Wire-JS.git
  • Install with NPM: npm install 1-wire-js

Loading

Each release includes a minified distribution version of the library which can be loaded with a module loader, or as a stand alone library.

Module load the library with CommonJS:

var ow = require('1-wire-js');

Including the library as a stand-alone library:

<script src="ow.min.js"></script>
var ow = window.ow;

API

All APIs utilize the Q promise library, so most functions return a promise which has a .then() method. .then() methods accept two callbacks. The first callback is called on success, and the second is called on failure.

ow.permission.request().then(success, failure);

Permission

permission.check()

Checks Chrome for permission to access USB device.

ow.permission.check().then(gotPermission);

permission.request()

Requests Chrome for permission to access USB device. Method must be activated by a user event (such as a button press).

ow.permission.request().then(gotPermission, failedPermission);

Device

device.open()

Attempts to open the USB device.

ow.device.open().then(deviceOpened);

device.close()

Attempts to close the USB device.

ow.device.close().then(deviceClosed);

device.onDeviceAdded

Event listener which triggers upon the addition of a USB device.

addListener(callback) adds a callback to the event listener.

removeListener(callback) removes a callback from the event listener.

ow.device.onDeviceAdded.addListener(deviceConnected);

device.onDeviceRemoved

Event listener which triggers upon the removal of a USB device.

addListener(callback) adds a callback to the event listener.

removeListener(callback) removes a callback from the event listener.

ow.device.onDeviceRemoved.addListener(deviceRemoved);

device.reset()

Performs a device reset which resets device speed and cancels all actions.

ow.device.reset().then(deviceReady);

device.getStatus()

Passes device state registers object into callback.

ow.device.getStatus()
  .then(function (status) {
    if (status.ResultRegisters.DetectKey){
      console.log('Key Detected');
    }
  });

Transfer

transferInfo

A generic transfer object passed to some transfer methods.

direction is the transfer direction ("in" or "out").

endpoint is the target endpoint address.

length (optional) is the amount of data to receive (required only by input transfers).

data (optional) is the data to transmit (required only by output transfers).

var transferInfo = {
  "direction": "in",
  "endpoint": 1,
  "length": 0x20
};

device.interruptTransfer()

Performs a device interrupt transfer.

ow.device.interruptTransfer().then(interruptTransferComplete);

device.controlTransfer(transferInfo)

Performs a device control transfer.

ow.device.controlTransfer(transferInfo).then(controlTransferComplete);

device.bulkTransfer(transferInfo)

Performs a device bulk transfer.

ow.device.bulkTransfer(transferInfo).then(bulkTransferComplete);

Wire

wire.detectShort()

Detects short in the line and passes the result into callback.

ow.wire.detectShort()
  .then(function (shorted) {
    if (shorted) {
      throw new Error("Short Detected");
    }
  });

wire.setSpeed(overdrive)

Sets the speed to either normal or overdrive based on passed in boolean value overdrive;

ow.wire.setSpeed(true).then(speedSet);

wire.rest()

Sends a reset and then checks for a wire short.

ow.wire.rest().then(resetComplete);

wire.write(data, clearWire)

Writes data onto the wire.

data must be type Uint8Array or data loss may occur.

Pass a true value as the clearWire parameter to have the wire cleared after the write operation.

ow.wire.write(data).then(writeComplete);

wire.writeBit(bit)

Writes a single bit onto the wire.

ow.wire.writeBit(bit).then(writeBitComplete);

wire.read(byteCount)

Read a length of data defined by byteCount from the wire and passes it to callback.

ow.wire.read(0x20)
  .then(function(data){
    storeData(data);
  });

wire.readBit()

Reads a single bit of data from the wire and passes it to callback.

ow.wire.readBit()
  .then(function(bitSet){
    test = bitSet;
  });

wire.clearByte()

Clears a single byte of data from the wire.

ow.wire.clearByte().then(wireCleared);

Key

key.romCommand(match, keyRom, overdrive)

Performs a key ROM match operation on the network.

match determines if commands should target a specific key ROM (true) or if commands should target all devices (false).

keyRom should contain the ROM of the device being targeted if match is true.

overdrive should be set to true if commands should be performed in overdrive speed.

ow.key.romCommand(true, keyRom, true).then(keyRomMatched);

key.romMatch(keyRom)

Performs a key ROM match at normal speed.

Alias for ow.key.romCommand(true, keyRom, false)

ow.key.romMatch(keyRom).then(keyRomMatched);

key.romMatchOverdrive(keyRom)

Performs a key ROM match at overdrive speed.

Alias for ow.key.romCommand(true, keyRom, true)

ow.key.romMatch(keyRom).then(keyRomMatched);

key.romSkip()

Performs a key ROM skip at normal speed.

Alias for ow.key.romCommand(false, null, false)

ow.key.romSkip().then(keyRomSkipped);

key.romSkipOverdrive()

Performs a key ROM skip at overdrive speed.

Alias for ow.key.romCommand(false, null, true)

ow.key.romSkipOverdrive().then(keyRomSkipped);

key.searchFirst()

Searches network for keys and passes the first key ROM to the callback.

ow.key.searchFirst()
  .then(function(rom){
      keyROM = rom;
  });

key.searchNext()

Searches network for keys and passes the next key ROM to the callback.

This method will loop through key ROMs

ow.key.searchNext()
  .then(function(rom){
      keyRom = rom;
  });

key.readAll(keyRom, overdrive)

Reads all of the data from the key targeted by keyRom and passes the data to the callback.

keyRom is the target key ROM stored as Uint8Array.

overdrive is a boolean value determining operation speed. (Default: false)

ow.key.readAll(keyRom, true)
  .then(function(data){
      keyData = data;
  });

key.write(keyRom, offset, data, overdrive)

Writes data to the key targeted by keyRom.

keyRom is the target key ROM stored as Uint8Array.

offset is the memory offset where the data is to be written.

data is the data to be written to the key memory stored as Uint8Array.

overdrive is a boolean value determining operation speed. (Default: false)

ow.key.write(keyRom, 0x00, data, true).then(writeComplete);

key.writeAll(keyRom, data, overdrive)

Writes data to the key targeted by keyRom starting at the memory beginning.

keyRom is the target key ROM stored as Uint8Array.

data is the data to be written to the key memory stored as Uint8Array.

overdrive is a boolean value determining operation speed. (Default: false)

ow.key.writeAll(keyRom, data, true).then(writeComplete);

key.writeDiff(keyRom, newData, oldData, overdrive)

Writes newData to the key targeted by keyRom starting at the memory beginning using a diffing algorithm to speed up writes.

keyRom is the target key ROM stored as Uint8Array.

newData is the data to be written to the key memory stored as Uint8Array.

oldData is the current key memory stored as Uint8Array.

overdrive is a boolean value determining operation speed. (Default: false)

ow.key.writeAll(keyRom, newData, lastDump, true).then(writeComplete);

Contributors

Copyright and License

Licensed under the MIT license.