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

Working on cli frontend to backend communication

parent 9fd96180
No related branches found
No related tags found
No related merge requests found
...@@ -221,31 +221,7 @@ int main(int argc, char **argv) ...@@ -221,31 +221,7 @@ int main(int argc, char **argv)
} }
if (fd == fileno(stdin)) { if (fd == fileno(stdin)) {
// break;
// unsigned char userCommand[CMD_MAX_LENGTH];
// read(fileno(stdin), (char *)userCommand, sizeof(userCommand));
// unsigned int cmdLen = strlen((char*) userCommand);
// // if the user simply hit enter then let them try again
// if((userCommand[0] != '\n') && (userCommand[0] != '\r'))
// {
// // remove newline and return line chars
// if((userCommand[cmdLen - 1] == '\n') || (userCommand[cmdLen - 1] == '\r'))
// userCommand[cmdLen - 1] = '\0';
// unsigned char *packet;
// formatCommand(userCommand, &packet);
// printf("received input from cli: '%s'\n", userCommand);
// // Write the command to the control_loop socket
// // int n = writeQuad(packet, ((packet[6] << 8) | packet[5]) + 8);
// // if(n < 0) {
// // printf("CLI: ERROR writing to socket\n");
// // }
// }
// printf("$microcart> ");
// memset(userCommand, 0, cmdLen);
} else if (fd == zyboSocket) { } else if (fd == zyboSocket) {
// Read the response from the control loop // Read the response from the control loop
int available; int available;
...@@ -281,6 +257,7 @@ int main(int argc, char **argv) ...@@ -281,6 +257,7 @@ int main(int argc, char **argv)
} }
} }
} else if (get_client_index(fd) > -1) { } else if (get_client_index(fd) > -1) {
printf("receiving from client\n");
client_recv(fd); client_recv(fd);
} }
} }
......
...@@ -55,7 +55,7 @@ struct MessageType MessageTypes[MAX_TYPE] = ...@@ -55,7 +55,7 @@ struct MessageType MessageTypes[MAX_TYPE] =
// Type of the command data // Type of the command data
floatType, floatType,
// Function pointer // Function pointer
&yawset &setyaw
}, },
// yaw p constant subtype // yaw p constant subtype
{ {
...@@ -66,7 +66,7 @@ struct MessageType MessageTypes[MAX_TYPE] = ...@@ -66,7 +66,7 @@ struct MessageType MessageTypes[MAX_TYPE] =
// Type of the command data // Type of the command data
floatType, floatType,
// Function pointer // Function pointer
&yawp &setyawp
}, },
// yaw d constant subtype // yaw d constant subtype
{ {
...@@ -77,7 +77,7 @@ struct MessageType MessageTypes[MAX_TYPE] = ...@@ -77,7 +77,7 @@ struct MessageType MessageTypes[MAX_TYPE] =
// Type of the command data // Type of the command data
floatType, floatType,
// Function pointer // Function pointer
&yawd &setyawd
}, },
// roll setpoint subtype // roll setpoint subtype
{ {
...@@ -88,7 +88,7 @@ struct MessageType MessageTypes[MAX_TYPE] = ...@@ -88,7 +88,7 @@ struct MessageType MessageTypes[MAX_TYPE] =
// Type of the command data // Type of the command data
floatType, floatType,
// Function pointer // Function pointer
&rollset &setroll
}, },
// roll p constant subtype // roll p constant subtype
{ {
...@@ -99,7 +99,7 @@ struct MessageType MessageTypes[MAX_TYPE] = ...@@ -99,7 +99,7 @@ struct MessageType MessageTypes[MAX_TYPE] =
// Type of the command data // Type of the command data
floatType, floatType,
// Function pointer // Function pointer
&rollp &setrollp
}, },
// roll d constant subtype // roll d constant subtype
{ {
...@@ -110,7 +110,7 @@ struct MessageType MessageTypes[MAX_TYPE] = ...@@ -110,7 +110,7 @@ struct MessageType MessageTypes[MAX_TYPE] =
// Type of the command data // Type of the command data
floatType, floatType,
// Function pointer // Function pointer
&rolld &setrolld
}, },
// pitch setpoint subtype // pitch setpoint subtype
{ {
...@@ -121,7 +121,7 @@ struct MessageType MessageTypes[MAX_TYPE] = ...@@ -121,7 +121,7 @@ struct MessageType MessageTypes[MAX_TYPE] =
// Type of the command data // Type of the command data
floatType, floatType,
// Function pointer // Function pointer
&pitchset &setpitch
}, },
// pitch p constant subtype // pitch p constant subtype
{ {
...@@ -132,7 +132,7 @@ struct MessageType MessageTypes[MAX_TYPE] = ...@@ -132,7 +132,7 @@ struct MessageType MessageTypes[MAX_TYPE] =
// Type of the command data // Type of the command data
floatType, floatType,
// Function pointer // Function pointer
&pitchp &setpitchp
}, },
// pitch d constant subtype // pitch d constant subtype
{ {
...@@ -143,7 +143,7 @@ struct MessageType MessageTypes[MAX_TYPE] = ...@@ -143,7 +143,7 @@ struct MessageType MessageTypes[MAX_TYPE] =
// Type of the command data // Type of the command data
floatType, floatType,
// Function pointer // Function pointer
&pitchd &setpitchd
}, },
// throttle setpoint subtype // throttle setpoint subtype
{ {
...@@ -154,7 +154,7 @@ struct MessageType MessageTypes[MAX_TYPE] = ...@@ -154,7 +154,7 @@ struct MessageType MessageTypes[MAX_TYPE] =
// Type of the command data // Type of the command data
floatType, floatType,
// Function pointer // Function pointer
&throttleset &setthrottle
}, },
// throttle p constant subtype // throttle p constant subtype
{ {
...@@ -165,7 +165,7 @@ struct MessageType MessageTypes[MAX_TYPE] = ...@@ -165,7 +165,7 @@ struct MessageType MessageTypes[MAX_TYPE] =
// Type of the command data // Type of the command data
floatType, floatType,
// Function pointer // Function pointer
&throttlep &setthrottlep
}, },
// throttle i constant subtype // throttle i constant subtype
{ {
...@@ -176,7 +176,7 @@ struct MessageType MessageTypes[MAX_TYPE] = ...@@ -176,7 +176,7 @@ struct MessageType MessageTypes[MAX_TYPE] =
// Type of the command data // Type of the command data
floatType, floatType,
// Function pointer // Function pointer
&throttlei &setthrottlei
}, },
// throttle d constant subtype // throttle d constant subtype
{ {
...@@ -187,7 +187,7 @@ struct MessageType MessageTypes[MAX_TYPE] = ...@@ -187,7 +187,7 @@ struct MessageType MessageTypes[MAX_TYPE] =
// Type of the command data // Type of the command data
floatType, floatType,
// Function pointer // Function pointer
&throttled &getthrottled
} }
} }
}, },
...@@ -204,44 +204,187 @@ struct MessageType MessageTypes[MAX_TYPE] = ...@@ -204,44 +204,187 @@ struct MessageType MessageTypes[MAX_TYPE] =
// ID // ID
0x00, 0x00,
// Command text // Command text
"accelreq", "getaccel",
// Type of the command data // Type of the command data
floatType, floatType,
// Function pointer // Function pointer
&accelreq &getaccel
}, },
// gyroscope subtype // gyroscope subtype
{ {
// ID // ID
0x01, 0x01,
// Command text // Command text
"gyroreq", "getgyro",
// Type of the command data // Type of the command data
floatType, floatType,
// Function pointer // Function pointer
&gyroreq &getgyro
}, },
// pitch angle subtype // pitch angle subtype
{ {
// ID // ID
0x02, 0x02,
// Command text // Command text
"reqpitchangle", "getpitchangle",
// Type of the command data // Type of the command data
floatType, floatType,
// Function pointer // Function pointer
&pitchanglereq &getpitchangle
}, },
// roll angle subtype // roll angle subtype
{ {
// ID // ID
0x03, 0x03,
// Command text // Command text
"reqrollangle", "getrollangle",
// Type of the command data // Type of the command data
floatType, floatType,
// Function pointer // Function pointer
&rollanglereq &getrollangle
},
// get yaw setpoint subtype
{
// ID
0x04,
// Command text
"getyaw",
// Type of the command data
floatType,
// Function pointer
&setyaw
},
// get yaw p constant subtype
{
// ID
0x05,
// Command text
"getyawp",
// Type of the command data
floatType,
// Function pointer
&getyawp
},
// get yaw d constant subtype
{
// ID
0x06,
// Command text
"getyawd",
// Type of the command data
floatType,
// Function pointer
&getyawd
},
// get roll setpoint subtype
{
// ID
0x07,
// Command text
"getroll",
// Type of the command data
floatType,
// Function pointer
&getroll
},
// get roll p constant subtype
{
// ID
0x08,
// Command text
"getrollp",
// Type of the command data
floatType,
// Function pointer
&getrollp
},
// getroll d constant subtype
{
// ID
0x09,
// Command text
"getrolld",
// Type of the command data
floatType,
// Function pointer
&getrolld
},
// get pitch setpoint subtype
{
// ID
0x0A,
// Command text
"getpitch",
// Type of the command data
floatType,
// Function pointer
&getpitch
},
// get pitch p constant subtype
{
// ID
0x0B,
// Command text
"getpitchp",
// Type of the command data
floatType,
// Function pointer
&getpitchp
},
// get pitch d constant subtype
{
// ID
0x0C,
// Command text
"getpitchd",
// Type of the command data
floatType,
// Function pointer
&getpitchd
},
// get throttle setpoint subtype
{
// ID
0x0D,
// Command text
"getthrottle",
// Type of the command data
floatType,
// Function pointer
&getthrottle
},
// get throttle p constant subtype
{
// ID
0x0E,
// Command text
"getthrottlep",
// Type of the command data
floatType,
// Function pointer
&getthrottlep
},
// get throttle i constant subtype
{
// ID
0x0F,
// Command text
"getthrottlei",
// Type of the command data
floatType,
// Function pointer
&getthrottlei
},
// get throttle d constant subtype
{
// ID
0x10,
// Command text
"getthrottled",
// Type of the command data
floatType,
// Function pointer
&getthrottled
} }
} }
}, },
...@@ -262,7 +405,7 @@ struct MessageType MessageTypes[MAX_TYPE] = ...@@ -262,7 +405,7 @@ struct MessageType MessageTypes[MAX_TYPE] =
// Type of the command data // Type of the command data
floatType, floatType,
// Function pointer // Function pointer
&accelresp &respaccel
}, },
// gyroscope subtype // gyroscope subtype
{ {
...@@ -273,7 +416,7 @@ struct MessageType MessageTypes[MAX_TYPE] = ...@@ -273,7 +416,7 @@ struct MessageType MessageTypes[MAX_TYPE] =
// Type of the command data // Type of the command data
floatType, floatType,
// Function pointer // Function pointer
&gyroresp &respgyro
}, },
// pitch angle subtype // pitch angle subtype
{ {
...@@ -284,7 +427,7 @@ struct MessageType MessageTypes[MAX_TYPE] = ...@@ -284,7 +427,7 @@ struct MessageType MessageTypes[MAX_TYPE] =
// Type of the command data // Type of the command data
floatType, floatType,
// Function pointer // Function pointer
&pitchangleresp &resppitchangle
}, },
// roll angle subtype // roll angle subtype
{ {
...@@ -295,7 +438,7 @@ struct MessageType MessageTypes[MAX_TYPE] = ...@@ -295,7 +438,7 @@ struct MessageType MessageTypes[MAX_TYPE] =
// Type of the command data // Type of the command data
floatType, floatType,
// Function pointer // Function pointer
&rollangleresp &resprollangle
} }
} }
}, },
...@@ -412,7 +555,7 @@ int response(unsigned char *packet, int dataLen, modular_structs_t *structs) ...@@ -412,7 +555,7 @@ int response(unsigned char *packet, int dataLen, modular_structs_t *structs)
// ------------------------------------------------------------------ // ------------------------------------------------------------------
int yawset(unsigned char *packet, int dataLen, modular_structs_t *structs) int setyaw(unsigned char *packet, int dataLen, modular_structs_t *structs)
{ {
float value; float value;
...@@ -422,203 +565,243 @@ int yawset(unsigned char *packet, int dataLen, modular_structs_t *structs) ...@@ -422,203 +565,243 @@ int yawset(unsigned char *packet, int dataLen, modular_structs_t *structs)
structs->setpoint_struct.desiredQuadPosition.yaw = value; structs->setpoint_struct.desiredQuadPosition.yaw = value;
printf("function for yawset: %f\n", structs->setpoint_struct.desiredQuadPosition.yaw); printf("function for setyaw: %f\n", structs->setpoint_struct.desiredQuadPosition.yaw);
return 0; return 0;
} }
int yawp(unsigned char *packet, int dataLen, modular_structs_t *structs) int setyawp(unsigned char *packet, int dataLen, modular_structs_t *structs)
{ {
float value; float value;
memcpy(&value, ((float *)packet), dataLen); memcpy(&value, ((float *)packet), dataLen);
structs->parameter_struct.yaw_angle_pid.Kp = value; structs->parameter_struct.yaw_angle_pid.Kp = value;
printf("function for yawp: %f\n", structs->parameter_struct.yaw_angle_pid.Kp); printf("function for setyawp: %f\n", structs->parameter_struct.yaw_angle_pid.Kp);
return 0; return 0;
} }
int yawd(unsigned char *packet, int dataLen, modular_structs_t *structs) int setyawd(unsigned char *packet, int dataLen, modular_structs_t *structs)
{ {
float value; float value;
memcpy(&value, ((float *)packet), dataLen); memcpy(&value, ((float *)packet), dataLen);
structs->parameter_struct.yaw_angle_pid.Kd = value; structs->parameter_struct.yaw_angle_pid.Kd = value;
printf("function for yawd: %f\n", structs->parameter_struct.yaw_angle_pid.Kd); printf("function for setyawd: %f\n", structs->parameter_struct.yaw_angle_pid.Kd);
return 0; return 0;
} }
int rollset(unsigned char *packet, int dataLen, modular_structs_t *structs) int setroll(unsigned char *packet, int dataLen, modular_structs_t *structs)
{ {
float value; float value;
memcpy(&value, ((float *)packet), dataLen); memcpy(&value, ((float *)packet), dataLen);
structs->setpoint_struct.desiredQuadPosition.roll = value; structs->setpoint_struct.desiredQuadPosition.roll = value;
printf("function for rollset: %f\n", structs->setpoint_struct.desiredQuadPosition.roll); printf("function for setroll: %f\n", structs->setpoint_struct.desiredQuadPosition.roll);
return 0; return 0;
} }
int rollp(unsigned char *packet, int dataLen, modular_structs_t *structs) int setrollp(unsigned char *packet, int dataLen, modular_structs_t *structs)
{ {
float value; float value;
memcpy(&value, ((float *)packet), dataLen); memcpy(&value, ((float *)packet), dataLen);
structs->parameter_struct.local_y_pid.Kp = value; structs->parameter_struct.local_y_pid.Kp = value;
printf("function for rollp: %f\n", structs->parameter_struct.local_y_pid.Kp); printf("function for setrollp: %f\n", structs->parameter_struct.local_y_pid.Kp);
return 0; return 0;
} }
int rolld(unsigned char *packet, int dataLen, modular_structs_t *structs) int setrolld(unsigned char *packet, int dataLen, modular_structs_t *structs)
{ {
float value; float value;
memcpy(&value, ((float *)packet), dataLen); memcpy(&value, ((float *)packet), dataLen);
structs->parameter_struct.local_y_pid.Kd = value; structs->parameter_struct.local_y_pid.Kd = value;
printf("function for rolld: %f\n", structs->parameter_struct.local_y_pid.Kd); printf("function for setrolld: %f\n", structs->parameter_struct.local_y_pid.Kd);
return 0; return 0;
} }
int pitchset(unsigned char *packet, int dataLen, modular_structs_t *structs) int setpitch(unsigned char *packet, int dataLen, modular_structs_t *structs)
{ {
float value; float value;
memcpy(&value, ((float *)packet), dataLen); memcpy(&value, ((float *)packet), dataLen);
structs->setpoint_struct.desiredQuadPosition.pitch = value; structs->setpoint_struct.desiredQuadPosition.pitch = value;
printf("function for pitchset: %f\n", structs->setpoint_struct.desiredQuadPosition.pitch); printf("function for setpitch: %f\n", structs->setpoint_struct.desiredQuadPosition.pitch);
return 0; return 0;
} }
int pitchp(unsigned char *packet, int dataLen, modular_structs_t *structs) int setpitchp(unsigned char *packet, int dataLen, modular_structs_t *structs)
{ {
float value; float value;
memcpy(&value, ((float *)packet), dataLen); memcpy(&value, ((float *)packet), dataLen);
structs->parameter_struct.local_x_pid.Kp = value; structs->parameter_struct.local_x_pid.Kp = value;
printf("function for pitchp: %f\n", structs->parameter_struct.local_x_pid.Kp); printf("function for setpitchp: %f\n", structs->parameter_struct.local_x_pid.Kp);
return 0; return 0;
} }
int pitchd(unsigned char *packet, int dataLen, modular_structs_t *structs) int setpitchd(unsigned char *packet, int dataLen, modular_structs_t *structs)
{ {
float value; float value;
memcpy(&value, ((float *)packet), dataLen); memcpy(&value, ((float *)packet), dataLen);
structs->parameter_struct.local_x_pid.Kd = value; structs->parameter_struct.local_x_pid.Kd = value;
printf("function for pitchd: %f\n", structs->parameter_struct.local_x_pid.Kd); printf("function for setpitchd: %f\n", structs->parameter_struct.local_x_pid.Kd);
return 0; return 0;
} }
// ------------------------------------------------------------ // ------------------------------------------------------------
// These should be renamed to altitude! // These should be renamed to altitude!
int throttleset(unsigned char *packet, int dataLen, modular_structs_t *structs) int setthrottle(unsigned char *packet, int dataLen, modular_structs_t *structs)
{ {
float value; float value;
memcpy(&value, ((float *)packet), dataLen); memcpy(&value, ((float *)packet), dataLen);
structs->setpoint_struct.desiredQuadPosition.alt_pos = value; structs->setpoint_struct.desiredQuadPosition.alt_pos = value;
printf("function for throttleset: %f\n", structs->setpoint_struct.desiredQuadPosition.alt_pos); printf("function for setthrottle: %f\n", structs->setpoint_struct.desiredQuadPosition.alt_pos);
return 0; return 0;
} }
int throttlep(unsigned char *packet, int dataLen, modular_structs_t *structs) int setthrottlep(unsigned char *packet, int dataLen, modular_structs_t *structs)
{ {
float value; float value;
memcpy(&value, ((float *)packet), dataLen); memcpy(&value, ((float *)packet), dataLen);
structs->parameter_struct.alt_pid.Kp = value; structs->parameter_struct.alt_pid.Kp = value;
printf("function for throttlep: %f\n", structs->parameter_struct.alt_pid.Kp); printf("function for setthrottlep: %f\n", structs->parameter_struct.alt_pid.Kp);
return 0; return 0;
} }
int throttlei(unsigned char *packet, int dataLen, modular_structs_t *structs) int setthrottlei(unsigned char *packet, int dataLen, modular_structs_t *structs)
{ {
float value; float value;
memcpy(&value, ((float *)packet), dataLen); memcpy(&value, ((float *)packet), dataLen);
structs->parameter_struct.alt_pid.Ki = value; structs->parameter_struct.alt_pid.Ki = value;
printf("function for throttlei: %f\n", structs->parameter_struct.alt_pid.Ki); printf("function for setthrottlei: %f\n", structs->parameter_struct.alt_pid.Ki);
return 0; return 0;
} }
int throttled(unsigned char *packet, int dataLen, modular_structs_t *structs) int setthrottled(unsigned char *packet, int dataLen, modular_structs_t *structs)
{ {
float value; float value;
memcpy(&value, ((float *)packet), dataLen); memcpy(&value, ((float *)packet), dataLen);
structs->parameter_struct.alt_pid.Kd = value; structs->parameter_struct.alt_pid.Kd = value;
printf("function for throttled: %f\n", structs->parameter_struct.alt_pid.Kd); printf("function for setthrottled: %f\n", structs->parameter_struct.alt_pid.Kd);
return 0; return 0;
} }
int getyaw(unsigned char *packet, int dataLen, modular_structs_t *structs){
return 0;
}
int getyawp(unsigned char *packet, int dataLen, modular_structs_t *structs){
return 0;
}
int getyawd(unsigned char *packet, int dataLen, modular_structs_t *structs) {
return 0;
}
int getroll(unsigned char *packet, int dataLen, modular_structs_t *structs){
return 0;
}
int getrollp(unsigned char *packet, int dataLen, modular_structs_t *structs){
return 0;
}
int getrolld(unsigned char *packet, int dataLen, modular_structs_t *structs){
return 0;
}
int getpitch(unsigned char *packet, int dataLen, modular_structs_t *structs){
return 0;
}
int getpitchp(unsigned char *packet, int dataLen, modular_structs_t *structs){
return 0;
}
int getpitchd(unsigned char *packet, int dataLen, modular_structs_t *structs){
return 0;
}
int getthrottle(unsigned char *packet, int dataLen, modular_structs_t *structs){
return 0;
}
int getthrottlep(unsigned char *packet, int dataLen, modular_structs_t *structs){
return 0;
}
int getthrottlei(unsigned char *packet, int dataLen, modular_structs_t *structs){
return 0;
}
int getthrottled(unsigned char *packet, int dataLen, modular_structs_t *structs){
return 0;
}
// These should be renamed to altitude! // These should be renamed to altitude!
// ------------------------------------------------------------ // ------------------------------------------------------------
int accelreq(unsigned char *packet, int dataLen, modular_structs_t *structs) int getaccel(unsigned char *packet, int dataLen, modular_structs_t *structs)
{ {
printf("function for accelreq\n"); printf("function for getaccel\n");
return 0; return 0;
} }
int gyroresp(unsigned char *packet, int dataLen, modular_structs_t *structs) int respgyro(unsigned char *packet, int dataLen, modular_structs_t *structs)
{ {
printf("function for accelreq\n"); printf("function for respgyro\n");
return 0; return 0;
} }
int pitchangleresp(unsigned char *packet, int dataLen, modular_structs_t *structs) int resppitchangle(unsigned char *packet, int dataLen, modular_structs_t *structs)
{ {
printf("function for accelreq\n"); printf("function for resppitchangle\n");
return 0; return 0;
} }
int rollangleresp(unsigned char *packet, int dataLen, modular_structs_t *structs) int resprollangle(unsigned char *packet, int dataLen, modular_structs_t *structs)
{ {
printf("function for accelreq\n"); printf("function for resprollangle\n");
return 0; return 0;
} }
int gyroreq(unsigned char *packet, int dataLen, modular_structs_t *structs) int getgyro(unsigned char *packet, int dataLen, modular_structs_t *structs)
{ {
printf("function for accelreq\n"); printf("function for getgyro\n");
return 0; return 0;
} }
int pitchanglereq(unsigned char *packet, int dataLen, modular_structs_t *structs) int getpitchangle(unsigned char *packet, int dataLen, modular_structs_t *structs)
{ {
printf("function for accelreq\n"); printf("function for getpitchangle\n");
return 0; return 0;
} }
int rollanglereq(unsigned char *packet, int dataLen, modular_structs_t *structs) int getrollangle(unsigned char *packet, int dataLen, modular_structs_t *structs)
{ {
printf("function for accelreq\n"); printf("function for getrollangle\n");
return 0; return 0;
} }
int accelresp(unsigned char *packet, int dataLen, modular_structs_t *structs) int respaccel(unsigned char *packet, int dataLen, modular_structs_t *structs)
{ {
printf("function for accelreq\n"); printf("function for respaccel\n");
return 0; return 0;
} }
\ No newline at end of file
...@@ -44,27 +44,40 @@ int debug(unsigned char *c, int dataLen, modular_structs_t *structs); ...@@ -44,27 +44,40 @@ int debug(unsigned char *c, int dataLen, modular_structs_t *structs);
int update(unsigned char *c, int dataLen, modular_structs_t *structs); int update(unsigned char *c, int dataLen, modular_structs_t *structs);
int logdata(unsigned char *c, int dataLen, modular_structs_t *structs); int logdata(unsigned char *c, int dataLen, modular_structs_t *structs);
int response(unsigned char *packet, int dataLen, modular_structs_t *structs); int response(unsigned char *packet, int dataLen, modular_structs_t *structs);
int yawset(unsigned char *c, int dataLen, modular_structs_t *structs); int setyaw(unsigned char *c, int dataLen, modular_structs_t *structs);
int yawp(unsigned char *c, int dataLen, modular_structs_t *structs); int setyawp(unsigned char *c, int dataLen, modular_structs_t *structs);
int yawd(unsigned char *c, int dataLen, modular_structs_t *structs); int setyawd(unsigned char *c, int dataLen, modular_structs_t *structs);
int rollset(unsigned char *c, int dataLen, modular_structs_t *structs); int setroll(unsigned char *c, int dataLen, modular_structs_t *structs);
int rollp(unsigned char *c, int dataLen, modular_structs_t *structs); int setrollp(unsigned char *c, int dataLen, modular_structs_t *structs);
int rolld(unsigned char *c, int dataLen, modular_structs_t *structs); int setrolld(unsigned char *c, int dataLen, modular_structs_t *structs);
int pitchset(unsigned char *c, int dataLen, modular_structs_t *structs); int setpitch(unsigned char *c, int dataLen, modular_structs_t *structs);
int pitchp(unsigned char *c, int dataLen, modular_structs_t *structs); int setpitchp(unsigned char *c, int dataLen, modular_structs_t *structs);
int pitchd(unsigned char *c, int dataLen, modular_structs_t *structs); int setpitchd(unsigned char *c, int dataLen, modular_structs_t *structs);
int throttleset(unsigned char *c, int dataLen, modular_structs_t *structs); int setthrottle(unsigned char *c, int dataLen, modular_structs_t *structs);
int throttlep(unsigned char *c, int dataLen, modular_structs_t *structs); int setthrottlep(unsigned char *c, int dataLen, modular_structs_t *structs);
int throttlei(unsigned char *c, int dataLen, modular_structs_t *structs); int setthrottlei(unsigned char *c, int dataLen, modular_structs_t *structs);
int throttled(unsigned char *c, int dataLen, modular_structs_t *structs); int setthrottled(unsigned char *c, int dataLen, modular_structs_t *structs);
int accelreq(unsigned char *c, int dataLen, modular_structs_t *structs); int getyaw(unsigned char *c, int dataLen, modular_structs_t *structs);
int gyroresp(unsigned char *c, int dataLen, modular_structs_t *structs); int getyawp(unsigned char *c, int dataLen, modular_structs_t *structs);
int pitchangleresp(unsigned char *c, int dataLen, modular_structs_t *structs); int getyawd(unsigned char *c, int dataLen, modular_structs_t *structs);
int rollangleresp(unsigned char *c, int dataLen, modular_structs_t *structs); int getroll(unsigned char *c, int dataLen, modular_structs_t *structs);
int gyroreq(unsigned char *c, int dataLen, modular_structs_t *structs); int getrollp(unsigned char *c, int dataLen, modular_structs_t *structs);
int pitchanglereq(unsigned char *c, int dataLen, modular_structs_t *structs); int getrolld(unsigned char *c, int dataLen, modular_structs_t *structs);
int rollanglereq(unsigned char *c, int dataLen, modular_structs_t *structs); int getpitch(unsigned char *c, int dataLen, modular_structs_t *structs);
int accelresp(unsigned char *c, int dataLen, modular_structs_t *structs); int getpitchp(unsigned char *c, int dataLen, modular_structs_t *structs);
int getpitchd(unsigned char *c, int dataLen, modular_structs_t *structs);
int getthrottle(unsigned char *c, int dataLen, modular_structs_t *structs);
int getthrottlep(unsigned char *c, int dataLen, modular_structs_t *structs);
int getthrottlei(unsigned char *c, int dataLen, modular_structs_t *structs);
int getthrottled(unsigned char *c, int dataLen, modular_structs_t *structs);
int getaccel(unsigned char *c, int dataLen, modular_structs_t *structs);
int respgyro(unsigned char *c, int dataLen, modular_structs_t *structs);
int resppitchangle(unsigned char *c, int dataLen, modular_structs_t *structs);
int resprollangle(unsigned char *c, int dataLen, modular_structs_t *structs);
int getgyro(unsigned char *c, int dataLen, modular_structs_t *structs);
int getpitchangle(unsigned char *c, int dataLen, modular_structs_t *structs);
int getrollangle(unsigned char *c, int dataLen, modular_structs_t *structs);
int respaccel(unsigned char *c, int dataLen, modular_structs_t *structs);
float getFloat(unsigned char* str, int pos); float getFloat(unsigned char* str, int pos);
int getInt(unsigned char* str, int pos); int getInt(unsigned char* str, int pos);
......
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <err.h> #include <err.h>
#include <unistd.h>
#include "cli.h" #include "cli.h"
...@@ -46,6 +47,7 @@ int main(int argc, char **argv) ...@@ -46,6 +47,7 @@ int main(int argc, char **argv)
}else { }else {
(*cli_functions[0]) (conn, argc-1, &argv[1]); (*cli_functions[0]) (conn, argc-1, &argv[1]);
} }
sleep(1);
ucart_backendDisconnect(conn); ucart_backendDisconnect(conn);
return 0; return 0;
......
...@@ -43,14 +43,12 @@ struct backend_conn * ucart_backendConnect() ...@@ -43,14 +43,12 @@ struct backend_conn * ucart_backendConnect()
goto fail_final; goto fail_final;
} }
conn = malloc(sizeof(struct backend_conn)); conn = malloc(sizeof(struct backend_conn));
if (conn == NULL) { if (conn == NULL) {
perror("malloc"); perror("malloc");
goto fail_sock; goto fail_sock;
} }
conn->len = 0; conn->len = 0;
conn->buf = NULL; conn->buf = NULL;
conn->socket = fdopen(s, "rw"); conn->socket = fdopen(s, "rw");
...@@ -86,7 +84,7 @@ char * ucart_backendGetline(struct backend_conn *conn) ...@@ -86,7 +84,7 @@ char * ucart_backendGetline(struct backend_conn *conn)
return conn->buf; return conn->buf;
} }
size_t ucart_backendWrite(struct backend_conn *conn, const char * line) int ucart_backendWrite(struct backend_conn *conn, const char * line)
{ {
return fputs(line, conn->socket); return fputs(line, conn->socket);
} }
...@@ -17,6 +17,6 @@ void ucart_backendDisconnect(struct backend_conn * conn); ...@@ -17,6 +17,6 @@ void ucart_backendDisconnect(struct backend_conn * conn);
char * ucart_backendGetline(struct backend_conn * conn); char * ucart_backendGetline(struct backend_conn * conn);
/* Write a line to the backend */ /* Write a line to the backend */
size_t ucart_backendWrite(struct backend_conn * backend, const char * line); int ucart_backendWrite(struct backend_conn * backend, const char * line);
#endif #endif
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "frontend_getpid.h" #include "frontend_getpid.h"
#include "pid_common.h"
/* Get a specified PID. /* Get a specified PID.
* *
...@@ -16,5 +21,32 @@ ...@@ -16,5 +21,32 @@
*/ */
int frontend_getpid( int frontend_getpid(
struct backend_conn * conn, struct frontend_pid_data * pid_data) { struct backend_conn * conn, struct frontend_pid_data * pid_data) {
char line[10] = "getpid \0";
char pid_option[2];
switch (pid_data->pid) {
case PITCH :
strncpy(pid_option, "p\0", 2);
break;
case ROLL :
strncpy(pid_option, "i\0", 2);
break;
case YAW :
strncpy(pid_option, "d\0", 2);
break;
default :
return 1;
}
strncat(line, pid_option, 2);
int size;
if((size = ucart_backendWrite(conn, line)) < 0 ) {
printf("nope! %d \n", size);
return 1;
}
printf("we send size bytes\n");
return 0; return 0;
} }
\ No newline at end of file \ No newline at end of file
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