コード例 #1
0
ファイル: pymata3.py プロジェクト: infinityis/pymata-aio
    def __init__(self, arduino_wait=2, sleep_tune=0.0001, log_output=False, com_port=None,
                 ip_address=None, ip_port=2000, ip_handshake='*HELLO*'):
        """
        Constructor for the PyMata3 API
        If log_output is set to True, a log file called 'pymata_log'
        will be created in the current directory and all pymata_aio output
        will be redirected to the log with no output appearing on the console.

        :param arduino_wait: Amount of time to allow Arduino to finish its
                             reset (2 seconds for Uno, Leonardo can be 0)
        :param sleep_tune: This parameter sets the amount of time PyMata core
                           uses to set asyncio.sleep
        :param log_output: If True, pymata_aio.log is created and all
                            console output is redirected to this file.
        :param com_port: If specified, auto port detection will not be
                         performed and this com port will be used.
        :param ip_address: If using a WiFly module, set its address here
        :param ip_port: Port to used with ip_address
        :param ip_handshake: Connectivity handshake string sent by IP device

        :returns: None
        """
        self.log_out = log_output
        self.loop = asyncio.get_event_loop()

        self.sleep_tune = sleep_tune
        self.core = PymataCore(arduino_wait, self.sleep_tune, log_output,
                               com_port, ip_address, ip_port, ip_handshake)
        self.core.start()
        self.sleep(1)