I have the data, which includes 32 bit scaled integers for latitude and longitude,32 bit floats for x y and z velocity and some 1-bit flags. I also am successfully sending at least one double over UDP but it appears to be trash on the other end and in Wireshark. I need bitwise access to toggle/change the data every second that I send out the data over UDP. The message format is simple and each data type will take up its size and has a certain start bit. It seems like I need to serialize but with the other end, not necessarily deserializing is that possible? My first thought was to make a structure with all the data then send the whole structure over UDP but with padding that seems wrong. The message needs to be 64 bytes long and each data type has a start bit and length of the format. This code compiles and works but with an unreadable latitude on the receiving side. Lat, long, and alt update every second. There are more data fields but I am trying to start small. A snippet of the format is attached with the data type, word location, start bit within that word, and length in bits is attached, lat, long, and alt are somewhere else within the message. Data Format Best idea right now is to use Cereal (http://uscilab.github.io/cereal/index.html) but not sure if that's a dead end.
struct TSPIstruct //
{
double Latitude;
double Longitude;
double Altitude;
};
void SendDataUDP(double latitude, double longitude, double altitude)
{
TSPIstruct TSPI;
TSPI = CompileTSPI(latitude, longitude, altitude);
//printf("\n\r");
printf("Sending GPS over UDP at %d", LastSystemTime);
printf("\n\r");
printf("\n\r");
//send the message
if (sendto(s, (char*)&(TSPI.Latitude), sizeof(double) , 0 , (struct sockaddr *) &si_other, slen) == SOCKET_ERROR)
{
printf("sendto() failed with error code : %d" , WSAGetLastError());
exit(EXIT_FAILURE);
}
printf("UDP packet sent, latitude is %f", TSPI.Latitude);
printf("\n\r");
printf("\n\r");
}
TSPIstruct CompileTSPI(double latitude, double longitude, double altitude)
{
TSPIstruct TSPI;
TSPI.Latitude = latitude;
TSPI.Longitude = longitude;
TSPI.Altitude = altitude;
return TSPI;
}