#WebUSB

2025-05-05
2025-04-11

Это под силу даже веб-разработчику! Размышляю, как создать драйверы на JavaScript с API WebUSB

Привет! Я Игорь Кечайкин, руководитель группы разработки во Frontend-команде Flocktory. Недавно, решая задачу, связанную с API WebUSB для Fingerprint-атрибуции пользователя, задался совершенно не связанным теоретическим вопросом: а как создать с этим API драйверы на JavaScript? Чтобы разобраться, изучил спецификацию API WebUSB, а теперь принёс на Хабр выжимку самых важных элементов. В статье я расскажу о принципах работы решения и том, что с ним делать веб-разработчику, который хочет напрямую реализовать на сайт функцию, например, 3D-принтинга с пользовательских девайсов. А также вы узнаете, насколько это безопасно — для сайта, внедряющего API, и для девайсов юзера. Если интересно, как расширить возможности своих сайтов и избавиться от головной боли с адаптацией под всевозможные устройства, заходите в статью.

habr.com/ru/companies/flocktor

#webusb #браузеры #hardware #javascript #embedded #w3c #drivers #usbif #chromium #мнение

N-gated Hacker Newsngate
2025-03-14

Another day, another 🥪 of wrapped in a desperate attempt to make relevant again. Instead of waiting for , let's just build an entire Rube Goldberg machine to reinvent the wheel! As if GitHub isn't already bursting with enough "ingenious" hacks nobody asked for. 🙄
github.com/ArcaneNibble/i-cant

Hacker Newsh4ckernews
2025-03-14

I-cant-believe-its-not-webusb: Hacking around lack of WebUSB support in Firefox

github.com/ArcaneNibble/i-cant

-cant-believe-its-not-webusb

2024-11-25

I've used #webusb again. It's been a super convenient way of installing #grapheneos : grapheneos.org/install/web
Unfortunately, it works in Chrome only. Ubuntu's snapped Chromium doesn't work. But I could isolate Google through #flatpak .

2024-11-16

I've written a small utility to use my #heatit USB-C gadget rather than using the official app: github.com/muelli/heatit
I also produced a small #WebUSB site! capable-otter-a0e467.netlify.a
Now you can get your treatments without being tracked by their app.

Chordian 🇩🇰🎵chordian
2024-11-08

A new SID handler with WebUSB support for USBSID-Pico has been added to Hermit's emulator by LouD. Note that WebUSB can be quite demanding resource wise. github.com/LouDnl/USBSID-Pico

2024-09-09

After remapping some keys with a locally installed version of #chrysalis (the configuration software) I've realized there is an online version at chrysalis.keyboard.io

#webUSB for the win!

2024-07-22

Dear folks of #JavaScript #async #programming. This #Promise stuff is still voodoo to me. Any simple solution to set a timeout on this byte-receiving loop? I have to collect data from an USB IN endpoint... and let's assume(!) I don't know when I am done (how much data to receive) so that I always have to cancel the last started `transferIn` (#WebUSB) after a timeout (let's say 500 milliseconds). How would you do it? I've trued hacky Promise/timeout stuff, but don't feel comfortable with it.

My JavaScript source code snippet inside an async function:

```
        let rxBuffer = new Uint8Array([]);
        let startTs = Date.now();

        while(success && ((Date.now() - startTs) < 1000)) {
            console.log("Diff: ", (Date.now() - startTs))
            result = await usbDevice.transferIn(usbRxEndpoint, 8);
            success = (result.status == 'ok');

            if(!success) {
                console.log("Failed to transfer in.");
            }
            else {
                console.log("In transfer successful.");
                rxBuffer = concatBuffers(rxBuffer, result.data.buffer);
                console.log("[RXM]", array2hex(result.data.buffer));
                console.log("[RXM_ALL]", array2hex(rxBuffer));
            }
        }
```The browser's console log. You can see that I receive data byte-wise... and after successfully receiving a byte, I poll for another byte. I must abort after a timeout.. as I don't seem to get more data there.

Code hangs after "Diff: 545" and does not return (blocking wait which I want to abort with a timeout).
2024-07-15

Wrote a "high level USB decoder" which sits on top of Saleae's USB LS/FS analyzer so that I can see the really relevant data. Should help getting me the #LEGO #USB Infrared Tower for the #Mindstorms #RCX analyzed better... and maybe provide #WebUSB support on #WebPBrick some day. Sometimes you cannot to see the wood for the trees. (I was surprised recently that this saying could be translated from German to English 1:1.) Planning to open source the tool.

#hardwarehacking #reverseengineering

The tool's intermediate output: a bunch of USB transactions being displayed.

A boring excerpt (won't be fun to read or hear I guess):


===> Transaction: UsbTransaction(Start: 8.55790076, Type: SETUP, Addr.: 11, EP: 0, Success: True, bmRequestType=0b11000000, bRequest=0x02, wValue=[1, 2], wIndex=[0, 0], wLength=[232, 3])
===> Transaction: UsbTransaction(Start: 8.55849542, Type: IN, Addr.: 11, EP: 0, Success: True, Data: [4, 0, 0, 2])
===> Transaction: UsbTransaction(Start: 8.55873182, Type: OUT, Addr.: 11, EP: 0, Success: True, Data: [])
===> Transaction: UsbTransaction(Start: 8.56020846, Type: OUT, Addr.: 11, EP: 2, Success: True, Data: [85, 255, 0, 210, 45, 0, 255, 0])
===> Transaction: UsbTransaction(Start: 8.56820842, Type: OUT, Addr.: 11, EP: 2, Success: True, Data: [255, 210, 45])
===> Transaction: UsbTransaction(Start: 8.5762084, Type: OUT, Addr.: 11, EP: 2, Success: True, Data: [85, 255, 0, 210, 45, 128, 127, 0])
===> Transaction: UsbTransaction(Start: 8.58420836, Type: OUT, Addr.: 11, EP: 2, Success: True, Data: [255, 82, 173])

===> Transaction: UsbTransaction(Start: 12.12311558, Type: SETUP, Addr.: 11, EP: 0, Success: True, bmRequestType=0b11000000, bRequest=0x02, wValue=[1, 2], wIndex=[0, 0], wLength=[232, 3])
Thomas Steiner :chrome:tomayac@toot.cafe
2024-07-03

You can now update your Meta Quest devices 🥽 with #WebUSB: meta.com/help/quest/software_u. After Android with the Android Flash Tool (flash.android.com/), that's another major player who bets on the Web with this #ProjectFugu 🐡 API.

The Quest update website with the site controls open, showing a connected Quest 2 USB device.

Devo ancora aggiungere un po’ di altre funzioni, ma diciamo che questo ennesimo #progetto è comunque già pronto per il pubblico, e allora fuck it: grazie ai poteri del silicio, ho creato #SpiderADB, una collezione di strumentopoli che hanno a che fare con il benedettissimo #AndroidDebugBridge, utilizzabili direttamente dal #browser senza installare un fico secco. 🗽️

Si, ne ho voluto proprio approfittare e ho reso il tema della UI tale e quale a quello di #Android #Holo (Ice Cream Sandwich)… bei tempi. Un po’ grazie all’esistente Holo Web, un po’ con miei aggiustamenti che ho fatto e farò man mano, perché quella libreria è abbastanza incompleta. La #webapp è su https://hub.octt.eu.org/SpiderADB/! 🕸️

Per ora funge solo su Chromium, perché le scimmie che lavorano ad Apple e Mozilla non hanno ancora, dopo credo ben 7 anni, implementato #WebUSB. In realtà Tango, la libreria che ho usato che implementa il porting di ADB, supporterebbe anche la connessione via rete, ma è un casino che richiede comunque #software sull’androide o sul dispositivo host (per via di limitazioni della piattaforma #web), per cui, anche ammesso mi vada di sbattermi, non so quanto possa essere utile. 🍂️

Comunque l’idea di creare questo piripicchio viene dall’altro giorno, in cui dovevo dare dei comandi shell sul tablet (dove non ho il root) ma l’unico altro dispositivo che avevo in quel momento era il telefono, dove a quanto pare il server #ADB in Termux non riesce a rilevare dispositivi via USB… e non potevo nemmeno usare il TCP/IP, perché ero su VPN e non potevo scollegarmi. Alcune #app native ci sono, ma soltanto abbastanza mediocri, tralasciando il fatto che ad installare un #programma per ogni singola evenienza si finisce subito ad accumulare monnezza. 💔️

…Ovviamente se esiste questa libreria che io ho usato, doveva esistere anche una (1) app toolkit demo, simile in effetti alla mia di ora, però… da un lato il terminale che c’è lì è buggato su #mobile, e dall’altro ho pensato quasi quasi di approfittarne per implementare #utility più specifiche che lì non c’erano. Ad esempio, di roba in più nella mia #applicazione c’è già un listino di pacchetti installati… che a breve diventerà anche gestore effettivo, con pure funzioni di debloat, eheh. 👽️

https://octospacc.altervista.org/2024/04/19/adbranio/

#ADB #Android #AndroidDebugBridge #app #applicazione #browser #Holo #mobile #progetto #programma #software #SpiderADB #utility #web #webapp #WebUSB

Blort™ 🐀Ⓥ🥋☣️Blort@social.tchncs.de
2024-03-04

@joao @martijnbraam @justinkd

Well, yeah. I'm a staunch FIrefox user and avoid Chrome / Chromium wherever I can. That said, I'm not going to suggest that Mozilla having not implemented WebUSB yet, means that Mobile Linux users shouldn't have access to a fast, easy way to try recent advancements because they'd need to use Chromium for a few minutes. That seems like "baby with the bathwater" behavior to me. 🤷

#Firefox #Chrome #Chromium #WebUSB #MobileLinux

2024-03-01

Some more experiments with bringing #LEGO #Mindstorms #RCX access into the webbrowser - without the need of some Windows virtual machine or UBS driver hacks. I drafted a browser compatibility test page. And more importantly: I ran first experiments with the Web USB API! And success: 🥳

"Size: 8, error code: 0
LEGO USB Tower firmware version is 1.0 build 134" 🧱 💡
(The numbers really are from the USB device.)

Thankfully, there's a Linux USB driver for inspiration.

#webusb #webusbapi

Firefox: only WebAssembly (WASM) works, neither Web Serial API nor Web USB APIGoogle Chrome: vendor-specific USB control request at the device returns version (major, minor, build number)
Joerg Jaspert :debian:Ganneff@fulda.social
2024-01-27

Of course I had to try #GrapheneOS too. The website reads nice, lots of docs (way more than #CalyxOS who put things on #Matrix. Which is just not for me), lots of information. A #WebUSB installer (if you run a #chromium for it, but please no #flatpak, ...) and not hard to switch too. So after some days CalyxOS i put GrapheneOS on yesterday evening.

Ahwell. I'm already back on Calyx. GrapheneOS is really ... pretty damn low level. It comes with basically nothing, except their own app store, from which you can get the google services/playstore stuff.
Which then directly kept crashing here, whenever I tried using the store to get anything installed.

So grapheneos does want / allow you a much more barebones start, which is nice, but right now just nothing for me. No time. I want it 85% done, and just put the few specials on top, not start near empty. At another time I think I would love that way, but not right now and the near/middle future...
2/x

Thomas Steiner :chrome:tomayac@toot.cafe
2024-01-09

Gave my desk a #NeoPixels makeover based on some leftovers I had (the black holes are from soldering strips together). Really digging the soothing moving gradient. It's powered by an old BBC #microbit that connects to MakeCode over #WebUSB. #ProjectFugu 🐡 FTW!

Standing desk with a NeoPixels strip running around it that displays a rainbow gradient. The screen shows the block code.
Ingvar Stepanyanrreverser
2023-12-10

libusb 1.0.27-rc1 is out - this is the first official release candidate with my + backend, with the official release coming soon!

github.com/libusb/libusb/commi

Kevin Karhan :verified:kkarhan@mstdn.social
2023-10-11

@hanna #Firefox does support #WebUSB.

As one can see with @stacksmashing 's #TetriLink project...

Client Info

Server: https://mastodon.social
Version: 2025.04
Repository: https://github.com/cyevgeniy/lmst