removinator.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:smart-card-removinator 作者: nkinder 项目源码 文件源码
def __init__(self, port=None):
        """Opens a connection to a Removinator controller on the specified
        serial port.

        If a port is not specified, an attempt will be made to auto-discover
        the Removinator controller.

        :param port: port that the Removinator is connected to
        :type port: str
        :raises: :exc:`ConnectError`
        :ivar last_result: The result output from the last executed command
        :ivar last_response: The response output from the last executed command
        :ivar port: The port that the Removinator is connected to
        """

        self.port = port
        self.last_result = ''
        self.last_response = ''

        # Attempt to discover the Removinator controller if a
        # port was not specified.
        if port is None:
            port = _discover_removinator()

        # Open a connection to the Removinator controller.
        try:
            self.connection = serial.Serial(
                port,
                9600,
                serial.EIGHTBITS,
                serial.PARITY_NONE,
                serial.STOPBITS_ONE,
                1)
            self.sio = io.TextIOWrapper(io.BufferedRWPair(self.connection,
                                                          self.connection))
        except serial.SerialException as e:
            raise ConnectError('Unable to open connection to Removinator '
                               'controller on port {0}'.format(port))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号