Skip to content
Snippets Groups Projects
Commit adbdea1c authored by burneykb's avatar burneykb
Browse files

ready to test

parent a69cb0b7
No related branches found
No related tags found
No related merge requests found
...@@ -694,11 +694,11 @@ static void client_recv(int fd) { ...@@ -694,11 +694,11 @@ static void client_recv(int fd) {
} }
} }
printf("packet = '"); // printf("packet = '");
for(int i = 0; i < (int)psize; ++i) { // for(int i = 0; i < (int)psize; ++i) {
printf(" %.2x ", packet[i]); // printf(" %.2x ", packet[i]);
} // }
printf("'\n"); // printf("'\n");
writeQuad(packet, psize); writeQuad(packet, psize);
...@@ -733,7 +733,7 @@ static void quad_recv() { ...@@ -733,7 +733,7 @@ static void quad_recv() {
// printf("packet = '"); // printf("packet = '");
// for(int i = 0; i < (int)respBufLen; ++i) { // for(int i = 0; i < (int)respBufLen; ++i) {
// printf(" 0x%.2x ", respBuf[i]); // printf(" %.2x ", respBuf[i]);
// } // }
// printf("'\n"); // printf("'\n");
...@@ -760,7 +760,6 @@ static void quad_recv() { ...@@ -760,7 +760,6 @@ static void quad_recv() {
respBufLen -=i; respBufLen -=i;
return; return;
} }
} }
respBufLen = 0; respBufLen = 0;
return; return;
...@@ -777,7 +776,6 @@ static void quad_recv() { ...@@ -777,7 +776,6 @@ static void quad_recv() {
switch (m.msg_type) { switch (m.msg_type) {
case DEBUG_ID : case DEBUG_ID :
printf();
case PACKETLOG_ID : case PACKETLOG_ID :
case GETPACKETLOGS_ID : case GETPACKETLOGS_ID :
case UPDATE_ID : case UPDATE_ID :
...@@ -814,12 +812,12 @@ static void handleResponseParam(struct metadata *m, uint8_t * data) ...@@ -814,12 +812,12 @@ static void handleResponseParam(struct metadata *m, uint8_t * data)
warnx("DecodeResponse error"); warnx("DecodeResponse error");
return; return;
} }
char buffer[128]; char buffer[128];
const char * message = cmToString(RESPPARAM_ID, &cm); const char * message = cmToString(RESPPARAM_ID, &cm);
size_t len = snprintf(buffer, 128, "%s %f\n", message, cm.value); size_t len = snprintf(buffer, 128, "%s %f\n", message, cm.value);
printf("response = %s\n", buffer);
for(int fd = 0; fd <= max_fd; ++fd) { for(int fd = 0; fd <= max_fd; ++fd) {
if (get_client_index(fd) > -1) { if (get_client_index(fd) > -1) {
......
...@@ -57,21 +57,30 @@ const char * setParamStrings[MAX_PARAM_COMMANDS] = { ...@@ -57,21 +57,30 @@ const char * setParamStrings[MAX_PARAM_COMMANDS] = {
"setlatp", "setlatp",
"setlati", "setlati",
"setlatd", "setlatd",
"setlat",
"setlongp", "setlongp",
"setlongi", "setlongi",
"setlongd", "setlongd",
"setlong",
"setheightp", "setheightp",
"setheighti", "setheighti",
"setheightd", "setheightd",
"setlat",
"setlong",
"setheight", "setheight",
}; };
const char * cmToString(int msgType, const struct controller_message *cm) const char * cmToString(int msgType, const struct controller_message *cm)
{ {
size_t index = (cm->id * MAX_CONTROL_PARAM_ID) + cm->value_id; size_t index;
if (cm->id == X_SETPOINT_ID) {
index = PARAM_LOCAL_X; // This will change when we make node structure changes
} else if (cm->id == X_SETPOINT_ID) {
index = PARAM_LOCAL_Y; // This will change when we make node structure changes
} else if (cm->id == X_SETPOINT_ID) {
index = PARMA_ALT; // This will change when we make node structure changes
} else {
index = (cm->id * MAX_CONTROL_PARAM_ID) + cm->value_id;
printf("index = %lu\n", index);
}
switch (msgType) { switch (msgType) {
case DEBUG_ID : case DEBUG_ID :
case PACKETLOG_ID : case PACKETLOG_ID :
...@@ -148,39 +157,29 @@ struct controller_message * stringToCm(const char * string, struct controller_me ...@@ -148,39 +157,29 @@ struct controller_message * stringToCm(const char * string, struct controller_me
} else if (i <= PARAM_YAW_RATE_D) { } else if (i <= PARAM_YAW_RATE_D) {
cm->id = YAW_RATE_ID; cm->id = YAW_RATE_ID;
} else if (i <= PARAM_LOCAL_X) { } else if (i <= PARAM_LOCAL_X_D) {
// If setpoint command, change the cm->valueid and cm
if (i == PARAM_LOCAL_X) { cm->id = LOCAL_X_ID;
cm->id = X_SETPOINT_ID; } else if (i <= PARAM_LOCAL_Y_D) {
cm->value_id = 0;
} else { cm->id = LOCAL_Y_ID;
// these have a slightly different value id offset } else if (i <= PARAM_ALT_D) {
cm->id = LOCAL_X_ID;
cm->value_id = MAX_CONTROL_PARAM_ID - (PARAM_LOCAL_X - i); cm->id = ALT_ID;
} } else if ( i == PARAM_LOCAL_X) {
} else if (i <= PARAM_LOCAL_Y) {
// If setpoint command, change the cm->valueid and cm cm->id = X_SETPOINT_ID;
if (i == PARAM_LOCAL_Y) { cm->value_id = 0;
cm->id = Y_SETPOINT_ID; } else if ( i == PARAM_LOCAL_Y) {
cm->value_id = 0;
} else { cm->id = Y_SETPOINT_ID;
// these have a slightly different value id offset cm->value_id = 0;
cm->id = LOCAL_Y_ID; } else if ( i == PARAM_ALT) {
cm->value_id = MAX_CONTROL_PARAM_ID - (PARAM_LOCAL_Y - i);
cm->id = ALT_SETPOINT_ID;
} cm->value_id = 0;
} else if (i <= PARAM_ALT) {
// If setpoint command, change the cm->valueid and cm
if (i == PARAM_ALT) {
cm->id = ALT_SETPOINT_ID;
cm->value_id = 0;
} else {
// these have a slightly different value id offset
cm->id = ALT_ID;
cm->value_id = MAX_CONTROL_PARAM_ID - (PARAM_ALT - i);
}
} }
} }
// printf("cm->id = %d\ncm->value_id = %d\n", cm->id, cm->value_id);
return cm; return cm;
} }
\ No newline at end of file
...@@ -25,14 +25,14 @@ enum paramIndices { ...@@ -25,14 +25,14 @@ enum paramIndices {
PARAM_LOCAL_X_P , PARAM_LOCAL_X_P ,
PARAM_LOCAL_X_I , PARAM_LOCAL_X_I ,
PARAM_LOCAL_X_D , PARAM_LOCAL_X_D ,
PARAM_LOCAL_X ,
PARAM_LOCAL_Y_P , PARAM_LOCAL_Y_P ,
PARAM_LOCAL_Y_I , PARAM_LOCAL_Y_I ,
PARAM_LOCAL_Y_D , PARAM_LOCAL_Y_D ,
PARAM_LOCAL_Y ,
PARAM_ALT_P, PARAM_ALT_P,
PARAM_ALT_I, PARAM_ALT_I,
PARAM_ALT_D, PARAM_ALT_D,
PARAM_LOCAL_X ,
PARAM_LOCAL_Y ,
PARAM_ALT , PARAM_ALT ,
MAX_PARAM_COMMANDS MAX_PARAM_COMMANDS
}; };
......
...@@ -114,6 +114,7 @@ int getSetPointValues(struct backend_conn * conn, struct frontend_setpoint_data ...@@ -114,6 +114,7 @@ int getSetPointValues(struct backend_conn * conn, struct frontend_setpoint_data
case LONGG : case LONGG :
printf("Longitude: %f\n", printf("Longitude: %f\n",
setpoint_data->longg); setpoint_data->longg);
break;
case PITCH : case PITCH :
printf("Pitch: %f\n", printf("Pitch: %f\n",
setpoint_data->pitch); setpoint_data->pitch);
...@@ -121,9 +122,11 @@ int getSetPointValues(struct backend_conn * conn, struct frontend_setpoint_data ...@@ -121,9 +122,11 @@ int getSetPointValues(struct backend_conn * conn, struct frontend_setpoint_data
case ROLL : case ROLL :
printf("Roll: %f\n", printf("Roll: %f\n",
setpoint_data->roll); setpoint_data->roll);
break;
case YAW : case YAW :
printf("Yaw: %f\n", printf("Yaw: %f\n",
setpoint_data->yaw); setpoint_data->yaw);
break;
default : default :
break; break;
} }
......
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <err.h>
#include "frontend_getsetpoint.h" #include "frontend_getsetpoint.h"
#include "setpoint_common.h" #include "setpoint_common.h"
...@@ -48,5 +49,46 @@ int frontend_getsetpoint( ...@@ -48,5 +49,46 @@ int frontend_getsetpoint(
return 1; return 1;
} }
char * response;
char tmpresponse[64];
char * cmdString;
size_t pendingResponses = 1;
float value;
while (pendingResponses) {
response = ucart_backendGetline(conn);
if (response == NULL) {
warnx("Line not returned from backend");
return 1;
}
strncpy(tmpresponse, response, 64);
if (strncmp(tmpresponse, "get", 3) == 0) {
cmdString = strtok(tmpresponse, " ");
value = strtof(&response[strlen(cmdString)],NULL);
switch (type) {
case HEIGHT :
setpoint_data->height = value;
break;
case LAT :
setpoint_data->lat = value;
break;
case LONGG :
setpoint_data->longg = value;
break;
case PITCH :
setpoint_data->pitch = value;
break;
case ROLL :
setpoint_data->roll = value;
break;
case YAW :
setpoint_data->yaw = value;
break;
}
pendingResponses--;
}
}
return 0; return 0;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment