diff options
author | Florian Jung <flo@windfisch.org> | 2015-01-07 13:10:33 +0100 |
---|---|---|
committer | Florian Jung <flo@windfisch.org> | 2015-01-07 13:10:33 +0100 |
commit | 7a51b8103dc6b6a5ee4689dc93cad40b6e866d06 (patch) | |
tree | 0ce05a38fb7071ccb2517a77aee8a4e62b073a42 /client2.c | |
parent | 5d3362ea961db44afdf5d2969ece85e03ed69a04 (diff) |
client receives navdata
Diffstat (limited to 'client2.c')
-rw-r--r-- | client2.c | 21 |
1 files changed, 17 insertions, 4 deletions
@@ -34,6 +34,14 @@ int read_completely(int fd, void* buf, size_t len) int main(int argc, const char** argv) { struct sockaddr_un my_sockaddr; + struct navdata_t + { + double phi; + double theta; + double psi; + double batt; + }; + my_sockaddr.sun_family=AF_UNIX; strcpy(my_sockaddr.sun_path, SOCKETPATH); int sockaddrlen = strlen(my_sockaddr.sun_path) + sizeof(my_sockaddr.sun_family); @@ -52,8 +60,10 @@ int main(int argc, const char** argv) write(sockfd,"get\n",4); read_completely(sockfd, buffer, 4); int framelen = ((buffer[0]*256+buffer[1])*256+buffer[2])*256+buffer[3]; - if (framelen > sizeof(buffer)) suicide("buffer too small"); - read_completely(sockfd, buffer, framelen); + if (framelen + sizeof(navdata_t) > sizeof(buffer)) suicide("buffer too small"); + read_completely(sockfd, buffer, framelen+sizeof(navdata_t)); + const navdata_t* navdata = (navdata_t*)(buffer + framelen); + printf("%lf\t%lf\t%lf\t%lf\n", navdata->phi, navdata->theta, navdata->psi, navdata->batt); char key; bool go=true; bool new_vals=true; @@ -139,8 +149,11 @@ int main(int argc, const char** argv) write(sockfd,"get\n",4); read_completely(sockfd, buffer, 4); int framelen = ((buffer[0]*256+buffer[1])*256+buffer[2])*256+buffer[3]; - if (framelen > sizeof(buffer)) suicide("buffer too small"); - read_completely(sockfd, buffer, framelen); + if (framelen + sizeof(navdata_t) > sizeof(buffer)) suicide("buffer too small"); + read_completely(sockfd, buffer, framelen+sizeof(navdata_t)); + + const navdata_t* navdata = (navdata_t*)(buffer + framelen); + printf("%lf\t%lf\t%lf\t%lf\n", navdata->phi, navdata->theta, navdata->psi, navdata->batt); } //Mat dingens=Mat::eye(100,100,CV_8UC1) * 244; |