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

Add PCAN support through python-can #25

Merged
merged 1 commit into from
Dec 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions dronecan/driver/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ def make_driver(device_name, **kwargs):
windows_com_port = device_name.replace('\\', '').replace('.', '').lower().startswith('com')
unix_tty = device_name.startswith('/dev/')

if device_name.startswith('PCAN'):
kwargs['bustype'] = 'pcan'

if device_name.startswith("mavcan:"):
if not have_mavcan:
raise DriverError('MAVCAN is not available, ensure pymavlink is installed')
Expand Down
2 changes: 1 addition & 1 deletion dronecan/driver/python_can.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def __init__(self, channel, **_extras):
if channel is None:
self._bus = can.interface.Bus() # get bus from environment's config file
else:
if not hasattr(_extras,'bustype'):
if not 'bustype' in _extras:
_extras['bustype'] = 'socketcan'
self._bus = can.interface.Bus(channel=channel, bustype=_extras['bustype'], bitrate=_extras['bitrate'])
except Exception as ex:
Expand Down