Giter Site home page Giter Site logo

travis5491811 / nodeusbscale Goto Github PK

View Code? Open in Web Editor NEW

This project forked from danieloneill/nodeusbscale

0.0 1.0 0.0 12 KB

Node.js bindings for several USB scales (Pitney Bowes, Dymo, etc.)

License: GNU General Public License v2.0

Python 2.20% JavaScript 9.27% C++ 88.53%

nodeusbscale's Introduction

nodeusbscale

Node.js+Linux (HID) bindings for several USB scales (Pitney Bowes, Dymo, etc.)

Tested with:

  • 0922:8004 Dymo-CoStar Corp.
  • 0d8f:0200 Pitney Bowes

Data packets are in the following format:

{
	'weight': xxxxxx,
	'balanced': <true/false>
}

Example

#!/usr/bin/env node

var UsbScale = require('nodeusbscale');

var dev = UsbScale.create();
dev.open( '/dev/usb/hiddev0', function(obj, err) {
	if( err ) {
		console.log("UsbScale: Failed to open device: "+err);
		return false;
	}
	dev['data'] = function(data) {
		console.log("UsbScale event: "+JSON.stringify(data, null, 2));
	};
});

// Hack to prevent Node.js from exiting, sorry.
var http = require('http');
var httpServer = http.createServer(function(){});
httpServer.listen(8084);
console.log("Listening for keyboard input...");

Methods

Factory

usbscale::create()

Returns an initialised usbscale object.

  • Returns: An initialised usbscale object.

usbscale object

usbscaleObject::open( path, callback( usbscaleObject, error ) )

Open an usbscale device, associate it to this object, and fire the provided callback upon completion.

The parameters passed to the provided callback function are usbscaleObject which is a reference to the usbscale object, and error which will be an error string in the case of an error, or undefined on success.

  • Returns: A reference to itself.

usbscaleObject::data( usbscaleEvent )

A virtual method of the usbscaleObject. Reimplement it to handle usbscaleEvents. It can be ignored, but if you ignore it, you might as well not use this module at all.

nodeusbscale's People

Contributors

danieloneill avatar

Watchers

James Cloos 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.