Skip to content

Add _detect_available_configs to serial_can #811

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

Merged
merged 2 commits into from
Apr 29, 2020

Conversation

josko7452
Copy link
Contributor

Hi I am using serial_can interface and I was missing the serial port detection.

This is very simple PR, it just adds pySerial list_ports.comports() call non-intrusive way.
I.e. if the detection fails (or serial.tools.list_ports is not available) for one reason or another it just gives an empty list.
It does not attempt to get more detailed configuration (e.g. baudrates) besides the list of serial ports.

Tested on Linux and Windows:
Linux:

>>> can.detect_available_configs('serial')
[{'interface': 'serial', 'channel': '/dev/ttyUSB0'}]

Window:

>>> can.detect_available_configs('serial')
[{'interface': 'serial', 'channel': 'COM4'}]

As you'd expect. These configs can be directly used to connect to the interface (with the default baudrate of the serial interface).

@josko7452 josko7452 force-pushed the detect-available-configs-serial branch from 77ff3ce to 9d04335 Compare April 17, 2020 09:51
@codecov
Copy link

codecov bot commented Apr 17, 2020

Codecov Report

Merging #811 into develop will increase coverage by 0.14%.
The diff coverage is 84.61%.

@@             Coverage Diff             @@
##           develop     #811      +/-   ##
===========================================
+ Coverage    69.71%   69.85%   +0.14%     
===========================================
  Files           70       70              
  Lines         6577     6578       +1     
===========================================
+ Hits          4585     4595      +10     
+ Misses        1992     1983       -9     

Copy link
Owner

@hardbyte hardbyte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution :-)

Copy link
Collaborator

@felixdivo felixdivo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really cool and simple! Thanks!

@felixdivo
Copy link
Collaborator

I'll just wait until the CI tests pass and merge it afterwards.

@felixdivo felixdivo added this to the 4.0 Release milestone Apr 29, 2020
@felixdivo felixdivo merged commit de0613e into hardbyte:develop Apr 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants