sg-wireless / pymakr-vsc

GNU General Public License v3.0
97 stars 25 forks source link

List serial ports #190

Closed jprodriguez-nbs closed 2 years ago

jprodriguez-nbs commented 2 years ago

Feature Request 🚀

List manufacturers when listing serial ports

Any serial port from a manufacturer that is not listed in autoconnect_comport_manufacturers is silently discarded There are manufacturers (like 'QinHeng Electronics' on some TTGO boards) that do not return an identifiable manufacturer (eg: '1a86'). The user experience is that the pymakr returns always 'Found 0 serialports'

Describe the solution you'd like

SerialPort.list method used in pyserial.js does return the information about the different serial ports available and has the manufacturer information ready. The line var pycom_manu_index = comport_manufacturers.indexOf(manu); compares the found serial port manufacturer with the configured autoconnect_comport_manufacturers The solution proposed is to print all found serial ports, both the ones from a manufacturer included in the list and the ones from a different manufacturer, indicating if the manufacturer does match or not. I would also include a final sentence explaining the user that he can add the missing manufacturers in the pymakr.json autoconnect_comport_manufacturers list if he wants to use that serial port.

Describe alternatives you've considered

As an alternative, I have manuall listed the ports using nodejs to find the manufacturer, with the following code:

const bindings = require('@serialport/bindings')

var listOfPorts=[];

//called automatically by bindings.list()
function list(ports) {
  listOfPorts=ports;
  // now listOfPorts will be the port Objects
  console.log(listOfPorts);
}

bindings.list().then(list, err => {
  process.exit(1)
})

If you put this code in test.js, then:

You get something like:

[
  {
    manufacturer: '1a86',
    serialNumber: '5185015613',
    pnpId: 'usb-1a86_USB_Single_Serial_5185015613-if00',
    locationId: undefined,
    vendorId: '1a86',
    productId: '55d4',
    path: '/dev/ttyACM0'
  },

Then you can put '1a86' in the autoconnect_comport_manufacturers list and connect to the board.

jakobrosenberg commented 2 years ago

@jprodriguez-nbs thanks for the feedback. I'm not sure why USB connections are limited to predefined manufacturers.

Most of all, I'd like to remove the restriction, but I don't know if that could present any side effects.

For now I can add 1a86 to the preapproved devices. You can also submit a PR if you would like.

Josverl commented 2 years ago

I agree that having a way to open up to more devices would be great. Whenever I move to a new PC I always need to remember how to get everything to work :-( I think that autoconnect could be bad if pymakr starts connection to just any serial device, So to allow some control over it it would make more sense to add a wildcard as the default.

That way it would be explicit , and if it causes issues for someone they could just remove that wildcard.

    "autoconnect_comport_manufacturers": [
        "Pycom*",
        "FTDI",
        "Microsoft",
        "Microchip Technology, Inc.",
        "Silicon Labs",
        "*"
    ]

I personally would prefer a simple wildcard (above) , but regex (below) would also be fine.

    "autoconnect_comport_manufacturers": [
        "Pycom.*",
        "FTDI",
        "Microsoft",
        "Microchip Technology, Inc.",
        "Silicon Labs",
        ".*"
    ]
jprodriguez-nbs commented 2 years ago

Hello, I think that the reason to add the filter is to filter out all the other tty devices returned by the library that are really not used (e.g. ttySxx). This is the reason why I suggested to provide a hint to the user about what serial devices might be used but are currently filtered out. BR

El lun, 10 ene 2022 a las 0:03, Jos Verlinde @.***>) escribió:

I agree that having a way to add other I think that autoconnect could be bad if pymakr starts connection to just any serial device. to allow some control over it it would make more sense to add a wildcard by default. that way it would be explicit , and if it causes issues for someone they could just remove that wildcard.

"autoconnect_comport_manufacturers": [ "Pycom", "FTDI", "Microsoft", "Microchip Technology, Inc.", "Silicon Labs", "" ]

I personally would prefer a simple wildcard (above) , but regex (below) would also be fine.

"autoconnect_comport_manufacturers": [ "Pycom.", "FTDI", "Microsoft", "Microchip Technology, Inc.", "Silicon Labs", "." ]

— Reply to this email directly, view it on GitHub https://github.com/pycom/pymakr-vsc/issues/190#issuecomment-1008441391, or unsubscribe https://github.com/notifications/unsubscribe-auth/AO3HNQYGJDRN2R7EHBBHO5TUVIH5DANCNFSM5LFXV76A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

--

jakobrosenberg commented 2 years ago

@Josverl I'm currently working on moving the configuration into VSCode settings. This should make it easier to get started without having to remember where everything is.

@jprodriguez-nbs I added your device to the predefined devices, so it should work now without any configuration.

jprodriguez-nbs commented 2 years ago

Hello,

The board that I am using is a TTGO T-CALL PMU manufactured in 2021 (the serial port to USB device has changed since previous version)

Just for any person that has the same problem, the manufacturer for this USB serial port device in Windows has a different name: "wch.cn", so in order to connect to the device in Windows you have to add "wch.cn" to the autoconnect_comport_manufacturers list

To open the configuration file that has this list use:

Example:

    "autoconnect_comport_manufacturers": [
        "Pycom",
        "Pycom Ltd.",
        "FTDI",
        "Microsoft",
        "Microchip Technology, Inc.",
        "Silicon Labs",
        "1a86",
        "wch.cn"
    ]
jakobrosenberg commented 2 years ago

Closing this for now, but can be reopened if needed.