New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

1-wire-js

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

1-wire-js

1-Wire USB Interface

  • 1.2.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
23
Maintainers
1
Weekly downloads
 
Created
Source

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.requestPermission().then(success, failure);

Permissions

checkPermission()

Checks Chrome for permission to access USB device.

ow.checkPermission().then(gotPermission);
requestPermission()

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

ow.requestPermission().then(gotPermission, failedPermission);

Device

deviceOpen()

Attempts to open the USB device.

ow.deviceOpen().then(deviceOpened);
deviceClose()

Attempts to close the USB device.

ow.deviceClose().then(deviceClosed);
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.onDeviceAdded.addListener(deviceConnected);
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.onDeviceRemoved.addListener(deviceRemoved);

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
};
deviceInterruptTransfer()

Performs a device interrupt transfer.

ow.deviceInterruptTransfer().then(interruptTransferComplete);
deviceControlTransfer(transferInfo)

Performs a device control transfer.

ow.deviceControlTransfer(transferInfo).then(controlTransferComplete);
deviceBulkTransfer(transferInfo)

Performs a device bulk transfer.

ow.deviceBulkTransfer(transferInfo).then(bulkTransferComplete);

Device Control

deviceReset()

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

ow.deviceReset().then(deviceReady);
deviceGetStatus()

Passes device state registers object into callback.

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

1-Wire Commands

wireDetectShort()

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

ow.wireDetectShort()
  .then(function (shorted) {
    if (shorted) {
      throw new Error("Reset Failed: Short Detected");
    }
  });

Contributors

Copyright Keiser Corporation under the MIT license.

FAQs

Package last updated on 18 Jan 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc