GithubHelp home page GithubHelp logo

danchitnis / comport Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 0.0 228 KB

A simple package for using W3C Serial Api

Home Page: https://danchitnis.github.io/Serial-API-Examples/

License: MIT License

TypeScript 100.00%
serial api com port hardware embedded communication microcontroller ftdi arduino typescript javascript w3c browser chrome comport microbit edge

comport's Introduction

ComPort

A simple package to use the new Serial Api available in Chrome (also Edge based on Chromium)

๐Ÿ”ฅ Notice : Serial Api is under Chrome's experimental flag since Chrome 79 and on Origins Trail since Chrome 80. The API is unstable.

Why Serial Api

Although WebUSB has been around for some years, it is mainly targeted at companies intending to developed web-based firmwares. A major downside of WebUSB is once a native driver is installed on the OS, the device will no longer be recognized by WebUSB. Unlike WebUSB, the Serial Api is intended for use as a traditional COM port (Serial port) which includes many microcontroller based devices and USB-to-Serial devices such as FTDI and Cypress chipsets. Additionally, you can still implement your own USB CDC protocol, and have the OS driver and Web driver co-exist. The Serial Api opens doors for new and exciting web-based front-ends for small and medium sized embedded projects.

Why ComPort

ComPort makes it easy for embedded developers to quickly build a modern front-end for their applications. It removes the hassle of dealing with async/await functions. This package is not intended for high-performance and high data-rate applications, but for quick and simple development. If high-performance is required then a browser based app is probably the wrong choice.

Potential use cases

all serial communication to and from embedded hardware via USB-to-Serial bridges like FTDI cables and Arduino boards.

How to enable Serial Api (Chrome 79 and above)

Enable it in: chrome://flags/#enable-experimental-web-platform-features

Build instructions

npm i
npm run build

installation

npm i @danchitnis/comport

Example

import the library

import { ComPort } from "@danchitnis/ComPort";

initialize:

const port = new ComPort();
port.connect(9600);
port.addEventListener("rx", dataRX);

data RX event:

function dataRX(e) {
  log(e.detail + "\n");
}

API documentation

See here ๐Ÿงพ

Demos

See here examples tested with Arduino Nano 33 BLE, but also extendable to other boards as it is simply using serial communication.

Useful links

comport's People

Contributors

danchitnis avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  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.