WebUSB | WebUSB enabled LOL shield | Runtime Evironment library
kandi X-RAY | WebUSB Summary
kandi X-RAY | WebUSB Summary
WebUSB enabled LOL shield.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of WebUSB
WebUSB Key Features
WebUSB Examples and Code Snippets
Community Discussions
Trending Discussions on WebUSB
QUESTION
I'm trying to make a non-component class in ReactJS. Most tutorials I've followed on JavaScript show that when you're making a class, you can create properties simply by specifying them with this.[name]
.
Something really doesn't like this, and it throws me a no-undef
error for my properties.
Here is the code in question:
...ANSWER
Answered 2021-Apr-27 at 11:36In your connectDAP
method you are referencing undefined variables device
and transport
. You probably want to use the properties defined on the instance this
:
QUESTION
I have a PWA using Web Serial on those devices where it is supported (Chromium based Desktop Browsers), on all other devices (basically Android) I try to fall back to Web USB via web serial polyfill.
This is working great for most devices, but on some (at leas one) Android devices I can not claim the device:
...ANSWER
Answered 2021-Mar-25 at 23:39I believe this is a duplicate of that issue and automatically detaching drivers on Android (tracked by Chromium issue 1099521) will resolve the problem.
QUESTION
I have LibNFC working from the Linux terminal recognising my ACR122U Reader, and I wanted to know if there was a method for it to work through Chrome on a Linux Desktop as it is really similar to Android Support, with all the NFC device handling done by libnfc and the browser just has to know about this library instead of every type usb or other device than can do NFC.
I have tried using the WebNFC API to connect it :
...ANSWER
Answered 2021-Feb-10 at 06:54Web NFC is supported on Android only as of February 2021. See https://web.dev/nfc/
The WebUSB error suggests you're requesting an interface that implements a protected class (among those below):
QUESTION
I am trying to use WebUSB to read GPS coordinates from a USB-connected GPS receiver from within javascript.
I have been able to connect to the receiver; however, I am unsure how to use WebUSB to access the NMEA messages.
So far, I have the following proof-of-concept code:
...ANSWER
Answered 2021-Jan-29 at 02:03There are a couple of layers you'll need to understand in order to accomplish your goal. The first is the USB interface implemented by the device.
In the example code you've posted there are two calls which send commands to the device. The first is a controlTransferOut() which sends the standard USB CDC-ACM SET_CONTROL_LINE_STATE request (0x22) to the device to enable the DTR signal (0x01). If your device implements the USB CDC-ACM protocol then this is the write thing to do as it signals to the device that the host software is ready to receive data. If your device doesn't implement this protocol then the command will be ignored or fail. You're already claiming the first interface, to understand USB protocol that interface implements you should check device.configuration.interfaces[0].alternates[0].interfaceClass
and device.configuration.interfaces[1].alternates[0].interfaceClass
. A USB CDC-ACM device will have one interface with class 2 and one with class 10. Class 2 is for the control interface while class 10 is the data interface. If your device doesn't have these two interfaces then it probably isn't implementing the USB CDC-ACM protocol and you'll have to figure out what protocol it uses first.
The second call you make is a controlTransferIn() which sends the standard USB GET_DESCRIPTOR request (0x06) to read a string descriptor from the device. Passing 0x0302 asks it to read the string descriptor (type 3) at index 2. This will work for any USB device (assuming the index is right) and so doesn't tell you whether you've figured out what protocol the interface supports.
Assuming this is a USB CDC-ACM interface then you'll want to look at device.configuration.interfaces[1].alternates[0].endpoints
and figure out the endpoint numbers for the IN and OUT endpoints. These are what you'll pass to transferIn()
and transferOut()
to send and receive data from the device.
Once you have all that figured out you'll need to figure out how to get the device to start sending NMEA messages. If you are lucky then in its default mode it will automatically send them and you can just start calling transferIn()
to receive them. Otherwise you will have to figure out what command to send to the device to put it in a the right mode. If you have and documentation for the device or example code written in other languages that supports this device then that will be very helpful for figuring this out.
QUESTION
I have implemented the web USB API for the USB-to-TTL chip CH340. It works pretty good on the PC but when I connect my phone to the chip (using direct cable and/or OTG cable) the API will disconnect after a minute or two. This doesn't happen if I use a Serial Terminal App on the same phone. Same will happen on multiple Chromium based browsers.
And as soon as I physically disconnect the chip from the phone it will freeze and restart the phone.
Here's my beta test site: https://grovkillen.com/webusb/
...ANSWER
Answered 2021-Jan-26 at 00:44This behavior shouldn't happen (especially the freezing and crashing part) and is likely a Chromium or Android bug. Please open an issue on crbug.com and include any crash IDs from chrome://crashes in the report. Reply here with the bug link so I'm sure to see it.
QUESTION
WebUSB API documentation introduces new powerful feature with name "usb" to permissions infrastructure (https://wicg.github.io/webusb/#permission-api). But when I try to use permissions api to query permissions for "usb":
...ANSWER
Answered 2020-Dec-17 at 02:05
- Does permissions api support "usb" feature? If yes, what I do wrong in upper code?
No. While the Permissions API integration defined in the specification is implemented in Chromium-based browsers it is not exposed through the Permissions API's query()
method. This is tracked by issue 638721 but has not been a priority given the available alternatives.
- If permissions api not yet support "usb" feature, where/how allowed devices are stored in browser? Can I programmatically get access to this storage?
Permissions are stored in the browser's user preferences file and internal data structures which are not directly accessible to Javascript. The only way these permissions are currently exposed are through the settings UI (chrome://settings/content/usbDevices) and the navigator.usb.getDevices()
method, which only returns allowed devices if they are currently connected.
- Can website request user to allow permissions to group of devices (in my case by vid+pid) which not only connected right now, but also can be connected in future? In other words, I want to ask user "Please, let me work with usb devices (with this vid+pid) which you connect in a future, because I don't want to bore you with permission question every time you connect new device of particular type".
No. It is important to the security design of the API that the user make the decision based on the devices currently connected rather than a hypothetical future device.
For enterprise managed devices the WebUsbAllowDevicesForUrls policy allows an administrator to make this type of decision on behalf of their users.
QUESTION
I am interesting in building a web application to read and write inforomation of a mobile phone using webusb or adb shell or node js to open port and communicate device with at command or adb command
but I am struggle which the propre and secure way and i have problems of permissions
Webusb works fine but I can't integert at command or adb shell ?
...ANSWER
Answered 2020-Jun-16 at 00:25The webadb.js library provides an implementation of the ADB protocol in Javascript using WebUSB to communicate with a local device. This assumes that the device is local to the computer running the web browser.
If you want to control the device from the server you will need to provide a way for the server to command the browser to forward commands to the device. This could be done, for example, using a Web Socket.
If you want to use the browser to control a device connected to the server however a different approach is needed. In that case you would use a library like adbkit to connect to the device directly from Node.
QUESTION
UPDATED CODE
I'm using this code to claim the use of the serial-2-USB device. It shows up and I can query the info about it, ie. "connected to USB2.0-Serial VID: 6790 PID: 29987" (CH34x from Qinheng). To be clear, I use the winUSB driver (downloaded with zadig-2.5.exe, Windows 10) and have uninstalled the original drivers.
I get the received data as dataview but when I do the decode it comes out gibberish. And I see that the array length pretty much corresponds to what I know my ESP8266 is posting over the serial port.
Example of decoded data: �(#���D"D�T�b�!A#7mP�R�N����#�m93aw9 ½�d-K��b��BF+3ѡ��kag1�R�#��#!!r����g�!d��a��谛oa��399�}��1D�#��'99�����9�����'99���'99����@@譛
I get the data as Uint8Arrays but even if I try to make my own parser the same gibberish is the end result. Do I need to care about USB stuff as in start bits, ack bits etc. etc.? All the example code out there just do a text decoder and that's it.
serial.js + index.html
...ANSWER
Answered 2020-Nov-20 at 18:04This isn't a flaw in WebUSB but with the script you are running. The serial.js script included in the Arduino examples repository is designed to work with Arduino devices where setting the baud rate in unnecessary because the port is virtual. In order to set the baud rate on a USB to serial adapter you need to send the SET_LINE_CODING control transfer. This should go before the SET_CONTROL_LINE_STATE command in your existing code. There is documentation for the structure of the control transfer here:
QUESTION
WebUSB has very limited coverage, but that's okay for this project.
The navigator.usb.requestDevice
method succeeds:
ANSWER
Answered 2020-Oct-31 at 21:56Because USB–and even more so WebUSB–seems to be more fragile than the http connections I'm used, parallel to playing with the Javascript interface, I also worked at pulling in the data with PyUSB. The goal is to write data from the device to a CSV file so either could work.
In this related post I outline some additional steps in the process including:
- rebooting the machine
- with the device connected
- a good USB cable
- checking
chrome://device-log
at DEBUG level - using a demo of the Serial App
- checking status with
kexstat
, "unclaiming" withkextunload
- looking at kernel log with
dmesg
I would love to accept a more robust "answer" than this, but I am finally seeing some data:
QUESTION
I have a device that I would like to access through WebUsb, the driver is source-closed, so Is there a way I can create my own driver to wrap the official driver ?, just to give the device visibility from chrome and WebUsb ?
Update:
After the answer that really helped me a lot I can say the following:
If you don't have access to the firmware of the USB and cannot modify it so its compatible with WebUsb, the next approach is to learn how the device works at low level, you dont need to know the full USB Protocol, but at least know how to send and receive commands, and in WINDOWS is a must, that the driver for your usb device be WinUsb.sys
You dont need to create a full new driver, only know how the comunication between the device and the computer works, and rewrite that in javascript.
...ANSWER
Answered 2020-Oct-06 at 19:54WebUSB is designed to provide low-level access to USB devices, at the level of individual USB transfers. If the device has an existing driver then that should be taking care of the transfers and presenting a higher-level interface to applications on your system. Trying to wrap that in something which presented the low-level interface again would be counterproductive.
Without more information about the device in question and its driver I can't give more precise advice.
One option, which would be a lot of work but could be more broadly applicable would be writing a wrapper around the existing driver that would allow it to use WebUSB to connect to the device. There has been work, for example, it port user-space drivers using libusb to the web by providing a port of libusb that uses WebUSB internally. This works much more easily for open-source drivers because you can recompile them to use the wrapper. If this is a closed-source native Windows driver, for example, running that inside of an emulator on the web would be an enormous undertaking.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install WebUSB
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page