electron-serialport-poc

CC0-1.0 License

Stars
0

electron-serialport-poc

This test assumes you have a prolific USB to RS-232 Serial Adapter.

Performing Loopback Test

Dependencies

  • First you must install the prolific driver for your Operating System.
  • After installing and restarting your system, you must next identify the port for testing. For example, on Mac you can run ls /dev | grep tty.usb which should return tty.usbserial, if your driver was installed correctly.
  • Next, install @serialport/repl by running npm install -g @serialport/repl
  • The TXD(3) pin must be connected to the RXD(2) pin. - DE-9 Male diagram

Performing Test

  • Now let's perform the test in the serialport repl!
serialport-repl {path-to-port} # serialport-repl /dev/tty.usbserial on a Mac
# This will pre-load a `port` variable with a connection to the serial adapter.
> port.open() # Allow the port to accept I/O
> port.write("Hello World!")
> const output = port.read() 
<Buffer 48 65 6c 6c 6f 20 77 6f 72 6c 64 21> # If connection between pins was successfully made
> output.toString(); # should be "Hello World!"

Documentation

Electron App

An app is bundled using Electron which leverages SerialPort to display all serial connections.

You must have Node.js (which comes with npm) installed on your computer. From your command line:

# git clone the repository and run the following
cd electron-serialport-poc
# Install dependencies
npm install
# Run the app
npm start