[ARDrone] Fix compilation warning
Add pthread_exit(NULL_value). Delete variable inused and labview socket.
This commit is contained in:
parent
46292cfe8c
commit
c18209545c
|
@ -22,6 +22,8 @@
|
||||||
|
|
||||||
#define SEPARATOR ','
|
#define SEPARATOR ','
|
||||||
#define EOL '$'
|
#define EOL '$'
|
||||||
|
#define TYPE "GPS"
|
||||||
|
|
||||||
|
|
||||||
/* Options */
|
/* Options */
|
||||||
|
|
||||||
|
@ -74,23 +76,37 @@ int main(int argc, char *argv[])
|
||||||
program_name = argv[0] ;
|
program_name = argv[0] ;
|
||||||
parse_command_line(argc, argv) ;
|
parse_command_line(argc, argv) ;
|
||||||
|
|
||||||
create_socket() ;
|
|
||||||
pthread_t send ;
|
|
||||||
pthread_create(&send, NULL, thread_send, NULL) ;
|
|
||||||
// Thread communication TCP OwlSIG
|
// Thread communication TCP OwlSIG
|
||||||
pthread_t control ;
|
pthread_t control ;
|
||||||
pthread_create(&control, NULL, thread_control, NULL) ;
|
pthread_create(&control, NULL, thread_control, NULL) ;
|
||||||
|
|
||||||
|
if(!strcmp(TYPE,"WIFI"))
|
||||||
|
{
|
||||||
|
pthread_t send ;
|
||||||
|
pthread_t receive ;
|
||||||
|
create_socket() ;
|
||||||
|
pthread_create(&send, NULL, thread_send, NULL) ;
|
||||||
|
if (options.listening_port > 0)
|
||||||
|
pthread_create(&receive, NULL, receive_position, NULL) ;
|
||||||
|
}
|
||||||
|
else if(!strcmp(TYPE,"GPS"))
|
||||||
|
{
|
||||||
pthread_t gps ;
|
pthread_t gps ;
|
||||||
pthread_create(&gps, NULL, thread_gps, NULL) ;
|
pthread_create(&gps, NULL, thread_gps, NULL) ;
|
||||||
while(1)
|
|
||||||
{
|
|
||||||
if (options.listening_port > 0)
|
|
||||||
receive_position() ;
|
|
||||||
else usleep(1000);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("TYPE is not correct, change value of TYPE\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(void) close(socksendfd) ;
|
(void) close(socksendfd) ;
|
||||||
(void) close(sockreceivefd) ;
|
(void) close(sockreceivefd) ;
|
||||||
//(void) close(socksendlvfd) ; //Use for close labview socket ; for next use
|
|
||||||
return 0 ;
|
return 0 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,21 +115,23 @@ int main(int argc, char *argv[])
|
||||||
void parse_command_line(int argc, char **argv)
|
void parse_command_line(int argc, char **argv)
|
||||||
{
|
{
|
||||||
parse_main_options(argc, argv) ;
|
parse_main_options(argc, argv) ;
|
||||||
|
if(!strcmp(TYPE,"WIFI"))
|
||||||
|
{
|
||||||
check_destination_ip() ;
|
check_destination_ip() ;
|
||||||
parse_calibration_data(argc, argv) ;
|
parse_calibration_data(argc, argv) ;
|
||||||
check_configuration() ;
|
check_configuration() ;
|
||||||
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
print_configuration() ;
|
print_configuration() ;
|
||||||
#endif // DEBUG
|
#endif // DEBUG
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void traficGPS(int gps)
|
|
||||||
{
|
void traficGPS(int gps) {
|
||||||
int offset=0, c=1, i=0, l;
|
int offset=0, c=1, i=0;
|
||||||
char buffer[4096], chtime[1024];
|
char buffer[4096];
|
||||||
char *utc, *latitude, *longitude, *chv, *cmd, *ch;
|
|
||||||
float vitesse;
|
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
@ -203,40 +221,22 @@ void traficGPS(int gps)
|
||||||
share_lon=datagps.longitude;
|
share_lon=datagps.longitude;
|
||||||
printf("lat %s lon %s\n",data[3], data[5]);
|
printf("lat %s lon %s\n",data[3], data[5]);
|
||||||
printf("Time : %f | State : %c | Latitude : %.10f%c | Longitude %.10f%c | Speed : %f km/h | Cap : %f° | Date : %d | DecMagn : %f maps %.10f %.10f\n",datagps.time, datagps.state, datagps.latitude, datagps.orilat, datagps.longitude, datagps.orilon, datagps.speed, datagps.cap, datagps.date, datagps.decmag, share_lat, share_lon);
|
printf("Time : %f | State : %c | Latitude : %.10f%c | Longitude %.10f%c | Speed : %f km/h | Cap : %f° | Date : %d | DecMagn : %f maps %.10f %.10f\n",datagps.time, datagps.state, datagps.latitude, datagps.orilat, datagps.longitude, datagps.orilon, datagps.speed, datagps.cap, datagps.date, datagps.decmag, share_lat, share_lon);
|
||||||
|
|
||||||
|
|
||||||
/* printf("Taille : %d | Message : %s\n",strlen(buffer+i),buffer+i);
|
|
||||||
cmd=strtok(buffer+i,",");
|
|
||||||
utc=strtok(NULL,",");
|
|
||||||
ch=strtok(NULL,",");
|
|
||||||
latitude=strtok(NULL,",");
|
|
||||||
ch=strtok(NULL,",");
|
|
||||||
longitude=strtok(NULL,",");
|
|
||||||
ch=strtok(NULL,",");
|
|
||||||
chv=strtok(NULL,",");
|
|
||||||
//printf("h %s lt %s lg %s v %s\n",utc, latitude, longitude,chv);
|
|
||||||
vitesse=atof(chv)*1.852;
|
|
||||||
share_lat=atof(strndup(latitude,2))+atof(strndup(latitude+2,strlen(latitude)-2))/60.0;
|
|
||||||
share_lon=atof(strndup(longitude,3))+atof(strndup(longitude+3,strlen(longitude)-3))/60.0;
|
|
||||||
printf("h %s lt %s lg %s v %f km/h share lat lon %f %f\n",utc, latitude, longitude,vitesse, share_lat, share_lon);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void* thread_gps(void* data)
|
void* thread_gps(void* NULL_value)
|
||||||
{
|
{
|
||||||
int c=0;
|
|
||||||
char buffer[1024];
|
char buffer[1024];
|
||||||
|
|
||||||
int gps_fd = open("/dev/ttyPA0",O_RDONLY);
|
int gps_fd = open("/dev/ttyPA0",O_RDONLY);
|
||||||
|
|
||||||
read(gps_fd, buffer, 80);
|
read(gps_fd, buffer, 80);
|
||||||
//printf("%sxxx\n",buffer);
|
|
||||||
traficGPS(gps_fd);
|
traficGPS(gps_fd);
|
||||||
|
pthread_exit(NULL_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* thread_send(void* data)
|
void* thread_send(void* NULL_value)
|
||||||
{
|
{
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
|
@ -244,11 +244,11 @@ void* thread_send(void* data)
|
||||||
send_request() ;
|
send_request() ;
|
||||||
sleep(1) ;
|
sleep(1) ;
|
||||||
}
|
}
|
||||||
return NULL;
|
pthread_exit(NULL_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TCP Server OwlSIG
|
// TCP Server OwlSIG
|
||||||
void* thread_control(void* data)
|
void* thread_control(void* NULL_value)
|
||||||
{
|
{
|
||||||
int sockfd, newsockfd, portno=8080;
|
int sockfd, newsockfd, portno=8080;
|
||||||
socklen_t clilen;
|
socklen_t clilen;
|
||||||
|
@ -322,7 +322,7 @@ void* thread_control(void* data)
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
close(sockfd);
|
close(sockfd);
|
||||||
return NULL;
|
pthread_exit(NULL_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void parse_main_options(int argc, char **argv)
|
void parse_main_options(int argc, char **argv)
|
||||||
|
@ -523,16 +523,9 @@ void print_configuration()
|
||||||
|
|
||||||
void create_socket()
|
void create_socket()
|
||||||
{
|
{
|
||||||
char *ip_labview = "192.168.3.2" ;
|
|
||||||
int port_labview = 50000 ;
|
|
||||||
socksendfd =
|
socksendfd =
|
||||||
owlclient_create_trx_socket(options.dest_ip, options.dest_port,
|
owlclient_create_trx_socket(options.dest_ip, options.dest_port,
|
||||||
&server, options.iface) ;
|
&server, options.iface) ;
|
||||||
|
|
||||||
//socksendlvfd =
|
|
||||||
//owlclient_create_trx_socket(ip_labview, port_labview,
|
|
||||||
// &server, options.iface) ;
|
|
||||||
|
|
||||||
sockreceivefd =
|
sockreceivefd =
|
||||||
owl_create_udp_listening_socket(options.listening_port) ;
|
owl_create_udp_listening_socket(options.listening_port) ;
|
||||||
}
|
}
|
||||||
|
@ -602,15 +595,20 @@ void send_request()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void receive_position()
|
void* receive_position(void* NULL_value)
|
||||||
{
|
{
|
||||||
// Position of the mobile as computed by the infrastructure:
|
// Position of the mobile as computed by the infrastructure:
|
||||||
char timestampXYZ[128] ;
|
char timestampXYZ[128] ;
|
||||||
char *data_cpy ;
|
char *data_cpy ;
|
||||||
|
while(1)
|
||||||
|
{
|
||||||
recvfrom(sockreceivefd, ×tampXYZ, 128, 0, NULL, NULL) ;
|
recvfrom(sockreceivefd, ×tampXYZ, 128, 0, NULL, NULL) ;
|
||||||
//send_labview(timestampXYZ) ; // Use for future
|
//send_labview(timestampXYZ) ; // Use for future
|
||||||
data_cpy = strdup(timestampXYZ) ;
|
data_cpy = strdup(timestampXYZ) ;
|
||||||
string2data(data_cpy) ;
|
string2data(data_cpy) ;
|
||||||
|
usleep(100000);
|
||||||
|
}
|
||||||
|
pthread_exit(NULL_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void string2data(char* string_data)
|
void string2data(char* string_data)
|
||||||
|
@ -752,13 +750,6 @@ void string2data(char* string_data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void send_labview(char* string_data)
|
|
||||||
{
|
|
||||||
//owlclient_send_request(socksendlvfd, &server, string_data, strlen(string_data),
|
|
||||||
//1, 0) ;
|
|
||||||
//printf("Send to labView : %s", string_data) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
void print_error(char* merror)
|
void print_error(char* merror)
|
||||||
{
|
{
|
||||||
if(!strcmp(merror,"trame")) printf("Impossible à lire la trame : Abandon") ;
|
if(!strcmp(merror,"trame")) printf("Impossible à lire la trame : Abandon") ;
|
||||||
|
|
|
@ -31,12 +31,10 @@ void print_configuration(void) ;
|
||||||
void create_socket(void) ;
|
void create_socket(void) ;
|
||||||
void make_packet(void) ;
|
void make_packet(void) ;
|
||||||
void send_request(void) ;
|
void send_request(void) ;
|
||||||
void receive_position(void) ;
|
void* receive_position(void*) ;
|
||||||
void print_usage(void) ;
|
void print_usage(void) ;
|
||||||
void send_labview(char*) ;
|
|
||||||
void string2data(char*) ;
|
void string2data(char*) ;
|
||||||
void traficGPS(int);
|
void traficGPS(int);
|
||||||
static int isWaiting(int);
|
|
||||||
void* thread_gps(void*) ;
|
void* thread_gps(void*) ;
|
||||||
void* thread_send(void*) ;
|
void* thread_send(void*) ;
|
||||||
void* thread_control(void*) ;
|
void* thread_control(void*) ;
|
||||||
|
|
Loading…
Reference in New Issue