Skip to content

Commit

Permalink
Add PCAN support through python-can
Browse files Browse the repository at this point in the history
  • Loading branch information
PetervdPerk-NXP authored and tridge committed Dec 20, 2022
1 parent bb69e16 commit ed2bdbd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
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

0 comments on commit ed2bdbd

Please sign in to comment.