From 9eb3e02b2c3234868e6ef6ead0853ae5ba7f3a6c Mon Sep 17 00:00:00 2001 From: Florian Taillard Date: Tue, 5 Apr 2011 17:23:28 +0200 Subject: [PATCH] [ARDrone] Update owlps-drone to new format Receive and processing a new format of message string. Add owlps-drone.h for prototype. --- owlps-ardrone/owlps-drone.c | 76 +++++++++++++++++++++++++++++++------ owlps-ardrone/owlps-drone.h | 11 ++++++ 2 files changed, 76 insertions(+), 11 deletions(-) create mode 100644 owlps-ardrone/owlps-drone.h diff --git a/owlps-ardrone/owlps-drone.c b/owlps-ardrone/owlps-drone.c index cf018a2..4d4b482 100644 --- a/owlps-ardrone/owlps-drone.c +++ b/owlps-ardrone/owlps-drone.c @@ -3,7 +3,7 @@ */ #include "../libowlps-client/owlps-client.h" - +#include "owlps-drone.h" #include #include @@ -407,42 +407,95 @@ void send_request() void receive_position() { // Position of the mobile as computed by the infrastructure: - char timestampXYZ[50] ; - recvfrom(sockreceivefd, ×tampXYZ, 50, 0, NULL, NULL) ; + char timestampXYZ[128] ; + recvfrom(sockreceivefd, ×tampXYZ, 128, 0, NULL, NULL) ; //printf("%s", timestampXYZ) ; - send_labview(timestampXYZ) ; + //send_labview(timestampXYZ) ; string2data(timestampXYZ) ; } void string2data(char* string_data) { - float x, y, z = 0.0 ; - int i = 0 ; + char *mac = NULL ; + int type_req ; + int i ; + int y ; char *ptr= NULL ; char *delims = ";" ; - ptr = strtok(string_data, ".") ; + //Lecture Adresse Mac + ptr = strtok(string_data, delims) ; + mac = ptr ; + + //Lecture Type Request + ptr = strtok(NULL, delims) ; + type_req = atoi(ptr) ; + + //Lecture TimeStamp1 + ptr = strtok(NULL, ".") ; sscanf(ptr, "%ld", ×tamp.tv_sec) ; + + //Lecture TimeStamp2 ptr = strtok(NULL, ";") ; sscanf(ptr, "%ld", ×tamp.tv_nsec) ; + + result results[10]; + i=0; + while(1) + { + ptr = strtok(NULL, delims) ; + if(ptr==NULL) break; + sscanf(ptr, "%s", results[i].algo) ; + ptr = strtok(NULL, delims) ; + if(ptr==NULL) break; + results[i].x = atof(ptr) ; + ptr = strtok(NULL, delims) ; + if(ptr==NULL) break; + results[i].y = atof(ptr) ; + ptr = strtok(NULL, delims) ; + if(ptr==NULL) break; + results[i].z = atof(ptr) ; + i++; + } + for(y=0;y +#define ALGO_STRLEN 15 + +typedef struct result result; +struct result +{ + char algo[ALGO_STRLEN]; + float x; + float y; + float z; +};