Comments (6)
Had the same problem with a CH340 on an arduino connecting from Android.
You could try:
const deviceFilter = { usbVendorId: 6790, usbProductId: 29987 }; // 1659, 8963 for prolific
const interfaces = { usbControlInterfaceClass: 255, usbTransferInterfaceClass: 255 };
if ("usb" in navigator) {
try {
device = await serial.requestPort({ filters: [deviceFilter] }, interfaces);
} catch (e) {
if (device.opened) {
await device.close();
}
}
}
from web-serial-polyfill.
Had the same problem with a CH340 on an arduino connecting from Android.
You could try:
const deviceFilter = { usbVendorId: 6790, usbProductId: 29987 }; // 1659, 8963 for prolific const interfaces = { usbControlInterfaceClass: 255, usbTransferInterfaceClass: 255 }; if ("usb" in navigator) { try { device = await serial.requestPort({ filters: [deviceFilter] }, interfaces); } catch (e) { if (device.opened) { await device.close(); } } }
now another issuse:
A is with pollyfill code
B is with chrome native serial
when A send data to B. it's ok, B will receive data correctly
but B send data to A, A will not receive any data.
after close port of A, the code reader.read().then((data) => {})
will receive {done: true, value: undefined }
from web-serial-polyfill.
This library only currently understands how to control a USB serial device that uses the standard USB CDC-ACM protocol, which is why it is looking for an interface with class 2. From my research many USB serial devices that use other non-standard protocols are still similar enough to this protocol that the library should work with only minor modifications.
We will use this issue to track implementing support for such chips from Prolific Technologies.
from web-serial-polyfill.
For my purposes I simply changed the SerialPort constructor code to look for interface types instead of interface class numbers:
this.controlInterface_ = this.device_.configuration.interfaces.find(x => x.alternates.find(y => y.endpoints.find(z => z.type === 'interrupt'))); // findInterface(this.device_, this.polyfillOptions_.usbControlInterfaceClass);
this.transferInterface_ = this.device_.configuration.interfaces.find(x => x.alternates.find(y => y.endpoints.find(z => z.type === 'bulk'))); // findInterface(this.device_, this.polyfillOptions_.usbTransferInterfaceClass);
Now it works the same as navigator.serial on desktop (serial.js and demo here: https://github.com/A-J-Bauer/asa)
from web-serial-polyfill.
That's interesting. It looks like Prolific chips use protocol that is similar enough to the standard USB CDC-ACM protocol that it works for the subset of functionality currently used by this library.
In particular it uses control transfers that appear identical to the standard SET_LINE_CODING and SET_CONTROL_LINE_STATE commands.
from web-serial-polyfill.
I think it does, the device Info posted by liu-minjie looks similar (endpoints not unfolded) to that returned for the WCH CH340 chip (http://www.wch-ic.com/products/CH340.html) that is used for Arduino Nano clones and those are working with the modification mentioned above.
from web-serial-polyfill.
Related Issues (20)
- Adding and removing event listeners HOT 1
- No compiled file published to npm in 1.0.7 HOT 8
- Unable to find interface with class 2
- add optional parameter signalOptions to open HOT 2
- Implement support for CDC composite gadget HOT 3
- Nothing happens after clicking RequestInfo HOT 2
- serial api(polyfill) show "access Denied" in windows and android chrome. HOT 5
- web-serial-polyfill and web-serial desktop and Android HOT 4
- Feature Request: Seamless Javascript integration between web-serial-polyfill and webSerial HOT 1
- Create a readable byte stream
- TypeError: serial.SerialPort is not a constructor
- Android: usb.getDevices() succeeds but serial.getDevices() fails HOT 3
- WebSerial update? HOT 5
- Static web serial Polyfill NPM example please. HOT 8
- Feature request: Design a webpage that informs if webSerial or polyfill works on the device. HOT 2
- Which phones support Android Polyfill? HOT 14
- Add support for bluetooth serial devices HOT 4
- Vanilla javascript example HOT 16
- NetworkError: Failed to execute 'transferIn' on 'USBDevice': A transfer error has occurred. HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from web-serial-polyfill.