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

192
Views
Escribir en el puerto serie cuando se está leyendo

Puedo leer y escribir en un puerto serie por separado con dos botones separados (hacer clic). Ahora trato de escribir en el puerto serie, cuando se lee un valor ("Envíe el archivo") desde el mismo puerto con un solo clic. A continuación se muestra mi código que muestra errores.

  1. TypeError: no se pudo ejecutar 'escribir' en 'UnderlyingSinkBase': el valor proporcionado no es del tipo '(ArrayBuffer o ArrayBufferView)'.

  2. TypeError no capturado (en promesa): no se pudo ejecutar 'pipeTo' en 'ReadableStream': no se puede canalizar una secuencia bloqueada.

 navigator.serial.requestPort().then(async (port) => { await port.open({ baudRate: 115200 }); // Reading port // while (port.readable) { const textDecoder = new TextDecoderStream(); const readableStreamClosed = port.readable.pipeTo(textDecoder.writable); const reader = textDecoder.readable.getReader(); try { while (true) { const { value, done } = await reader.read(); if (done) { break; } if (value) { document.getElementById('log').innerHTML += value + "<br/>"; if(value.includes('Please send the file')){ var arr=[]; // Getting file to be sent // var oReq = new XMLHttpRequest(); oReq.open("GET", "uart_rx_test2.bin", true); oReq.responseType = "arraybuffer"; oReq.onload = function (oEvent) { var arrayBuffer = oReq.response; // Note: not oReq.responseText if (arrayBuffer) { var byteArray = new Uint8Array(arrayBuffer); arr = byteArray; } }; oReq.send(null);

// Escribiendo al puerto //

 const writer = port.writable.getWriter(); await writer.write(arr); } } } } catch (error) { console.log(error) } } }).catch((e) => { console.log(e) });
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!