Skip to content

Linux discovery finds placeholder /dev/ttyS* devices #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
PaulStoffregen opened this issue Feb 3, 2022 · 3 comments
Closed

Linux discovery finds placeholder /dev/ttyS* devices #37

PaulStoffregen opened this issue Feb 3, 2022 · 3 comments
Assignees
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project

Comments

@PaulStoffregen
Copy link

When run on Ubuntu 20.04, serial-discovery is finding the /dev/ttyS* placeholder ports.

Looks like the go-serial library is supposed to check for this, but it seems to not be working.
https://github.com/bugst/go-serial/blob/f344e5f764a882b93ba5e38988551cbb2186e948/serial_unix.go#L285

./serial-discovery 
LIST
{
  "eventType": "command_error",
  "message": "First command must be HELLO, but got 'LIST'",
  "error": true
}
HELLO 1 "manual run"
{
  "eventType": "hello",
  "message": "OK",
  "protocolVersion": 1
}
START
{
  "eventType": "start",
  "message": "OK"
}
LIST
{
  "eventType": "list",
  "ports": [
    {
      "address": "/dev/ttyS8",
      "label": "/dev/ttyS8",
      "protocol": "serial",
      "protocolLabel": "Serial Port",
      "properties": {}
    },
    {
      "address": "/dev/ttyS9",
      "label": "/dev/ttyS9",
      "protocol": "serial",
      "protocolLabel": "Serial Port",
      "properties": {}
    },
    {
      "address": "/dev/ttyS0",
      "label": "/dev/ttyS0",
      "protocol": "serial",
      "protocolLabel": "Serial Port",
      "properties": {}
    },
    {
      "address": "/dev/ttyS2",
      "label": "/dev/ttyS2",
      "protocol": "serial",
      "protocolLabel": "Serial Port",
      "properties": {}
    },
    {
      "address": "/dev/ttyS3",
      "label": "/dev/ttyS3",
      "protocol": "serial",
      "protocolLabel": "Serial Port",
      "properties": {}
    },
    {
      "address": "/dev/ttyS7",
      "label": "/dev/ttyS7",
      "protocol": "serial",
      "protocolLabel": "Serial Port",
      "properties": {}
    },
    {
      "address": "/dev/ttyS6",
      "label": "/dev/ttyS6",
      "protocol": "serial",
      "protocolLabel": "Serial Port",
      "properties": {}
    },
    {
      "address": "/dev/ttyACM0",
      "label": "/dev/ttyACM0",
      "protocol": "serial",
      "protocolLabel": "Serial Port (USB)",
      "properties": {
        "pid": "0x0483",
        "serialNumber": "5393790",
        "vid": "0x16c0"
      }
    },
    {
      "address": "/dev/ttyS1",
      "label": "/dev/ttyS1",
      "protocol": "serial",
      "protocolLabel": "Serial Port",
      "properties": {}
    },
    {
      "address": "/dev/ttyS4",
      "label": "/dev/ttyS4",
      "protocol": "serial",
      "protocolLabel": "Serial Port",
      "properties": {}
    },
    {
      "address": "/dev/ttyS5",
      "label": "/dev/ttyS5",
      "protocol": "serial",
      "protocolLabel": "Serial Port",
      "properties": {}
    }
  ]
}
@per1234 per1234 added topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project labels Feb 3, 2022
@cmaglie
Copy link
Member

cmaglie commented Feb 18, 2022

@PaulStoffregen are the ttySxx accessible from your user?
From some tests on my local machine I see that if the port is not accessible the enumerator will (wrongly) list it:

$ cat /dev/ttyS0 
cat: /dev/ttyS0: Permission denied
$ go run portlist/portlist.go 
Port: /dev/ttyACM0
   USB ID      : 2341:0057
   USB serial  : 
Port: /dev/ttyS0
Port: /dev/ttyS1
Port: /dev/ttyS10
Port: /dev/ttyS11
Port: /dev/ttyS12
Port: /dev/ttyS13
Port: /dev/ttyS14
Port: /dev/ttyS15
Port: /dev/ttyS16
Port: /dev/ttyS17
Port: /dev/ttyS18
Port: /dev/ttyS19
Port: /dev/ttyS2
Port: /dev/ttyS20
Port: /dev/ttyS21
Port: /dev/ttyS22
Port: /dev/ttyS23
Port: /dev/ttyS24
Port: /dev/ttyS25
Port: /dev/ttyS26
Port: /dev/ttyS27
Port: /dev/ttyS28
Port: /dev/ttyS29
Port: /dev/ttyS3
Port: /dev/ttyS30
Port: /dev/ttyS31
Port: /dev/ttyS4
Port: /dev/ttyS5
Port: /dev/ttyS6
Port: /dev/ttyS7
Port: /dev/ttyS8
Port: /dev/ttyS9

but if I give the correct permissions to the user everything is fine again:

$ cat /dev/ttyACM0 
^C
$ go run portlist/portlist.go 
Port: /dev/ttyACM0
   USB ID      : 2341:0057
   USB serial  : 

can you check if this is your case?
I've prepared a fix here bugst/go-serial#135

@PaulStoffregen
Copy link
Author

PaulStoffregen commented Feb 18, 2022

Yes, confirmed.

image

@cmaglie
Copy link
Member

cmaglie commented Feb 24, 2022

This has been fixed with #38, and is already in production.

I'm working on another fix in the go-serial library, that allows checking if a serial port is fake or not without opening it (following your suggestion on libudev here) but it's mid-term because it requires a more involved change in the go-serial library.

@cmaglie cmaglie closed this as completed Feb 24, 2022
@per1234 per1234 added the conclusion: resolved Issue was resolved label Feb 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

No branches or pull requests

3 participants