Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

401
Views
Google Chrome Web Serial API: ¿Cómo repetir una consulta de registro de forma permanente?

Puedo direccionar un dispositivo vía Modbus con mi aplicación web. Direccionamiento significa en este caso enviar un comando Modbus y recibir una respuesta.

Sin embargo, no puedo repetir el proceso sin cerrar el navegador y reiniciar la página.

Mi pregunta específica ahora es ¿cómo ajusto el código para reenviar permanentemente el mismo comando modbus? Entonces, presionaría el botón y, en lugar de que aparezca una sola respuesta en la consola, después de la respuesta aparece otra respuesta y aparecería otra respuesta ...

Gracias por tu ayuda.

 <!DOCTYPE html> <html lang="de"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>examplepage</title> <script> 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"}); //Übermittle Anfrage um Inhalt von Register anzufordern const writer = port.writable.getWriter(); //const data = new Uint8Array([0x01, 0x03, 0x00, 0x01, 0x00, 0x02, 0x95, 0xCB]); // request for register const data = new Uint8Array([0x01, 0x03, 0x00, 0x37, 0x00, 0x02, 0x75, 0xC5]); await writer.write(data); // Allow the serial port to be closed later. writer.releaseLock(); // empfangen const reader = port.readable.getReader(); // Listen to data coming from the serial device. while (true) { const { value, done } = await reader.read(); if (done) { // Allow the serial port to be closed later. reader.releaseLock(); break; } // value is a Uint8Array. console.log(value); } } if ("serial" in navigator) { alert("Your browser supports Web Serial API!"); } else {alert("Your browser does not support Web Serial API, the latest version of Google Chrome is recommended!");}; </script> </head> <body> <button onclick="start()">Click me</button> </body> </html>

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!