当前位置: 首页>>代码示例>>Python>>正文


Python can.BusABC方法代码示例

本文整理汇总了Python中can.BusABC方法的典型用法代码示例。如果您正苦于以下问题:Python can.BusABC方法的具体用法?Python can.BusABC怎么用?Python can.BusABC使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在can的用法示例。


在下文中一共展示了can.BusABC方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: connect

# 需要导入模块: import can [as 别名]
# 或者: from can import BusABC [as 别名]
def connect(self, *args, **kwargs):
        """Connect to CAN bus using python-can.

        Arguments are passed directly to :class:`can.BusABC`. Typically these
        may include:

        :param channel:
            Backend specific channel for the CAN interface.
        :param str bustype:
            Name of the interface. See
            `python-can manual <https://python-can.readthedocs.io/en/latest/configuration.html#interface-names>`__
            for full list of supported interfaces.
        :param int bitrate:
            Bitrate in bit/s.

        :raises can.CanError:
            When connection fails.
        """
        self._bus = can.interface.Bus(*args, **kwargs)
        logger.info("Connected to '%s'", self._bus.channel_info)
        self._notifier = can.Notifier(self._bus, self._listeners, 1) 
开发者ID:benkfra,项目名称:j1939,代码行数:23,代码来源:electronic_control_unit.py

示例2: __init__

# 需要导入模块: import can [as 别名]
# 或者: from can import BusABC [as 别名]
def __init__(self, bus=None):
        """
        :param can.BusABC bus:
            A python-can bus instance to re-use.
        """
        #: A python-can :class:`can.BusABC` instance which is set after
        #: :meth:`canopen.Network.connect` is called
        self.bus = bus
        #: A :class:`~canopen.network.NodeScanner` for detecting nodes
        self.scanner = NodeScanner(self)
        #: List of :class:`can.Listener` objects.
        #: Includes at least MessageListener.
        self.listeners = [MessageListener(self)]
        self.notifier = None
        self.nodes = {}
        self.subscribers = {}
        self.send_lock = threading.Lock()
        self.sync = SyncProducer(self)
        self.time = TimeProducer(self)
        self.nmt = NmtMaster(0)
        self.nmt.network = self

        self.lss = LssMaster()
        self.lss.network = self
        self.subscribe(self.lss.LSS_RX_COBID, self.lss.on_message_received) 
开发者ID:christiansandberg,项目名称:canopen,代码行数:27,代码来源:network.py

示例3: set_bus

# 需要导入模块: import can [as 别名]
# 或者: from can import BusABC [as 别名]
def set_bus(self, bus):
        if not isinstance(bus, can.BusABC):
            raise ValueError('bus must be a python-can BusABC object')
        self.bus=bus 
开发者ID:pylessard,项目名称:python-can-isotp,代码行数:6,代码来源:protocol.py

示例4: __init__

# 需要导入模块: import can [as 别名]
# 或者: from can import BusABC [as 别名]
def __init__(self, bus=None):
        """
        :param can.BusABC bus:
            A python-can bus instance to re-use.
        """
        #: A python-can :class:`can.BusABC` instance
        self._bus = bus
        # Locking object for send 
        self._send_lock = threading.Lock()

        #: Includes at least MessageListener.
        self._listeners = [MessageListener(self)]
        self._notifier = None
        self._subscribers = []
        # List of ControllerApplication
        self._cas = []
        # Receive buffers
        self._rcv_buffer = {}
        # Send buffers
        self._snd_buffer = {}
        # List of timer events the job thread should care of
        self._timer_events = []

        self._job_thread_end = threading.Event()
        logger.info("Starting ECU async thread")
        self._job_thread_wakeup_queue = queue.Queue()
        self._job_thread = threading.Thread(target=self._async_job_thread, name='j1939.ecu job_thread')
        # A thread can be flagged as a "daemon thread". The significance of 
        # this flag is that the entire Python program exits when only daemon 
        # threads are left.
        self._job_thread.daemon = True
        self._job_thread.start()
        # TODO: do we have to stop the tread somehow? 
开发者ID:benkfra,项目名称:j1939,代码行数:35,代码来源:electronic_control_unit.py

示例5: connect

# 需要导入模块: import can [as 别名]
# 或者: from can import BusABC [as 别名]
def connect(self, *args, **kwargs):
        """Connect to CAN bus using python-can.

        Arguments are passed directly to :class:`can.BusABC`. Typically these
        may include:

        :param channel:
            Backend specific channel for the CAN interface.
        :param str bustype:
            Name of the interface. See
            `python-can manual <https://python-can.readthedocs.io/en/latest/configuration.html#interface-names>`__
            for full list of supported interfaces.
        :param int bitrate:
            Bitrate in bit/s.

        :raises can.CanError:
            When connection fails.
        """
        # If bitrate has not been specified, try to find one node where bitrate
        # has been specified
        if "bitrate" not in kwargs:
            for node in self.nodes.values():
                if node.object_dictionary.bitrate:
                    kwargs["bitrate"] = node.object_dictionary.bitrate
                    break
        self.bus = can.interface.Bus(*args, **kwargs)
        logger.info("Connected to '%s'", self.bus.channel_info)
        self.notifier = can.Notifier(self.bus, self.listeners, 1)
        return self 
开发者ID:christiansandberg,项目名称:canopen,代码行数:31,代码来源:network.py

示例6: __init__

# 需要导入模块: import can [as 别名]
# 或者: from can import BusABC [as 别名]
def __init__(self, iface):
        if not isinstance(iface, can.BusABC):
            raise TypeError('canbus interface not compatible')
        self._iface = iface 
开发者ID:marcinbor85,项目名称:can-prog,代码行数:6,代码来源:abstract.py


注:本文中的can.BusABC方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。