コード例 #1
0
    def test_run(self):
        # Make calls to it
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        server_address = ('localhost', PORT)
        print >> sys.stderr, 'connecting to %s port %s' % server_address
        sock.connect(server_address)
        try:
            # Send heartbeat
            message = formatter.format(
                'RBHRB,101218,161229,21.31198,N,157.88972,W,AUVSI,2')
            print >> sys.stderr, 'sending "%s"' % message
            sock.sendall(message)

            # Send docking
            message = formatter.format('RBDOK,101218,161229,AUVSI,2')
            print >> sys.stderr, 'sending "%s"' % message
            sock.sendall(message)

            # Send flag
            message = formatter.format('RBFLG,101218,161229,AUVSI,3')
            print >> sys.stderr, 'sending "%s"' % message
            sock.sendall(message)

            # Send heartbeat
            message = formatter.format(
                'RBHRB,101218,161229,21.31198,N,157.88972,W,AUVSI,2')
            print >> sys.stderr, 'sending "%s"' % message
            sock.sendall(message)
        finally:
            print >> sys.stderr, 'closing socket'
            sock.close()
        self.assertTrue(True)
コード例 #2
0
def nmea_enable(context, message):
    global active
    try:
        logger.debug("Received RXSSC message to activate {}".format(
            message['data'][1]))

        segment = message['data'][1]
        matchObj = re.match(r'[1-9#\.]', segment)
        if matchObj:
            clear()
            enable(segment, pulse_length)
            return nmea_status(context, message)
        else:
            return formatter.format("RXERR,Only %s are accepted" % valid_input,
                                    True)
    except BaseException as err:
        return formatter.format(
            "RXERR,Invalid message. Example of a valid message: $RXSSC,A,1*39",
            True)
コード例 #3
0
ファイル: server.py プロジェクト: Zenttus/roboserver
def raise_the_flag_handler(context, message):
    context['team'].FLG(message['data'], context['logfile'])
    return formatter.format("TDFLG,{},Success".format(
        timeutil.nmea_timestamp()))
コード例 #4
0
ファイル: server.py プロジェクト: Zenttus/roboserver
def automated_docking_handler(context, message):
    context['team'].DOK(message['data'], context['logfile'])
    return formatter.format("TDDOK,{},Success".format(
        timeutil.nmea_timestamp()))
コード例 #5
0
ファイル: server.py プロジェクト: Zenttus/roboserver
def heartbeat_handler(context, message):
    context['team'].HRB(message['data'], context['logfile'])
    return formatter.format("TDHRB,{},Success".format(
        timeutil.nmea_timestamp()))
コード例 #6
0
def nmea_status(context, message):
    global active
    return formatter.format("RXSSS,A,%s,12000" % active, True)