diff --git a/groundStation/addnode b/groundStation/addnode new file mode 120000 index 0000000000000000000000000000000000000000..83c63a5d9a0f1ab92f86859877d2d168eca32fc0 --- /dev/null +++ b/groundStation/addnode @@ -0,0 +1 @@ +Cli \ No newline at end of file diff --git a/groundStation/getnodes b/groundStation/getnodes new file mode 120000 index 0000000000000000000000000000000000000000..83c63a5d9a0f1ab92f86859877d2d168eca32fc0 --- /dev/null +++ b/groundStation/getnodes @@ -0,0 +1 @@ +Cli \ No newline at end of file diff --git a/groundStation/getoutput b/groundStation/getoutput new file mode 120000 index 0000000000000000000000000000000000000000..83c63a5d9a0f1ab92f86859877d2d168eca32fc0 --- /dev/null +++ b/groundStation/getoutput @@ -0,0 +1 @@ +Cli \ No newline at end of file diff --git a/groundStation/getparam b/groundStation/getparam new file mode 120000 index 0000000000000000000000000000000000000000..83c63a5d9a0f1ab92f86859877d2d168eca32fc0 --- /dev/null +++ b/groundStation/getparam @@ -0,0 +1 @@ +Cli \ No newline at end of file diff --git a/groundStation/getsource b/groundStation/getsource new file mode 120000 index 0000000000000000000000000000000000000000..83c63a5d9a0f1ab92f86859877d2d168eca32fc0 --- /dev/null +++ b/groundStation/getsource @@ -0,0 +1 @@ +Cli \ No newline at end of file diff --git a/groundStation/setparam b/groundStation/setparam new file mode 120000 index 0000000000000000000000000000000000000000..83c63a5d9a0f1ab92f86859877d2d168eca32fc0 --- /dev/null +++ b/groundStation/setparam @@ -0,0 +1 @@ +Cli \ No newline at end of file diff --git a/groundStation/setsource b/groundStation/setsource new file mode 120000 index 0000000000000000000000000000000000000000..83c63a5d9a0f1ab92f86859877d2d168eca32fc0 --- /dev/null +++ b/groundStation/setsource @@ -0,0 +1 @@ +Cli \ No newline at end of file diff --git a/groundStation/src/backend/backend.c b/groundStation/src/backend/backend.c index 1088a84cb0b96da0c343b742026c63223c3ec47d..94e8e7dcc17b539223c155b8a94b2dbff77b4a69 100644 --- a/groundStation/src/backend/backend.c +++ b/groundStation/src/backend/backend.c @@ -563,7 +563,6 @@ static int clientAddPendResponses(int fd, uint16_t packet_id) { static int clientRemovePendResponses(int fd, uint16_t packet_id) { int *pendingResponses = get_client_pend_responses(fd); for(int i = 0; i < CLIENT_MAX_PENDING_RESPONSES; i++) { - printf("might remove pendingResponses[%d], if it equals %d\n", i, packet_id); if(pendingResponses[i] == packet_id) { pendingResponses[i] = -1; return i; @@ -737,22 +736,22 @@ static void client_recv(int fd) { } /* Only add the client to the pending responses if it was a getparam command */ - // if (m.msg_type == GETPARAM_ID || m.msg_type == GETOUTPUT_ID || - // m.msg_type == GETSOURCE_ID || m.msg_type == GETNODES_ID || m.msg_type == ADDNODE_ID) { - // printf("adding fd %d with id %d\n", fd, BytesTo16(packet[ID_L], packet[ID_H])); - // if (clientAddPendResponses(fd, BytesTo16(packet[ID_L], packet[ID_H])) == -1) { - // warnx("Ran out of room! Consider increasing CLIENT_MAX_PENDING_RESPONSES!\n"); - // } - // } - - printf("packetToQuad = '"); - for(int i = 0; i < (int)psize; ++i) { - printf(" %.2x ", packet[i]); + if (m.msg_type == GETPARAM_ID || m.msg_type == GETOUTPUT_ID || + m.msg_type == GETSOURCE_ID || m.msg_type == GETNODES_ID || m.msg_type == ADDNODE_ID) { + printf("adding fd %d with id %d\n", fd, BytesTo16(packet[ID_L], packet[ID_H])); + if (clientAddPendResponses(fd, BytesTo16(packet[ID_L], packet[ID_H])) == -1) { + warnx("Ran out of room! Consider increasing CLIENT_MAX_PENDING_RESPONSES!\n"); + } } - printf("'\n"); + + // printf("packetToQuad = '"); + // for(int i = 0; i < (int)psize; ++i) { + // printf(" %.2x ", packet[i]); + // } + // printf("'\n"); int retval = writeQuad(packet, psize); - printf("sent %d bytes\n", retval); + // printf("sent %d bytes\n", retval); free(data); } @@ -782,11 +781,11 @@ static void quad_recv() { } respBufLen += respLen; - printf("packetFromQuad = '"); - for(int i = 0; i < (int)respBufLen; ++i) { - printf(" %.2x ", respBuf[i]); - } - printf("'\n"); + // printf("packetFromQuad = '"); + // for(int i = 0; i < (int)respBufLen; ++i) { + // printf(" %.2x ", respBuf[i]); + // } + // printf("'\n"); while(respBufLen){ datalen = DecodePacket(&m, data, CMD_MAX_LENGTH, respBuf, respBufLen); @@ -833,11 +832,9 @@ static void quad_recv() { printf("New log file created: '%s'\n", log_file); quadlog_file = fopen(log_file, "a"); quadlog_file_open = 1; - } - /* something like this */ + } //printf("(Quad) : Log found\n"); fwrite((char *) data, sizeof(char), m.data_len, quadlog_file); - // fflush(quadlog_file); break; case RESPPARAM_ID: case RESPSOURCE_ID: @@ -855,6 +852,7 @@ static void quad_recv() { break; default: printf("(Backend): message type %d ignored from quad\n", m.msg_type); + break; } } } @@ -882,6 +880,7 @@ static void handleResponse(struct metadata *m, uint8_t * data) break; default: result = -1; + break; } if (result < 0) { @@ -890,12 +889,16 @@ static void handleResponse(struct metadata *m, uint8_t * data) return; } - // for(int fd = 0; fd <= max_fd; ++fd) { - // if (get_client_index(fd) < 0) { - // clientRemovePendResponses(fd, m->msg_id); - // write(fd, buffer, result); - // } - // } + printf("msg to client = '%s'\n", buffer); + + for(int fd = 0; fd <= max_fd; ++fd) { + if (get_client_index(fd) > -1) { + clientRemovePendResponses(fd, m->msg_id); + write(fd, buffer, result); + } + } + + printf("leaving handleResponse\n"); free(buffer); } diff --git a/groundStation/src/backend/param.c b/groundStation/src/backend/param.c index 8912b65f96d2a1506f8e62b4c4588cc71466f5d0..5fdba8fd5126414be4b8aee2239b3b14f0ce2205 100644 --- a/groundStation/src/backend/param.c +++ b/groundStation/src/backend/param.c @@ -120,7 +120,7 @@ int DecodeResponseParam( return -1; } - return snprintf(msg, max_len, "getparam %" PRId16 " %" PRId16 " %f", + return snprintf(msg, max_len, "getparam %" PRId16 " %" PRId16 " %f\n", BytesTo16(data[RESP_BLOCK_ID_L], data[RESP_BLOCK_ID_H]), BytesTo16(data[RESP_PARAM_ID_L], data[RESP_PARAM_ID_H]), BytesToFloat(data[RESP_VAL_1], data[RESP_VAL_2], diff --git a/groundStation/src/cli/cli_param.c b/groundStation/src/cli/cli_param.c index 478682ccee0c652f9e0a90704aea71e0292784df..f509ed092e0ee50233c56291dea995d28db93d2d 100644 --- a/groundStation/src/cli/cli_param.c +++ b/groundStation/src/cli/cli_param.c @@ -30,7 +30,7 @@ int cli_getparam(struct backend_conn * conn, int argc, char ** argv) { } printf("BLOCK.PARAM = VAL\n" \ - " %" PRId16 ".%" PRId16 " = %lf\n", + " %2" PRId16 ".%2" PRId16 " = %lf\n", param_data.block, param_data.param, param_data.value);