Skip to content

hlfshell/serial-rfid-reader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

serial-rfid-reader

This library is for use for simple serial output RFID readers. It was originally created for the Innovations RFID reader kit found at Sparkfun. It should work for any RFID reader that dumps its output to a serial port that node can read.

Install

npm install serial-rfid-reader

Example use

var RFIDReader = require('serial-rfid-reader');
var rfid = new RFIDReader('/dev/tty0', 9600);

rfid.on("read", function(read){

  console.log("RFID reader has read the following: ", read);
  
}).listen(function(err){
  console.log("RFID Reader is now listening!");
})

Constructor

The constructor accepts two arguments.

  • port - A string representing the COM port to listen to. /dev/tty0 or COM4 are examples.
  • options
    • If it is a number, it is assumed that this is the baud rate.
    • If it is an object, it will be passed to node-serialport as options. Baudrate must be included.

listen(cb)

This will open the serial port and start listening for reads. Once open, it will call the cb and the "open" event, whichever you've defined (if any).

close

This closes the serial port.

Events / functions

There are three events you can subscribe to.

  • serial - function(input, cb) - By default, this function will trim any non alphanumeric characters and spaces. This receives the raw input from the serial port. The callback function cb is function(err, parsedRead);
  • read - function(read) - This is called with the parsedRead returned from serial port if err is null.
  • open - function() - This is called when the serial port successfully opens.

node-serialport

This module makes use of node-serialport. This is a massive pain to compile on windows machines, so I suggest mozying on over to their github page. They have several excellent explanations there and on their wiki page that will help the install process.

node-webkit

Building node-serialport for NW is a pain on windows- moreso when its a sub-module. I wrote a helpful gist specifically for node-serialport, but can act as a helpful guide for building serial-rfid-reader for packaged NW apps.

Here's an example of what I built with this module.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published