Skip to content

Automatically find Arduino tty from /dev/serial/ #41

Description

@elcojacobs

The Arduino serial port can be found as a symlink in
/dev/serial/by-id/

We could look for a symlink with arduino in the name in that dir intead of just trying ttyACM0 and ttyACM1

Activity

  1. elcojacobs commented on Mar 25, 2015

    @elcojacobs
    MemberAuthor

    A possible easy way to do this in python is to use serial.tools.list_ports:
    It can be invoked from command line:

    python -m serial.tools.list_ports -v
    

    Giving for the Arduino Leo:

    pi@brewpi ~ $ python -m serial.tools.list_ports -v
    

    /dev/ttyACM0
    desc: ttyACM0
    hwid: USB VID:PID=2341:8036
    1 ports found

    And for the Spark Core:

    pi@raspberrypi ~ $ python -m serial.tools.list_ports -v
    /dev/ttyACM0
        desc: ttyACM0
        hwid: USB VID:PID=1d50:607d SNR=6D7517794852
    1 ports found
    

    We can distinguish between devices from their VID:PID

    The list_ports module is intended to be used from the command line, but can be used from a python script by including the platform specific version:

    https://github.com/elcojacobs/brewpi-script/blob/feature/dfu-flash-tool/utils/flash-dfu.py#L30

  2. m-mcgowan commented on Mar 25, 2015

    @m-mcgowan
    Contributor

    I have added automatic detection to the brewpi connector, it has all the various IDs registered - tried and tested code so that would be a good start.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions