Exemple #1
0
    def __init__(self, *subscriber_list, **kwargs):
        """

        :param subscriber_list: a tuple or list of topics to be subscribed to
        :param kwargs: contains the following parameters:

            back_plane_ip_address: banyan_base back_planeIP Address -
               if not specified, it will be set to the local computer
            subscriber_port: banyan_base back plane subscriber port.
               This must match that of the banyan_base backplane
            publisher_port: banyan_base back plane publisher port.
                               This must match that of the banyan_base
                               backplane
            process_name: Component identifier
            board_type: target micro-controller type ID

        """
        # initialize the parent
        super(RoboHatGateway, self).__init__(
            subscriber_list=subscriber_list,
            back_plane_ip_address=kwargs['back_plane_ip_address'],
            subscriber_port=kwargs['subscriber_port'],
            publisher_port=kwargs['publisher_port'],
            process_name=kwargs['process_name'],
            board_type=kwargs['board_type'])

        # instantiate pymata_rh
        self.robohat = pymata_rh.PymataRh(kwargs['com_port'],
                                          kwargs['arduino_instance_id'])
        # start the banyan receive loop
        try:
            self.receive_loop()
        except KeyboardInterrupt:
            self.clean_up()
            sys.exit(0)
"""
 Copyright (c) 2020 Alan Yorinks All rights reserved.

 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
 Version 3 as published by the Free Software Foundation; either
 or (at your option) any later version.
 This library is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 General Public License for more details.

 You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
 along with this library; if not, write to the Free Software
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
"""

import sys

from pymata_rh import pymata_rh
"""
Run a calibration cycle of the mpu9250
"""

board = pymata_rh.PymataRh()
try:
    board.mpu_9250_calibrate()
except KeyboardInterrupt:
    board.shutdown()
    sys.exit(0)