Skip to content
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

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

Open
elcojacobs opened this issue Jul 12, 2014 · 2 comments
Open

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

elcojacobs opened this issue Jul 12, 2014 · 2 comments

Comments

@elcojacobs
Copy link
Member

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

@elcojacobs
Copy link
Member Author

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

@m-mcgowan
Copy link
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants