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

data dumping after auto. flight works correctly

parent d1215560
No related branches found
No related tags found
No related merge requests found
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
#define QUAD_BT_ADDR "00:06:66:64:61:D6" #define QUAD_BT_ADDR "00:06:66:64:61:D6"
#define QUAD_BT_CHANNEL 0x01 #define QUAD_BT_CHANNEL 0x01
#define CMD_MAX_LENGTH 1024 #define CMD_MAX_LENGTH 4096
#define MAX_HASH_SIZE 50 #define MAX_HASH_SIZE 50
/* Backend-internal command magics */ /* Backend-internal command magics */
...@@ -269,7 +269,6 @@ int main(int argc, char **argv) ...@@ -269,7 +269,6 @@ int main(int argc, char **argv)
* Ignore stdin from the backend * Ignore stdin from the backend
*/ */
} else if (fd == zyboSocket) { } else if (fd == zyboSocket) {
printf("recieving from quad\n");
quad_recv(); quad_recv();
} else if (fd == backendSocket) { } else if (fd == backendSocket) {
int new_fd = 0; int new_fd = 0;
...@@ -714,11 +713,11 @@ static void client_recv(int fd) { ...@@ -714,11 +713,11 @@ static void client_recv(int fd) {
} }
static void quad_recv() { static void quad_recv() {
static unsigned char respBuf[4096]; static unsigned char respBuf[CMD_MAX_LENGTH];
static size_t respBufLen; static size_t respBufLen;
struct metadata m; struct metadata m;
uint8_t data[4096]; uint8_t data[CMD_MAX_LENGTH];
size_t respLen; size_t respLen;
ssize_t datalen; ssize_t datalen;
size_t packetlen; size_t packetlen;
...@@ -727,31 +726,48 @@ static void quad_recv() { ...@@ -727,31 +726,48 @@ static void quad_recv() {
CMD_MAX_LENGTH - respBufLen); CMD_MAX_LENGTH - respBufLen);
if (respLen <= 0) { if (respLen <= 0) {
perror("ERROR reading from quad...\n"); perror("ERROR reading from quad...\n");
respBufLen = 0;
return; return;
} }
respBufLen += respLen; respBufLen += respLen;
// printf("packet = '"); // printf("packet = '");
// for(int i = 0; i < (int)respBufLen; ++i) { // for(int i = 0; i < (int)respBufLen; ++i) {
// printf(" %.2x ", respBuf[i]); // printf(" 0x%.2x ", respBuf[i]);
// } // }
// printf("'\n"); // printf("'\n");
while(respBufLen){ while(respBufLen){
datalen = DecodePacket(&m, data, 2048, respBuf, respBufLen); datalen = DecodePacket(&m, data, CMD_MAX_LENGTH, respBuf, respBufLen);
if (datalen == -1) { if (datalen == -1) {
warnx("No start Byte!\n"); warnx("No start Byte");
for (size_t i = 0; i < respBufLen; ++i) {
if (respBuf[i] == BEGIN_CHAR) {
memmove(respBuf, respBuf + i, respBufLen - i);
respBufLen -=i;
return;
}
}
respBufLen = 0; respBufLen = 0;
return; return;
} }
if (datalen == -5) { if (datalen == -5) {
warnx("Chechsum mismatch!\n"); warnx("Chechsum mismatch");
for (size_t i = 0; i < respBufLen; ++i) {
if (respBuf[i] == BEGIN_CHAR) {
memmove(respBuf, respBuf + i, respBufLen - i);
respBufLen -=i;
return;
}
}
respBufLen = 0; respBufLen = 0;
return; return;
} }
if (datalen < 0){ if (datalen < 0){
/* Not enough data yet. We need to wait for more */ /* Not enough data yet. We need to wait for more */
// printf("not enough\n");
return; return;
} }
...@@ -769,8 +785,9 @@ static void quad_recv() { ...@@ -769,8 +785,9 @@ static void quad_recv() {
break; break;
case LOG_ID: case LOG_ID:
/* something like this */ /* something like this */
printf("(Quad) : Log found\n");
fwrite((char *) data, sizeof(char), m.data_len, quadlog_file); fwrite((char *) data, sizeof(char), m.data_len, quadlog_file);
fflush(quadlog_file); // fflush(quadlog_file);
break; break;
case RESPONSE_ID: case RESPONSE_ID:
printf("(Backend): response id found\n"); printf("(Backend): response id found\n");
......
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
// backend with sudo elevation and with the --preserve-env flag or -E // backend with sudo elevation and with the --preserve-env flag or -E
#define QUAD_WIFI_ENV "UCART_USE_WIFI" #define QUAD_WIFI_ENV "UCART_USE_WIFI"
#define QUAD_IP_ENV "UCART_QUAD_IP" #define QUAD_IP_ENV "UCART_QUAD_IP"
#define QUAD_IP_DEFAULT "192.168.4.1" #define QUAD_IP_DEFAULT "192.168.1.1"
#define QUAD_PORT_ENV "UCART_QUAD_PORT" #define QUAD_PORT_ENV "UCART_QUAD_PORT"
#define QUAD_PORT_DEFAULT 8080 #define QUAD_PORT_DEFAULT 8080
#endif /* __CONFIG_H */ #endif /* __CONFIG_H */
\ 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