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)
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)
def raise_the_flag_handler(context, message): context['team'].FLG(message['data'], context['logfile']) return formatter.format("TDFLG,{},Success".format( timeutil.nmea_timestamp()))
def automated_docking_handler(context, message): context['team'].DOK(message['data'], context['logfile']) return formatter.format("TDDOK,{},Success".format( timeutil.nmea_timestamp()))
def heartbeat_handler(context, message): context['team'].HRB(message['data'], context['logfile']) return formatter.format("TDHRB,{},Success".format( timeutil.nmea_timestamp()))
def nmea_status(context, message): global active return formatter.format("RXSSS,A,%s,12000" % active, True)