コード例 #1
0
ファイル: test_sender.c プロジェクト: super7ramp/Leonard
int main()
{
    printf("[Test sender]\n");

    socket_info_t sock1,sock2;

    sock1 = initialize_socket(IP_TEST, PORT_TEST1);
    sock2 = initialize_socket(IP_TEST, PORT_TEST2);

    if(sock1.socket_id == -1 || sock2.socket_id == -1)
    {
        printf("[FAILED] Socket initialization failed\n");
    }
    else
    {
        if (send_message("test1", sock1) != 0 ||
            send_message("test2", sock2) != 0) // test with a sniffer that what is sent is OK
        {
            printf("[FAILED] Message sending failed\n");
        }
        else
            printf("[SUCCESS] Messages were sent!\n");
    }

    close_socket(sock1);
    close_socket(sock2);

    return 0;
}
コード例 #2
0
ファイル: findy_toff_land.c プロジェクト: super7ramp/Leonard
int main ()
{
    char message [512];
    int n = 1;
    int tps = 1;

    if (initialize_socket(DEST_IP_AT, DEST_PORT_AT) != 0)
    {
        printf("[FAILED] Socket initialization failed\n");
    }
    else
    {
        sleep(1);
        set_trim(message, n++);
        usleep(500000);
        while(tps < 100)
	{
            take_off(message, n++);
            usleep(50000);
            tps++;
        }
        tps = 0;
        while(tps < 100)
        {
            reset_com(message);
            usleep(50000);
            tps++;
        }
        tps = 0;
        landing(message, n++);
        sleep(1);
    }
    close_socket();
    return 0;
}
コード例 #3
0
ファイル: ex8-recv.c プロジェクト: ozw1z5rd/Berkeley
main(int argc, char **argv )
{
		 initialize_socket( atoi(argv[1]) );
		 		 
     while( ! user_exit() ) {
          read_message();
          print_message();
     }

     close(socket_descriptor);
}
コード例 #4
0
/*
 * Module Load Callback
 */
void
_PG_init(void)
{
    /* Define custom GUC variables */
    DefineCustomStringVariable(
        "pg_query_statsd.hostname",
        gettext_noop("Host to send statsd messages to"),
        NULL,
        &statsd_host,
        "",
        PGC_SIGHUP,
        0,
        NULL,
        &assign_statsd_host,
        NULL);

    DefineCustomIntVariable(
        "pg_query_statsd.port",                             // name
        gettext_noop("Port to send statsd messages to"),    // shor desc
        NULL,                                               // long desc
        &statsd_port,                                       // var addr
        8125,                                               // boot val
        0,                                                  // min val
        16384,                                              // mav val
        PGC_SIGHUP,                                         // context
        0,                                                  // flags
        NULL,                                               // check_hook
        &assign_statsd_port,                                // assign_hook
        NULL);                                              // show_hook

    EmitWarningsOnPlaceholders("pg_query_statsd");

    initialize_socket(statsd_host, statsd_port);

    /* Install Hooks */
    if (ExecutorEnd_hook)
        prev_ExecutorEnd = ExecutorEnd_hook;
    else
        prev_ExecutorEnd = standard_ExecutorEnd;

    ExecutorEnd_hook = new_executor_end;

    if (ExecutorStart_hook)
        prev_ExecutorStart = ExecutorStart_hook;
    else
        prev_ExecutorStart = standard_ExecutorStart;

    ExecutorStart_hook = new_executor_start;
}
コード例 #5
0
ファイル: client.c プロジェクト: boz/challenge.kixeye
int main(int argc, char *argv[]) {
  int fd;

  do_getopt(argc,argv);
  fd = initialize_socket();

  reactor_initialize();
  reactor_add_listener(fd,handle_incoming_message,0);
  reactor_add_listener(STDIN_FILENO,handle_terminal_input,&fd);

  message_write_string(fd,mt_connect,config.name);

  reactor_run();
  exit(0);
}
コード例 #6
0
ファイル: http-socket.c プロジェクト: 1847123212/contiki
/*---------------------------------------------------------------------------*/
int
http_socket_get(struct http_socket *s,
                const char *url,
                int64_t pos,
                uint64_t length,
                http_socket_callback_t callback,
                void *callbackptr)
{
  initialize_socket(s);
  strncpy(s->url, url, sizeof(s->url));
  s->pos = pos;
  s->length = length;
  s->callback = callback;
  s->callbackptr = callbackptr;

  s->did_tcp_connect = 0;

  list_add(socketlist, s);

  return start_request(s);
}
コード例 #7
0
ファイル: http-socket.c プロジェクト: 1847123212/contiki
/*---------------------------------------------------------------------------*/
int
http_socket_post(struct http_socket *s,
                 const char *url,
                 const void *postdata,
                 uint16_t postdatalen,
                 const char *content_type,
                 http_socket_callback_t callback,
                 void *callbackptr)
{
  initialize_socket(s);
  strncpy(s->url, url, sizeof(s->url));
  s->postdata = postdata;
  s->postdatalen = postdatalen;
  s->content_type = content_type;

  s->callback = callback;
  s->callbackptr = callbackptr;

  s->did_tcp_connect = 0;

  list_add(socketlist, s);

  return start_request(s);
}
コード例 #8
0
ファイル: main.cpp プロジェクト: Alexandersss/COBRA-7-3
int main(int argc, char *argv[])
{
	int s;
	uint32_t whitelist_start = 0;
	uint32_t whitelist_end = 0;	
	uint16_t port = NETISO_PORT;
	
#ifndef WIN32	
	if (sizeof(off_t) < 8)
	{
		DPRINTF("off_t too small!\n");
		return -1;
	}
#endif
	
	if (argc < 2)
	{
		printf("Usage: %s rootdirectory [port] [whitelist]\nDefault port: %d\nWhitelist: x.x.x.x, where x is 0-255 or * (e.g 192.168.1.* to allow only connections from 192.168.1.0-192.168.1.255)\n", argv[0], NETISO_PORT);
		return -1;
	}
	
	if (strlen(argv[1]) >= sizeof(root_directory))
	{
		printf("Directory name too long!\n");
		return -1;
	}
	
	strcpy(root_directory, argv[1]);
	
	for (int i = strlen(root_directory)-1; i>= 0; i--)
	{
		if (root_directory[i] == '/' || root_directory[i] == '\\')
			root_directory[i] = 0;
		else
			break;
	}
	
	if (strlen(root_directory) == 0)
	{
		printf("/ can't be specified as root directory!\n");
		return -1;
	}
	
	if (argc > 2)
	{
		uint32_t u;
		
		if (sscanf(argv[2], "%u", &u) != 1)
		{
			printf("Wrong port specified.\n");
			return -1;
		}
		
#ifdef WIN32
		uint32_t min = 1;
#else
		uint32_t min = 1024;
#endif
		
		if (u < min || u > 65535)
		{
			printf("Port must be in %d-65535 range.\n", min);
			return -1;
		}
		
		port = u;
	}
	
	if (argc > 3)
	{
		char *p = argv[3];
		
		for (int i = 3; i >= 0; i--)
		{
			uint32_t u;
			int wildcard = 0;
			
			if (sscanf(p, "%u", &u) != 1)
			{
				if (i == 0)
				{
					if (strcmp(p, "*") != 0)
					{
						printf("Wrong whitelist format.\n");
						return -1;
					}					
					
				}
				else
				{
					if (p[0] != '*' || p[1] != '.')
					{
						printf("Wrong whitelist format.\n");
						return -1;
					}
				}
				
				wildcard = 1;
			}
			else
			{
				if (u > 0xFF)
				{
					printf("Wrong whitelist format.\n");
					return -1;
				}
			}
			
			if (wildcard)
			{
				whitelist_end |= (0xFF<<(i*8));
			}
			else
			{
				whitelist_start |= (u<<(i*8));
				whitelist_end |= (u<<(i*8));
			}
			
			if (i != 0)
			{
				p = strchr(p, '.');
				if (!p)
				{
					printf("Wrong whitelist format.\n");
					return -1;
				}
				
				p++;
			}
		}
		
		DPRINTF("Whitelist: %08X-%08X\n", whitelist_start, whitelist_end);
	}
	
	s = initialize_socket(port);
	if (s < 0)
	{
		printf("Error in initialization.\n");
		return -1;
	}	
	
	memset(clients, 0, sizeof(clients));
	printf("Waiting for client...\n");
	
	for (;;)
	{
		struct sockaddr_in addr;
		unsigned int size;
		int cs;
		int i;
		
		size = sizeof(addr);
		cs = accept(s, (struct sockaddr *)&addr, (socklen_t *)&size);
		
		if (cs < 0)
		{
			DPRINTF("Accept error: %d\n", get_network_error());
			printf("Network error.\n");
			break;
		}
		
		
		// Check for same client
		for (i = 0; i < MAX_CLIENTS; i++)
		{
			if (clients[i].connected && clients[i].ip_addr.s_addr == addr.sin_addr.s_addr)
				break;			
		}
		
		if (i != MAX_CLIENTS)
		{
			// Shutdown socket and wait for thread to complete
			shutdown(clients[i].s, SHUT_RDWR);
			closesocket(clients[i].s);
			join_thread(clients[i].thread);
			printf("Reconnection from %s\n",  inet_ntoa(addr.sin_addr));
		}
		else
		{
			if (whitelist_start != 0)
			{
				uint32_t ip = BE32(addr.sin_addr.s_addr);
				
				if (ip < whitelist_start || ip > whitelist_end)
				{
					printf("Rejected connection from %s (not in whitelist)\n", inet_ntoa(addr.sin_addr));
					closesocket(cs);
					continue;
				}
			}
			
			for (i = 0; i < MAX_CLIENTS; i++)
			{
				if (!clients[i].connected)
					break;
			}
			
			if (i == MAX_CLIENTS)
			{
				printf("Too many connections! (rejected client: %s)\n", inet_ntoa(addr.sin_addr));
				closesocket(cs);
				continue;
			}			
			
			printf("Connection from %s\n",  inet_ntoa(addr.sin_addr));
		}
		
		if (initialize_client(&clients[i]) != 0)
		{
			printf("System seems low in resources.\n");
			break;
		}
		
		clients[i].s = cs;
		clients[i].ip_addr = addr.sin_addr;		
		create_start_thread(&clients[i].thread, client_thread, &clients[i]);
	}
	
#ifdef WIN32
	WSACleanup();
#endif
	
	return 0;
}
コード例 #9
0
ファイル: server.c プロジェクト: zweng/java-examples
int main(void)
{
    char in_buf[MAXDATASIZE];
    int sockfd, new_fd, rc;
    rc = initialize_socket(&sockfd);
    if(rc!=0)
    {
        fprintf(stderr, "socket initilization error.\n");
    }

    if (listen(sockfd, BACKLOG) == -1)
    {
        perror("listen");
        exit(1);
    }

    struct sigaction sa;
    socklen_t sin_size;
    struct sockaddr_storage their_addr; // connector's address information
    char s[INET6_ADDRSTRLEN];

    sa.sa_handler = sigchld_handler; // reap all dead processes
    sigemptyset(&sa.sa_mask);
    sa.sa_flags = SA_RESTART;
    if (sigaction(SIGCHLD, &sa, NULL) == -1)
    {
        perror("sigaction");
        exit(1);
    }

    printf("server: waiting for connections...\n");


    while(1)    // main accept() loop
    {
        sin_size = sizeof their_addr;
        new_fd = accept(sockfd, (struct sockaddr *)&their_addr, &sin_size);
        if (new_fd == -1)
        {
            perror("accept");
            continue;
        }

        inet_ntop(their_addr.ss_family,
                  get_in_addr((struct sockaddr *)&their_addr),
                  s, sizeof s);
        printf("server: got connection from %s\n", s);

        if (!fork())   // this is the child process
        {
            close(sockfd); // child doesn't need the listener
            memset ( in_buf, 0, MAXDATASIZE );
            int numbytes;
            if ((numbytes = recv(new_fd, in_buf, MAXDATASIZE-1, 0)) == -1)
            {
                perror("recv");
                exit(1);
            }
            printf("in_buf:\n");
            printf("%s\n", in_buf);
            if (send(new_fd, in_buf, numbytes, 0) == -1)
                perror("send");
            close(new_fd);
            printf("sent the message\n");
            exit(0);
        }
        close(new_fd);  // parent doesn't need this
    }
    return 0;
}
コード例 #10
0
static void
assign_statsd_host(char *newval, void *extra)
{
    initialize_socket(newval, statsd_port);
}
コード例 #11
0
PeerDiscovery::DomainPeerDiscovery::DomainPeerDiscovery(sa_family_t domain, in_port_t port)
    : domain_(domain), port_(port), sockfd_(initialize_socket(domain))
{
    socketJoinMulticast(sockfd_, domain);
}
コード例 #12
0
ファイル: main.cpp プロジェクト: aldostools/ps3netsvr
int main(int argc, char *argv[])
{
	int s;
	uint32_t whitelist_start = 0;
	uint32_t whitelist_end = 0;
	uint16_t port = NETISO_PORT;

	printf("ps3netsrv build 20161211 (mod by aldostools)\n");

#ifndef WIN32
	if(sizeof(off_t) < 8)
	{
		DPRINTF("off_t too small!\n");
		return -1;
	}
#endif

	file_stat_t fs;

	if(argc < 2 && ((stat_file("./PS3ISO", &fs) >= 0) || (stat_file("./PSXISO", &fs) >= 0) || (stat_file("./GAMES", &fs) >= 0) || (stat_file("./GAMEZ", &fs) >= 0)  || (stat_file("./DVDISO", &fs) >= 0) || (stat_file("./BDISO", &fs) >= 0))) {argv[1] = (char *)malloc(2); sprintf(argv[1], "."); argc = 2;}

	if(argc < 2)
	{
		#ifdef MERGE_DRIVES
		printf( "\nUsage: %s [rootdirectory] [port] [whitelist] [ignore drive letters]\n\n"
				"Default port: %d\n"
				"Whitelist: x.x.x.x, where x is 0-255 or *\n"
				"(e.g 192.168.1.* to allow only connections from 192.168.1.0-192.168.1.255)\n", argv[0], NETISO_PORT);
		#else
		printf( "\nUsage: %s [rootdirectory] [port] [whitelist]\n\n"
				"Default port: %d\n"
				"Whitelist: x.x.x.x, where x is 0-255 or *\n"
				"(e.g 192.168.1.* to allow only connections from 192.168.1.0-192.168.1.255)\n", argv[0], NETISO_PORT);
		#endif
		return -1;
	}

	if(strlen(argv[1]) >= sizeof(root_directory))
	{
		printf("Directory name too long!\n");
		return -1;
	}

	strcpy(root_directory, argv[1]);

	for (int i = strlen(root_directory) - 1; i >= 0; i--)
	{
		if(root_directory[i] == '/' || root_directory[i] == '\\')
			root_directory[i] = 0;
		else
			break;
	}

	printf("Path: %s\n\n", root_directory);

	root_len = strlen(root_directory);

	if(root_len == 0)
	{
		printf("/ can't be specified as root directory!\n");
		return -1;
	}

	if(argc > 2)
	{
		uint32_t u;

		if(sscanf(argv[2], "%u", &u) != 1)
		{
			printf("Wrong port specified.\n");
			return -1;
		}

#ifdef WIN32
		uint32_t min = 1;
#else
		uint32_t min = 1024;
#endif

		if(u < min || u > 65535)
		{
			printf("Port must be in %d-65535 range.\n", min);
			return -1;
		}

		port = u;
	}

	if(argc > 3)
	{
		char *p = argv[3];

		for (int i = 3; i >= 0; i--)
		{
			uint32_t u;
			int wildcard = 0;

			if(sscanf(p, "%u", &u) != 1)
			{
				if(i == 0)
				{
					if(strcmp(p, "*") != 0)
					{
						printf("Wrong whitelist format.\n");
						return -1;
					}

				}
				else
				{
					if(p[0] != '*' || p[1] != '.')
					{
						printf("Wrong whitelist format.\n");
						return -1;
					}
				}

				wildcard = 1;
			}
			else
			{
				if(u > 0xFF)
				{
					printf("Wrong whitelist format.\n");
					return -1;
				}
			}

			if(wildcard)
			{
				whitelist_end |= (0xFF<<(i*8));
			}
			else
			{
				whitelist_start |= (u<<(i*8));
				whitelist_end |= (u<<(i*8));
			}

			if(i != 0)
			{
				p = strchr(p, '.');
				if(!p)
				{
					printf("Wrong whitelist format.\n");
					return -1;
				}

				p++;
			}
		}

		DPRINTF("Whitelist: %08X-%08X\n", whitelist_start, whitelist_end);
	}

#ifdef MERGE_DRIVES
	if(argc > 4)
	{
		ignore_drives = argv[4];
	}
	else if(whitelist_end == 0x0A000008)
	{
		ignore_drives = (char*)"E"; // ignore E:\ by default only if whitelist is 10.0.0.8
	}

	// convert to upper case
	if(ignore_drives)
	{
		ignore_drives_len = strlen(ignore_drives);

		for(uint8_t d = 0; d < ignore_drives_len; d++)
			if((ignore_drives[d] >= 'a') && (ignore_drives[d] <= 'z')) ignore_drives[d] -= ('a'-'A');
	}
#endif

	s = initialize_socket(port);
	if(s < 0)
	{
		printf("Error in initialization.\n");
		return -1;
	}

	memset(clients, 0, sizeof(clients));
	printf("Waiting for client...\n");

	for (;;)
	{
		struct sockaddr_in addr;
		unsigned int size;
		int cs;
		int i;

		size = sizeof(addr);
		cs = accept(s, (struct sockaddr *)&addr, (socklen_t *)&size);

		if(cs < 0)
		{
			printf("Network error: %d\n", get_network_error());
			break;
		}

		// Check for same client
		for (i = 0; i < MAX_CLIENTS; i++)
		{
			if(clients[i].connected && clients[i].ip_addr.s_addr == addr.sin_addr.s_addr)
				break;
		}

		if(i != MAX_CLIENTS)
		{
			// Shutdown socket and wait for thread to complete
			shutdown(clients[i].s, SHUT_RDWR);
			closesocket(clients[i].s);
			join_thread(clients[i].thread);
			printf("Reconnection from %s\n",  inet_ntoa(addr.sin_addr));
		}
		else
		{
			if(whitelist_start != 0)
			{
				uint32_t ip = BE32(addr.sin_addr.s_addr);

				if(ip < whitelist_start || ip > whitelist_end)
				{
					printf("Rejected connection from %s (not in whitelist)\n", inet_ntoa(addr.sin_addr));
					closesocket(cs);
					continue;
				}
			}

			for (i = 0; i < MAX_CLIENTS; i++)
			{
				if(!clients[i].connected)
					break;
			}

			if(i == MAX_CLIENTS)
			{
				printf("Too many connections! (rejected client: %s)\n", inet_ntoa(addr.sin_addr));
				closesocket(cs);
				continue;
			}

			printf("Connection from %s\n",  inet_ntoa(addr.sin_addr));
		}

		if(initialize_client(&clients[i]) != 0)
		{
			printf("System seems low in resources.\n");
			break;
		}

		clients[i].s = cs;
		clients[i].ip_addr = addr.sin_addr;
		create_start_thread(&clients[i].thread, client_thread, &clients[i]);
	}

#ifdef WIN32
	#ifdef MERGE_DRIVES
	if(ignore_drives)
	{
		free(ignore_drives);
	}
	#endif
	WSACleanup();
#endif

	return 0;
}
コード例 #13
0
ファイル: findy_rotation.c プロジェクト: super7ramp/Leonard
int main ()
{
    char message [512];
    int n = 1;
    int tps = 1;

    if (initialize_socket(DEST_IP_AT, DEST_PORT_AT) != 0)
    {
        printf("[FAILED] Socket initialization failed\n");
    }
    else
    {
        sleep(1);
        set_trim(message, n++);
        usleep(500000);
        while(tps < 167)
        {
                take_off(message, n++);
                usleep(30000);
                tps++;
        }
        tps = 0;
        while(tps < 133)
        {
                reset_com(message);
                usleep(30000);
                tps++;
        }
        tps = 0;
/*              while(tps < 30)
        {
                set_pitch(message, n++, BACK, 0.25);
                usleep(50000);
                tps++;
        }
        tps = 0;
        while(tps < 10)
        {
                set_pitch(message, n++, FRONT, 0.1);
                usleep(50000);
                tps++;
        }
        tps = 0;
        while(tps < 30)
        {
                set_pitch(message, n++, BACK, 0.0);
                usleep(50000);
                tps++;
        }
        tps = 0;*/
/*              while(tps < 60)
        {
                take_off(message, n++);
                usleep(50000);
                tps++;
        }
        tps = 0;*/
        while(tps < 150)
        {
                set_yaw(message, n++, LEFT, 0.4);
                usleep(30000);
                tps++;
        }
        tps = 0;
        set_yaw(message, n++, RIGHT, 0.0);
        usleep(30000);
        while(tps < 133)
        {
                reset_com(message);
                usleep(30000);
                tps++;
        }
        tps = 0;
        landing(message, n++);
        sleep(1);
    }
    close_socket();
    return 0;
}
コード例 #14
0
ファイル: mdio_main.c プロジェクト: KimMui/i2sTest
int mdio_main(int argc, char *argv[])
#endif
{
  int ret;
  int i;

  /* test related */

  uint16_t phy_id;
  uint16_t reg_num;
  uint16_t val_in;
  uint16_t val_out;

  /*--- SETUP --------------------------------------------------------------*/

  if (argc == 1)
    {
      printf("usage:\n");
      printf("\n");
      printf("  %s phy_id reg_no          -- read register\n", argv[0]);
      printf("  %s phy_id reg_no value    -- write register\n", argv[0]);
      printf("\n");
      return -1;
    }

  initialize_socket();

  if (argc == 4) /* Write to register */
    {
      phy_id = strtol(argv[1], NULL, 16);
      reg_num = strtol(argv[2], NULL, 16);
      val_in = strtol(argv[3], NULL, 16);

      ret = set_phy_reg(phy_id, reg_num, val_in);
      if (ret != 0)
        {
          printf("%s() returned %d\n", "set_phy_reg", ret);
        }
    }
  else if (argc == 3) /* Read from register */
    {
      phy_id = strtol(argv[1], NULL, 16);
      reg_num = strtol(argv[2], NULL, 16);

      ret = get_phy_reg(phy_id, reg_num, &val_out);
      if (ret != 0)
        {
          printf("%s() returned %d\n", "get_phy_reg", ret);
        }
      else
        {
          printf("0x%4x\n", val_out);
        }
    }
  else if (argc == 2)
    {
      phy_id = strtol(argv[1], NULL, 16);

      for (i = 0; i < 32; i++)
        {
          ret = get_phy_reg(phy_id, i, &val_out);

          printf("phy[%d][%d] = 0x%4x\n", phy_id, i, val_out);
        }
    }
  else
    {
      /* Read the PHY address */

      phy_id = get_phy_id();

      if (phy_id < 1)
        {
          /* failed (can not be negative) */

          printf("getting phy id failed\n");
        }
      else
        {
          printf("phy_id = %d\n", phy_id);
        }
    }

  return 0;
}
コード例 #15
0
static void
assign_statsd_port(int newval, void *extra)
{
    initialize_socket(statsd_host, newval);
}
コード例 #16
0
ファイル: findy_al_ar.c プロジェクト: super7ramp/Leonard
int main ()
{
    char message [512];
    int n = 1;
    int tps = 1;

    if (initialize_socket(DEST_IP_AT, DEST_PORT_AT) != 0)
    {
        printf("[FAILED] Socket initialization failed\n");
    }
    else
    {
        sleep(1);
        set_trim(message, n++);
        usleep(500000);
////////////// take off //////////////////////////
        while(tps < 167)                        //100 avec 50ms
        {
            take_off(message, n++);
            usleep(30000);
            tps++;
        }
        tps = 0;
////////////// WAIT ////////////////////
        while(tps < 133)                        //80
        {
            reset_com(message);
            usleep(30000);
            tps++;
        }
        tps = 0;
////////////// GO ////////////////////
        while(tps < 58)                         //35
        {
            set_pitch(message, n++, FRONT, 0.25);
            usleep(30000);
            tps++;
        }
        tps = 0;
        while(tps < 17)                         //10
        {
            set_pitch(message, n++, BACK, 0.25);
            usleep(30000);
            tps++;
        }
        tps = 0;
        while(tps < 17)
        {
            set_pitch(message, n++, FRONT, 0.0);
            usleep(30000);
            tps++;
        }
        tps = 0;
////////////// WAIT ////////////////////
        while(tps < 25)
        {
            reset_com(message);
            usleep(30000);
            tps++;
        }
        tps = 0;
////////////// ROTATE ////////////////////
        while(tps < 110)                        //140
        {
            set_yaw(message, n++, LEFT, 0.4);
            usleep(30000);
            tps++;
        }
        tps = 0;
        set_yaw(message, n++, RIGHT, 0.0);
        usleep(30000);
////////////// WAIT ////////////////////
        while(tps < 80)
        {
            reset_com(message);
            usleep(30000);
            tps++;
        }
        tps = 0;
////////////// RETURN ////////////////////
        while(tps < 58)
        {
            set_pitch(message, n++, FRONT, 0.25);
            usleep(30000);
            tps++;
        }
        tps = 0;
        while(tps < 17)
        {
            set_pitch(message, n++, BACK, 0.25);
            usleep(30000);
            tps++;
        }
        tps = 0;
        while(tps < 17)
        {
            set_pitch(message, n++, FRONT, 0.0);
            usleep(30000);
            tps++;
        }
        tps = 0;
////////////// WAIT ////////////////////
        while(tps < 167)
        {
            reset_com(message);
            usleep(30000);
            tps++;
        }
        tps = 0;
////////////// LAND ////////////////////
        landing(message, n++);
        sleep(1);
    }
    close_socket();
    return 0;
}
コード例 #17
0
ファイル: message_drone.c プロジェクト: super7ramp/Leonard
/** @brief Initialize AT communication
 *  @return -1 on failure
 */
int initialize_at_com()
{
    at_socket = initialize_socket(DEST_IP_AT, DEST_PORT_AT);
    return at_socket.socket_id;
}