[ARDrone] Fix compilation
Use /usr/include/libiw.h and wireless.h to cross-compile for ARM. Update variable names from libowlps and owlps.h (prefix owl_). Move #includes from .h to .c. Update path of library in Makefile.
This commit is contained in:
parent
290fcfa49b
commit
207e815192
|
@ -11,24 +11,23 @@ ifeq ($(COLORGCC), 0)
|
|||
CC = colorgcc
|
||||
endif
|
||||
|
||||
# Cross_compil
|
||||
#CC = /arm/bin/arm-none-linux-gnueabi-gcc
|
||||
|
||||
# Commandes d'installation et de désinstallation
|
||||
RM=rm -fv
|
||||
CP=cp -v
|
||||
|
||||
# Cible
|
||||
TARGET=owlps-client
|
||||
TARGET=owlps-drone
|
||||
HEADER=
|
||||
|
||||
# Flags
|
||||
CFLAGS = -O2 -Wall -Wextra -Wstrict-prototypes -O -I.
|
||||
LIBOWLPS_DIR = ../libowlps
|
||||
LIBOWLPSCLIENT_DIR = ../libowlps-client
|
||||
CFLAGS = -O2 -Wall -Wextra -Wstrict-prototypes \
|
||||
-I$(LIBOWLPS_DIR) -I$(LIBOWLPSCLIENT_DIR)
|
||||
DEPFLAGS = -MMD
|
||||
XCFLAGS = $(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS)
|
||||
PICFLAG = -fPIC
|
||||
LIBS = -L../../libowlps -lowlps -L../libowlps-client -lowlps-client
|
||||
SEMISTATIC_LIBS = $(LOWLPSA) $(LIBS)
|
||||
LIBS = -L$(LIBOWLPS_DIR) -lowlps -L$(LIBOWLPSCLIENT_DIR) -lowlps-client
|
||||
STATIC_LIBS = -liw -lm -lrt
|
||||
|
||||
|
||||
|
@ -38,7 +37,6 @@ STATIC_LIBS = -liw -lm -lrt
|
|||
|
||||
dynamic : $(TARGET)
|
||||
static : $(TARGET).static
|
||||
semistatic: $(TARGET).semistatic
|
||||
all : dynamic static
|
||||
|
||||
% : %.o
|
||||
|
@ -49,9 +47,6 @@ all : dynamic static
|
|||
# Compilation du programme
|
||||
$(TARGET) : $(TARGET).o $(HEADER)
|
||||
|
||||
$(TARGET).semistatic: $(TARGET).c $(HEADER)
|
||||
$(CC) $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ $(LDFLAGS) $(SEMISTATIC_LIBS)
|
||||
|
||||
$(TARGET).static : $(TARGET).c $(HEADER)
|
||||
$(CC) $(LDFLAGS) -static $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ $(LIBS) $(STATIC_LIBS)
|
||||
|
||||
|
|
|
@ -1,105 +0,0 @@
|
|||
# Emplacement de la suite de cross-compilation
|
||||
TOOLCHAIN_PREFIX = $$HOME/openwrt/atheros/8.09
|
||||
TOOLCHAIN_BIN = $(TOOLCHAIN_PREFIX)/staging_dir/toolchain-mips_gcc4.1.2/bin
|
||||
TOOLCHAIN_USR = $(TOOLCHAIN_PREFIX)/staging_dir/mips/usr
|
||||
TOOLCHAIN_USR_2 = $(TOOLCHAIN_PREFIX)/build_dir/mips/OpenWrt-SDK-atheros-for-Linux-i686/staging_dir/toolchain-mips_gcc4.1.2
|
||||
|
||||
# Répertoire d'installation
|
||||
PREFIX=/usr/local
|
||||
INSTALL_DIR= $(PREFIX)/bin
|
||||
INSTALL_LIB= $(PREFIX)/lib
|
||||
INSTALL_INC= $(PREFIX)/include
|
||||
INSTALL_MAN= $(PREFIX)/share/man
|
||||
|
||||
# Compilateur
|
||||
CC = $(TOOLCHAIN_BIN)/mips-linux-gcc
|
||||
|
||||
# Commandes d'installation et de désinstallation
|
||||
RM=rm -fv
|
||||
CP=cp -v
|
||||
|
||||
# Cible
|
||||
TARGET=owlps-client
|
||||
HEADER=
|
||||
|
||||
# Flags
|
||||
CFLAGS = -O2 -Wall -Wextra -Wstrict-prototypes -I.
|
||||
DEPFLAGS = -MMD
|
||||
XCFLAGS = $(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS)
|
||||
PICFLAG = -fPIC
|
||||
LOWLPS = -L../../libowlps -lowlps
|
||||
LOWLPSA = ../../libowlps/libowlps.a
|
||||
LOWLPSCLIENTA = ../libowlps-client/libowlps-client.a
|
||||
LIBS = $(LOWLPSCLIENTA) -liw -lm
|
||||
DYNAMIC_LIBS = $(LOWLPS) $(LIBS)
|
||||
SEMISTATIC_LIBS = $(LOWLPSA) $(LIBS)
|
||||
STATIC_LIBS = $(LOWLPSA) $(LIBS)
|
||||
LATHEROS = -L$(TOOLCHAIN_USR)/lib -L$(TOOLCHAIN_USR_2)/lib
|
||||
IATHEROS = -I$(TOOLCHAIN_USR)/include -I$(TOOLCHAIN_USR_2)/include
|
||||
LDFLAGS = $(IATHEROS) $(LATHEROS)
|
||||
|
||||
|
||||
## Cibles de compilation standard ##
|
||||
|
||||
.PHONY: all dynamic semistatic static install uninstall clean purge help
|
||||
|
||||
dynamic: $(TARGET)
|
||||
semistatic: $(TARGET).semistatic
|
||||
static: $(TARGET).static
|
||||
all: dynamic semistatic static
|
||||
|
||||
# Cancel implicit make rule
|
||||
%: %.c
|
||||
|
||||
%: %.o
|
||||
$(CC) $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ $(LDFLAGS) $(DYNAMIC_LIBS)
|
||||
|
||||
%.semistatic: %.o
|
||||
$(CC) $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ $(LDFLAGS) $(SEMISTATIC_LIBS)
|
||||
|
||||
%.static: %.o
|
||||
$(CC) $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ $(LDFLAGS) $(STATIC_LIBS) \
|
||||
-static
|
||||
|
||||
%.o: %.c $(HEADER)
|
||||
$(CC) $(XCFLAGS) $(IATHEROS) $(OWLPSFLAGS) -c $<
|
||||
|
||||
|
||||
## Installation / désinstallation ##
|
||||
|
||||
install : $(TARGET)
|
||||
@$(CP) $(TARGET) $(INSTALL_DIR)
|
||||
@cd $(INSTALL_DIR) ; chown root:root $(TARGET) ; chmod 755 $(TARGET)
|
||||
|
||||
uninstall :
|
||||
@$(RM) $(INSTALL_DIR)/$(TARGET)
|
||||
|
||||
|
||||
## Nettoyage ##
|
||||
|
||||
clean :
|
||||
@$(RM) -fv *~ *.o *.d
|
||||
|
||||
purge : clean
|
||||
@$(RM) -fv $(TARGET) $(TARGET).static $(TARGET).semistatic
|
||||
|
||||
|
||||
## Aide ##
|
||||
|
||||
help :
|
||||
@echo -e "Bibliothèques nécessaires à la compilation :\n\
|
||||
libowlps1.0 (fournie)\n\
|
||||
\n\
|
||||
Cibles possibles :\n\
|
||||
$(TARGET) (cible par défaut) : Compile le programme $(TARGET).\n\
|
||||
$(TARGET).static : Compile le programme $(TARGET).static \
|
||||
(version sans lien dynamique).\n\
|
||||
$(TARGET).semistatic : Compile le programme $(TARGET).semistatic \
|
||||
(version sans lien dynamique vers libowlps).\n\
|
||||
install : Installe le programme $(TARGET).\n\
|
||||
uninstall : Désinstalle le programme $(TARGET).\n\
|
||||
clean : Supprime les fichiers temporaires.\n\
|
||||
purge : Supprime le résultat de la compilation.\n\
|
||||
\n\
|
||||
Note : l'installation se fait dans l'arborescence $(PREFIX). \
|
||||
Modifiez la variable PREFIX du Makefile pour changer ce comportement."
|
|
@ -1,105 +0,0 @@
|
|||
# Emplacement de la suite de cross-compilation
|
||||
TOOLCHAIN_PREFIX = $$HOME/openwrt/atheros/10.03
|
||||
TOOLCHAIN_BIN = $(TOOLCHAIN_PREFIX)/staging_dir/toolchain-mips_gcc-4.3.3+cs_uClibc-0.9.30.1/usr/bin
|
||||
TOOLCHAIN_USR = $(TOOLCHAIN_PREFIX)/staging_dir/toolchain-mips_gcc-4.3.3+cs_uClibc-0.9.30.1/usr
|
||||
TOOLCHAIN_USR_2 = $(TOOLCHAIN_PREFIX)/staging_dir/target-mips_uClibc-0.9.30.1/usr
|
||||
|
||||
# Répertoire d'installation
|
||||
PREFIX=/usr/local
|
||||
INSTALL_DIR= $(PREFIX)/bin
|
||||
INSTALL_LIB= $(PREFIX)/lib
|
||||
INSTALL_INC= $(PREFIX)/include
|
||||
INSTALL_MAN= $(PREFIX)/share/man
|
||||
|
||||
# Compilateur
|
||||
CC = $(TOOLCHAIN_BIN)/mips-openwrt-linux-gcc
|
||||
|
||||
# Commandes d'installation et de désinstallation
|
||||
RM=rm -fv
|
||||
CP=cp -v
|
||||
|
||||
# Cible
|
||||
TARGET=owlps-client
|
||||
HEADER=
|
||||
|
||||
# Flags
|
||||
CFLAGS = -O2 -Wall -Wextra -Wstrict-prototypes -I.
|
||||
DEPFLAGS = -MMD
|
||||
XCFLAGS = $(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS)
|
||||
PICFLAG = -fPIC
|
||||
LOWLPS = -L../../libowlps -lowlps
|
||||
LOWLPSA = ../../libowlps/libowlps.a
|
||||
LOWLPSCLIENTA = ../libowlps-client/libowlps-client.a
|
||||
LIBS = $(LOWLPSCLIENTA) -liw -lm
|
||||
DYNAMIC_LIBS = $(LOWLPS) $(LIBS)
|
||||
SEMISTATIC_LIBS = $(LOWLPSA) $(LIBS)
|
||||
STATIC_LIBS = $(LOWLPSA) $(LIBS)
|
||||
LATHEROS = -L$(TOOLCHAIN_USR)/lib -L$(TOOLCHAIN_USR_2)/lib
|
||||
IATHEROS = -I$(TOOLCHAIN_USR)/include -I$(TOOLCHAIN_USR_2)/include
|
||||
LDFLAGS = $(IATHEROS) $(LATHEROS)
|
||||
|
||||
|
||||
## Cibles de compilation standard ##
|
||||
|
||||
.PHONY: all dynamic semistatic static install uninstall clean purge help
|
||||
|
||||
dynamic: $(TARGET)
|
||||
semistatic: $(TARGET).semistatic
|
||||
static: $(TARGET).static
|
||||
all: dynamic semistatic static
|
||||
|
||||
# Cancel implicit make rule
|
||||
%: %.c
|
||||
|
||||
%: %.o
|
||||
$(CC) $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ $(LDFLAGS) $(DYNAMIC_LIBS)
|
||||
|
||||
%.semistatic: %.o
|
||||
$(CC) $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ $(LDFLAGS) $(SEMISTATIC_LIBS)
|
||||
|
||||
%.static: %.o
|
||||
$(CC) $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ $(LDFLAGS) $(STATIC_LIBS) \
|
||||
-static
|
||||
|
||||
%.o: %.c $(HEADER)
|
||||
$(CC) $(XCFLAGS) $(IATHEROS) $(OWLPSFLAGS) -c $<
|
||||
|
||||
|
||||
## Installation / désinstallation ##
|
||||
|
||||
install : $(TARGET)
|
||||
@$(CP) $(TARGET) $(INSTALL_DIR)
|
||||
@cd $(INSTALL_DIR) ; chown root:root $(TARGET) ; chmod 755 $(TARGET)
|
||||
|
||||
uninstall :
|
||||
@$(RM) $(INSTALL_DIR)/$(TARGET)
|
||||
|
||||
|
||||
## Nettoyage ##
|
||||
|
||||
clean :
|
||||
@$(RM) -fv *~ *.o *.d
|
||||
|
||||
purge : clean
|
||||
@$(RM) -fv $(TARGET) $(TARGET).static $(TARGET).semistatic
|
||||
|
||||
|
||||
## Aide ##
|
||||
|
||||
help :
|
||||
@echo -e "Bibliothèques nécessaires à la compilation :\n\
|
||||
libowlps1.0 (fournie)\n\
|
||||
\n\
|
||||
Cibles possibles :\n\
|
||||
$(TARGET) (cible par défaut) : Compile le programme $(TARGET).\n\
|
||||
$(TARGET).static : Compile le programme $(TARGET).static \
|
||||
(version sans lien dynamique).\n\
|
||||
$(TARGET).semistatic : Compile le programme $(TARGET).semistatic \
|
||||
(version sans lien dynamique vers libowlps).\n\
|
||||
install : Installe le programme $(TARGET).\n\
|
||||
uninstall : Désinstalle le programme $(TARGET).\n\
|
||||
clean : Supprime les fichiers temporaires.\n\
|
||||
purge : Supprime le résultat de la compilation.\n\
|
||||
\n\
|
||||
Note : l'installation se fait dans l'arborescence $(PREFIX). \
|
||||
Modifiez la variable PREFIX du Makefile pour changer ce comportement."
|
|
@ -45,17 +45,17 @@ LDFLAGS = $(IATHEROS) $(LATHEROS)
|
|||
|
||||
.PHONY: all semistatic static install uninstall clean purge help
|
||||
|
||||
semistatic: $(TARGET)-drone
|
||||
semistatic: $(TARGET)
|
||||
static: $(TARGET).static
|
||||
all: semistatic static
|
||||
|
||||
# Cancel implicit make rule
|
||||
%: %.c
|
||||
|
||||
%: %.o
|
||||
$(CC) $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ $(LDFLAGS) $(DYNAMIC_LIBS)
|
||||
#%: %.o
|
||||
# $(CC) $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ $(LDFLAGS) $(DYNAMIC_LIBS)
|
||||
|
||||
%-drone: %.o
|
||||
%: %.o
|
||||
$(CC) $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ $(LDFLAGS) $(SEMISTATIC_LIBS)
|
||||
|
||||
%.static: %.o
|
||||
|
|
|
@ -3,8 +3,19 @@
|
|||
*/
|
||||
|
||||
#include "../libowlps-client/owlps-client.h"
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <inttypes.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <net/if.h>
|
||||
|
||||
#include <time.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#define DEBUG
|
||||
|
||||
/* Error codes */
|
||||
|
@ -43,14 +54,14 @@ void* thread_send(void*) ;
|
|||
/* Options */
|
||||
struct timespec timestamp ;
|
||||
struct {
|
||||
char dest_ip[16] ; // Destination IP of the packets
|
||||
char dest_ip[INET_ADDRSTRLEN] ; // Destination IP of the packets
|
||||
uint_fast16_t dest_port ;
|
||||
char iface[IFNAMSIZ + 1] ; // Source network interface
|
||||
int_fast32_t delay ; // Time between two packet transmissions
|
||||
uint_fast16_t nb_pkt ; // Number of packets to send
|
||||
uint_fast16_t listening_port ;
|
||||
// Calibration data:
|
||||
DIRECTION direction ;
|
||||
owl_direction direction ;
|
||||
float x ;
|
||||
float y ;
|
||||
float z ;
|
||||
|
@ -68,7 +79,7 @@ char *program_name = NULL ;
|
|||
|
||||
// TRUE if the packet is a calibration request, FALSE if it is a simple
|
||||
// positioning request:
|
||||
BOOL is_calibration_request = FALSE ;
|
||||
owl_bool is_calibration_request = FALSE ;
|
||||
|
||||
int socksendfd ; // Sending socket descriptor (send positioning packets)
|
||||
int sockreceivefd ; // Receiving socket descriptor (Receive position)
|
||||
|
@ -131,7 +142,7 @@ void parse_main_options(int argc, char **argv)
|
|||
switch (opt)
|
||||
{
|
||||
case 'd' :
|
||||
strncpy(options.dest_ip, optarg, 16) ;
|
||||
strncpy(options.dest_ip, optarg, INET_ADDRSTRLEN) ;
|
||||
break ;
|
||||
case 'h' :
|
||||
print_usage() ;
|
||||
|
@ -242,6 +253,16 @@ void check_configuration()
|
|||
else
|
||||
options.nb_pkt = DEFAULT_NBPKT_NORMAL ;
|
||||
}
|
||||
|
||||
// Calibration request but bad direction
|
||||
if (is_calibration_request)
|
||||
if (options.direction < OWL_DIRECTION_MIN ||
|
||||
options.direction > OWL_DIRECTION_MAX)
|
||||
{
|
||||
fprintf(stderr, "Error! « %"PRIu8" » is not a valid"
|
||||
" direction.\n", options.direction) ;
|
||||
exit(ERR_BAD_USAGE) ;
|
||||
}
|
||||
|
||||
// Check port numbers
|
||||
if (options.dest_port < 1 || options.dest_port > 65535)
|
||||
|
@ -327,8 +348,8 @@ void create_socket()
|
|||
void make_packet()
|
||||
{
|
||||
uint_fast16_t offset ; // Index used to create the packet
|
||||
TIMESTAMP request_time ;
|
||||
char request_time_str[TIMESTAMP_STR_LEN] ;
|
||||
owl_timestamp request_time ;
|
||||
char request_time_str[OWL_TIMESTAMP_STR_LEN] ;
|
||||
|
||||
// Get the current time and copy it as a string before to switch it to
|
||||
// network endianess:
|
||||
|
@ -342,10 +363,10 @@ void make_packet()
|
|||
|
||||
offset = 0 ;
|
||||
packet_size =
|
||||
sizeof(uint8_t) * 2 + sizeof(TIMESTAMP) + sizeof(float) * 3 ;
|
||||
sizeof(uint8_t) * 2 + sizeof(owl_timestamp) + sizeof(float) * 3 ;
|
||||
packet = malloc(packet_size) ;
|
||||
|
||||
memset(&packet[offset], PACKET_TYPE_CALIBRATION, 1) ; // Packet type
|
||||
memset(&packet[offset], OWL_REQUEST_CALIBRATION, 1) ; // Packet type
|
||||
++offset ;
|
||||
memcpy(&packet[offset], &request_time, sizeof(request_time)) ;
|
||||
offset += sizeof(request_time) ;
|
||||
|
@ -364,9 +385,9 @@ void make_packet()
|
|||
else // Standard packet
|
||||
{
|
||||
printf("Preparing request packet…\n") ;
|
||||
packet_size = sizeof(uint8_t) + sizeof(TIMESTAMP) ;
|
||||
packet_size = sizeof(uint8_t) + sizeof(owl_timestamp) ;
|
||||
packet = malloc(packet_size) ;
|
||||
memset(&packet[0], PACKET_TYPE_NORMAL, 1) ; // Packet type
|
||||
memset(&packet[0], OWL_REQUEST_NORMAL, 1) ; // Packet type
|
||||
memcpy(&packet[1], &request_time, sizeof(request_time)) ;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue