Skip to content

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

Closed
@PaulStoffregen

Description

@PaulStoffregen

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": {}
    }
  ]
}

Activity

added
topic: codeRelated to content of the project itself
type: imperfectionPerceived defect in any part of project
on Feb 3, 2022
cmaglie

cmaglie commented on Feb 18, 2022

@cmaglie
Member

@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

PaulStoffregen commented on Feb 18, 2022

@PaulStoffregen
SponsorAuthor

Yes, confirmed.

image

cmaglie

cmaglie commented on Feb 24, 2022

@cmaglie
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @cmaglie@PaulStoffregen@per1234

      Issue actions

        Linux discovery finds placeholder /dev/ttyS* devices · Issue #37 · arduino/serial-discovery