Code Monkey home page Code Monkey logo

Comments (6)

A-J-Bauer avatar A-J-Bauer commented on May 22, 2024

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.

liu-minjie avatar liu-minjie commented on May 22, 2024

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.

reillyeon avatar reillyeon commented on May 22, 2024

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.

A-J-Bauer avatar A-J-Bauer commented on May 22, 2024

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.

reillyeon avatar reillyeon commented on May 22, 2024

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.

A-J-Bauer avatar A-J-Bauer commented on May 22, 2024

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.

wch ch3400

from web-serial-polyfill.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.