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

tp-rs232

v0.0.5

Published

Node.JS library for TOP Vending Machine

Downloads

20

Readme

TpSeries

Library written in node.js for TOP Vending Machine tp products

Supported devices: TP1, TP11, TP2, TP3

Installation

Install from npm:

npm install tp-rs232
const TpSeries = require('tp-rs232');

let tp = new TpSeries({
  debug: true,
  timeout: 5000
});

Methods

All methods use Promise

  • tp.open('COM1') - Connect device
  • tp.close() - Disconnect device
  • tp.command('COMMAND_NAME') - Execute command and get answer
  • tp.enabled - Validator status
  • tp.openPort - Port status
  • tp.powerUp - Power Up (Bill Acceptor Active)

Command

tp.command('ENABLE')
.then(result => {
    console.log('status:', result.status)
    return;
})

tp.command('ACCEPT_BANKNOTE')

See all supported commands

Event

eSSP.on('READ_NOTE', result => {
    console.log(result)
})

See all supported events

Example

const TpSeries = require('tp-rs232');

let serialPortConfig = {
  baudrate: 9600,
  databits: 8,
  stopbits: 1,
  parity: 'even'
};

let tp = new TpSeries({
  debug: false,
  timeout: 5000
});

tp.on('OPEN', () => {
  console.log('Port opened!');
});

tp.on('CLOSE', () => {
  console.log('Port closed!');
});

tp.on('READ_NOTE', (result) => {
  console.log('READ_NOTE');
  console.log(result);

  if (result.channel === 2) {
    tp.command('REJECT_BANKNOTE');
  } else {
    tp.command('ACCEPT_BANKNOTE');
  }
});

tp.on('STACKING', (result) => {
  console.log(result);

  if (result.channel === 1) {
    tp.command('DISABLE').then((result) => {
      console.log(result);
      tp.close();
    });
  }

  if (result.channel === 3) {
    tp.removeAllListeners();
  }
});

tp.on('CLOSE', () => {
  console.log('CLOSE');
});
tp.on('POWER_UP', () => {
  console.log('POWER_UP');
});
tp.on('MOTOR_FAILURE', () => {
  console.log('MOTOR_FAILURE');
});
tp.on('CHECKSUM_ERROR', () => {
  console.log('CHECKSUM_ERROR');
});
tp.on('BILL_JAM', () => {
  console.log('BILL_JAM');
});
tp.on('BILL_REMOVE', () => {
  console.log('BILL_REMOVE');
});
tp.on('STACKER_OPEN', () => {
  console.log('STACKER_OPEN');
});
tp.on('SENSOR_PROBLEM', () => {
  console.log('SENSOR_PROBLEM');
});
tp.on('BILL_FISH', () => {
  console.log('BILL_FISH');
});
tp.on('STACKER_PROBLEM', () => {
  console.log('STACKER_PROBLEM');
});
tp.on('BILL_REJECT', () => {
  console.log('BILL_REJECT');
});
tp.on('INVALID_COMMAND', () => {
  console.log('INVALID_COMMAND');
});
tp.on('RESERVED', () => {
  console.log('RESERVED');
});
tp.on('RESPONSE_WHEN_ERROR', () => {
  console.log('RESPONSE_WHEN_ERROR');
});
tp.on('ENABLE', (result) => {
  console.log('ENABLE');
  console.log(result);
});
tp.on('DISABLE', (result) => {
  console.log('DISABLE');
  console.log(result);
});
tp.on('REJECT', () => {
  console.log('REJECT');
});
tp.on('COMMAND_NOT_FOUND', () => {
  console.log('COMMAND_NOT_FOUND');
});

tp.open('/dev/tty.usbserial-14330', serialPortConfig)
  .then(() => {
    console.log('GO!!!');

    tp.command('POWER_UP')
      .then(() => tp.command('ENABLE'))
      .then((result) => {
        console.log(result);
      });
  })
  .catch((error) => {
    console.log(error);
  });

Supported Commands:

Command name | Information return | Need promise | Description ------------------------------------|-------------------|-----------------------|------------------- POWER_UP | yes | no | Power Up (Bill Acceptor Active) ACCEPT_BANKNOTE | yes | no | Command to accept a banknote REJECT_BANKNOTE | yes | no | Command to reject a banknote HOLD_ESCROW | yes | no | Hold in Escrow STATUS | yes | yes | Returns the current status of the device ENABLE | yes | yes | Command to enable the banknote validator DISABLE | yes | yes | Command to disable the banknote validator RESET | yes | no | Command to reset the device

Example commands with options:

POWER_UP
tp.command('POWER_UP').then((result) => console.log(result););
ACCEPT_BANKNOTE
tp.command('ACCEPT_BANKNOTE').then((result) => console.log(result););
REJECT_BANKNOTE
tp.command('REJECT_BANKNOTE').then((result) => console.log(result););
HOLD_ESCROW
tp.command('HOLD_ESCROW').then((result) => console.log(result););
RESET
tp.command('RESET').then((result) => console.log(result););
STATUS
tp.command('STATUS').then((result) => console.log(result););
ENABLE
tp.command('ENABLE').then((result) => console.log(result););
DISABLE
tp.command('DISABLE').then((result) => console.log(result););

Supported Events:

Event name | Description ------------------------------------|------------------ OPEN | Event that detects that the device was opened successfully CLOSE | Event that detects that the device was closed POWER_UP | Power Up (Bill Acceptor Active). MOTOR_FAILURE | An motor fault was found. CHECKSUM_ERROR | Checksum error. BILL_JAM | The device has detected that coins are jammed in its mechanism and cannot be removed other than by manual intervention. The value paid at the jam point is given in the event data. BILL_REMOVE | Reported when a note float unit has been detected as removed from its validator. STACKER_OPEN | The device has detected that the stacked has been opened. SENSOR_PROBLEM | The device has encountered a problem with the sensor. BILL_FISH | BILL FISH STACKER_PROBLEM | The device has encountered a stacker problem. BILL_REJECT | The note has been rejected from the validator and is available for the user to retrieve. INVALID_COMMAND | Invalid command encountered. RESERVED | Reserved RESPONSE_WHEN_ERROR | Response when Error ENABLE | The device is enabled. DISABLE | The device is disabled. READ_NOTE | A note has been detected by the device. STACKING | A note has been stacked. REJECT | A note has been rejected. COMMAND_NOT_FOUND | The command was not found.

Errors and contributions

For an error write the problem directly on github issues or submit it to the mail [email protected]. If you want to contribute to the project please send an email.

#TP1 , #TP11 , #TP2 , #TP3 , #TOP Vending Machine