• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

512
Views
Google Chrome Web Serial API: How do I configure the parameters for Modbus RTU?

It is my intention to use the Web Serial API in Google Chrome to address a device with Modbus RTU.

The baud rate must be specified to start the setup - consequently this has already been done.

The following link leads to the part of a documentation which describes how to set up the parameters: Goog https://wicg.github.io/serial/#serialoptions-dictionary

I do not understand the syntax explanation. Javascript does not know a "dictionary".

Thanks for your help

about 3 years ago · Juan Pablo Isaza
2 answers
Answer question

0

As explained at https://web.dev/serial/#open-port, once you have a SerialPort object, calling port.open() with the desired baud rate will open the serial port. The baudRate dictionary member specifies how fast data is sent over a serial line. It is expressed in units of bits-per-second (bps).

Check your device's documentation for the correct value as all the data you send and receive will be gibberish if this is specified incorrectly. For some USB and Bluetooth devices that emulate a serial port this value may be safely set to any value as it is ignored by the emulation.

// Prompt user to select any serial port.
const port = await navigator.serial.requestPort();

// Wait for the serial port to open.
await port.open({ baudRate: 9600 });

You can also specify other options when opening a serial port. These options are optional and have convenient default values.

  • dataBits: The number of data bits per frame (either 7 or 8).
  • stopBits: The number of stop bits at the end of a frame (either 1 or 2).
  • parity: The parity mode (either "none", "even" or "odd").
  • bufferSize: The size of the read and write buffers that should be created (must be less than 16MB).
  • flowControl: The flow control mode (either "none" or "hardware").
// Wait for the serial port to open with more options.
await port.open({
  baudRate: 9600,
  dataBits: 8,
  stopBits: 1,
  parity: "none",
  bufferSize: 255,
  flowControl: "none",
});

about 3 years ago · Juan Pablo Isaza Report

0

async function start() 
{
        // Prompt user to select any serial port.
        const port = await navigator.serial.requestPort();

        // Wait for the serial port to open.
        await port.open({ baudRate: 9600, dataBits: 8,  stopBits: 2, ParityType: "none"});
}
about 3 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error