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

175
Views
Write binary file Web serial api

I am using web serial api for reading and writing serial port. I am able to read and write.Now I have a test.bin file in my root folder. I need to directy send it to my serial port .How is this possible?

    <?php
$file = fopen('test.bin', 'r');
$read = fread($file, filesize('test.bin'));
$value =  bin2hex($read);


?>
<input type="text" id="id" value="<?php echo $value; ?>" />


<script>
  var s = document.getElementById("id").value;
  var result = [];

  for (var i = 0; i < s.length; i += 2) {
    result.push(parseInt(s.substring(i, i + 2)));
  }
  result = Uint8Array.from(result);
  document.getElementById('log').innerHTML += result + "<br/>";


  console.log(result);
  button2.addEventListener('click', async () => {

    navigator.serial.requestPort().then(async (port) => {
      const textEncoder = new TextEncoderStream();
      const writableStreamClosed = textEncoder.readable.pipeTo(port.writable);
      const writer = textEncoder.writable.getWriter();



      await writer.write(result);

    })

  })
about 4 years ago · Santiago Trujillo
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!