Giter Club home page Giter Club logo

serial-reader's Introduction

SERIAL PORT PROTOTYPES

This prototype contains three separate nodejs applications for use in reading serial port data and communicating it to a front end web application. It demonstrates two different methods of broadcasting the serial data, one using ws, and the other using socket i/o.

###Dependencies###

  • node
  • serialport - node module for reading and writing serialport data
  • ws - if using the ws library to broadcast serial data
  • express and socket.io if using socket i/o to broadcast serial data

###Files###

  • listports.js - this node application simply includes the serialport library, and loops through the ports, logging their pertinent info. It is useful in determining the port name for your specific usb port, which will be necessary in order to read and transmit data from the serial port to your web application.
  • serial-ws.js - this node application uses serialport to establish a serial connection and ws to transmit that data to the front end web application (wsReceiver.html)
  • io-send-serial.js - this node application uses serialport to establish a serial connection and socketio/express to transmit that data to the front end web application (serialReceiver.html)
  • wsReceiver - receives serial data from serial-ws.js
  • serialReceiver - receives serial data from io-send-serial.js

###Installation###

  • Install node according to the directions at the nodejs website
  • CD into this project folder in terminal / command prompt
  • Run sudo npm install to install all dependencies. If you would rather install all the modules globally, make sure to run node [modulename] -g for each module instead of the sudo npm install

###Running the examples###

  • First, make sure you've followed the installation instructions above.
  • Then, make sure your serial device is plugged in via USB to your computer and functioning properly.
  • This application uses a barcode reader (DS457 Fixed Mount Imager from Zebra Technologies). The barcode reader must be configured with type "CDC COM Port Emulation" by scanning the barcode from the DS457 Fixed Mount Imager manual.

####List Ports####

  • run node listports.js from this directory in terminal to list all of your ports.
  • Look for something saying usbmodem in the comName object key to obtain your serial port's name.
  • Uncomment the //console.log(serialport); line to get more serialport data, such as the methods available to you with this library, and the types of parsers available for serial data.

####Serial WS####

  • run node serial-ws.js from this directory in terminal to begin listening for serial data.
  • Make sure the name in the portName variable matches your port name from listPorts.js.
  • If your serial device uses a delimiter between messages, make sure to uncomment the parsers.readline line in the code, and input the proper delimiter (\n for newline by default). Also comment out the parsers.raw line
  • If you want to communicate on a port other than 8081, change the SERVER_PORT variable
  • Load up the wsReceiver.html in your web browser and make sure the web console is available. Scan a barcode, and its number should log to your browser console

###IO Send Serial###

  • run node io-send-serial.js from this directory in terminal to begin listening for serial data.
  • Make sure the name in the portName variable matches your port name from listPorts.js.
  • If your serial device uses a delimiter between messages, make sure to uncomment the parsers.readline line in the code, and input the proper delimiter (\n for newline by default). Also comment out the parsers.raw line
  • If you want to communicate on a port other than 3000, change the SERVER_PORT variable
  • Load up the serialReceiver.html in your web browser and make sure the web console is available. Scan a barcode, and its number should log to your browser console
  • If you've changed the port in io-send-serial.js - you'll need to change the script tag that includes socket.io to read from that port (i.e., change localhost:3000/socket.io...) as well as the port in `io.connect('http://localhost:3000')

###Notes###

  • The serial data is sent as a string to the front end web application - if it is a number, it must be converted there.

serial-reader's People

Watchers

 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.