blob: c10242518791466829a842f9a8e7fe63d66ad108 [file] [log] [blame]
.. _module-pw_web:
Pigweed provides an NPM package with modules to build web UIs for Pigweed
Also included is a basic React app that demonstrates using the npm package.
Available Modules
Following Pigweed modules are included in the NPM package:
- `pw_hdlc <>`_
- `pw_rpc <>`_
- `pw_tokenizer <>`_
- `pw_transfer <>`_
To help with connecting to WebSerial and listening for serial data, a helper
class is also included under ``WebSerial.WebSerialTransport``. Here is an example
.. code:: javascript
import { WebSerial, pw_hdlc } from 'pigweedjs';
const transport = new WebSerial.WebSerialTransport();
const decoder = new pw_hdlc.Decoder();
// Present device selection prompt to user
await transport.connect();
// Listen and decode HDLC frames
transport.chunks.subscribe((item) => {
const decoded = decoder.process(item);
for (const frame of decoded) {
if (frame.address === 1) {
const decodedLine = new TextDecoder().decode(;
You can install ``pigweedjs`` in your web application by:
.. code:: bash
$ npm install --save pigweedjs
Getting Started
After installing, you can import modules from ``pigweedjs`` in this way:
.. code:: javascript
import { pw_rpc, pw_tokenizer } from 'pigweedjs';
Click on each module above to see its usage.