예제 #1
0
MAP_SIZE_METERS = 32


def _errmsg(message):
    sys.stderr.write(message + '\n')
    sys.exit(1)


class _MyArgumentParser(argparse.ArgumentParser):
    def error(self, message):
        sys.stderr.write('error: %s\n' % message)
        self.print_help()
        sys.exit(1)


_request = msppg.serialize_STATE_Request()


class _MyVisualizer(Visualizer):
    def __init__(self, cmdargs, label):

        zero_angle = float(
            cmdargs.zero_angle) if not cmdargs.zero_angle is None else 0

        Visualizer.__init__(self, MAP_SIZE_PIXELS, MAP_SIZE_METERS, label,
                            True, zero_angle)


class _StateParser(msppg.Parser):
    def __init__(self, readfun, writefun, closefun, visualizer):
예제 #2
0
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 Lesser General Public License 
along with this code.  If not, see <http:#www.gnu.org/licenses/>.
'''

BD_ADDR = '00:06:66:73:E3:E8'
BD_PORT = 1

from msppg import MSP_Parser as Parser, serialize_STATE_Request
import bluetooth
from time import time, sleep

parser = Parser()
request = serialize_STATE_Request()

sock = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
sock.connect((BD_ADDR, BD_PORT))

print('connected to ' + BD_ADDR)


def handler(altitude, variometer, positionX, positionY, heading,
            velocityForward, velocityRightward):

    print(altitude, variometer, positionX, positionY, heading, velocityForward,
          velocityRightward)
    sock.send(request)