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

0

110
Views
How to send a file with web serial api

I am currently building a web application that allows users to type text and send an image that would be send to a laser engraver through a serial port. Now I'm stuck with a problem which is I can send a gcode string to the laser engraver but I can't send a file, so how would I send a file with Web Serial API.

let imageShow = canvas.toDataURL();
const regex = /data:.*base64,/;
console.log(imageShow.replace(regex, ""));
imageShow.replace(regex, "");       
function b64_to_utf8(str) {
     return decodeURIComponent(escape(window.atob(str)));
}
image = b64_to_utf8(imageShow);
const encoder = new TextEncoder();
const writer = port.writable.getWriter();
await writer.write(encoder.encode(image));
writer.releaseLock();
about 3 years ago · Santiago Gelvez
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