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

rfid-driver

v1.0.1

Published

Biblioteca TypeScript para integração com dispositivos RFID USB.

Downloads

7

Readme

Biblioteca TypeScript para RFID USB

Esta biblioteca TypeScript foi desenvolvida para facilitar a integração com dispositivos RFID USB em aplicações React no lado do cliente. A necessidade desta lib veio neste projeto: https://github.com/LabsPlus/Eat-Eating-WebApp, um sistema para gerenciamento de restaurantes universitarios, implantado em algumas universidades do sul da Bahia.

Instalação

Para instalar a biblioteca, você pode usar npm ou yarn:

npm install rfid-driver

Como Encontrar Vendor ID e Product ID

Para integrar o seu dispositivo RFID USB com esta biblioteca, siga os passos abaixo para obter o Vendor ID e Product ID necessários:

Windows:

  1. Conecte o leitor RFID USB ao seu computador.
  2. Abra o "Gerenciador de Dispositivos".
  3. Localize o seu dispositivo na lista de dispositivos USB.
  4. Clique com o botão direito do mouse no dispositivo e selecione "Propriedades".
  5. Na guia "Detalhes", selecione "IDs de hardware" no menu suspenso.
  6. Anote o Vendor ID e Product ID exibidos.

Linux:

  1. Conecte o leitor RFID USB ao seu computador.
  2. Abra um terminal.
  3. Execute o comando lsusb.
  4. Encontre o seu dispositivo na lista. O output mostrará o Vendor ID e Product ID do dispositivo.
  5. Anote o Vendor ID e Product ID exibidos.

Exemplos de Uso

Exemplo Básico de Uso

import { RfidDriver } from 'rfid-driver';

const vendorId = 0x1234; // Substitua com o ID do fornecedor do seu dispositivo
const productId = 0x5678; // Substitua com o ID do produto do seu dispositivo

const rfid = new RfidDriver(vendorId, productId);

async function readData() {
    try {
        const data = await rfid.readData('FFCA000000');
        console.log('Dados lidos:', data.toString('hex'));
    } catch (error) {
        console.error('Erro ao ler dados:', error);
    } finally {
        rfid.close();
    }
}

readData();

Integração com React

import React, { useEffect, useState } from 'react';
import { RfidDriver } from 'rfid-driver';

const vendorId = 0x1234; // Substitua com o ID do fornecedor do seu dispositivo
const productId = 0x5678; // Substitua com o ID do produto do seu dispositivo

const RfidReader: React.FC = () => {
    const [rfid, setRfid] = useState(null);

    useEffect(() => {
        const initRfid = async () => {
            try {
                const driver = new RfidDriver(vendorId, productId);
                await driver.openDevice();
                setRfid(driver);
            } catch (error) {
                console.error('Erro ao inicializar RFID:', error);
            }
        };

        initRfid();

        return () => {
            if (rfid) {
                rfid.close();
            }
        };
    }, []);

    const handleReadData = async () => {
        try {
            if (rfid) {
                const data = await rfid.readData('FFCA000000');
                console.log('Dados lidos:', data.toString('hex'));
            }
        } catch (error) {
            console.error('Erro ao ler dados:', error);
        }
    };

    return (
        <div>
            <button onClick={handleReadData}>Ler Dados RFID</button>
        </div>
    );
};

export default RfidReader;

Exemplos de Dispositivos

A biblioteca suporta uma variedade de dispositivos RFID. Aqui estão alguns exemplos:

  • Dispositivo A

    • Vendor ID: 0x1234
    • Product ID: 0x5678
  • Dispositivo B

    • Vendor ID: 0xABCD
    • Product ID: 0xEF01

Contribuição

Contribuições são bem-vindas! Para relatar bugs ou enviar pull requests, por favor, consulte nosso repositório no GitHub.