1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

changed byteorder of message data (now big endian => network byte order)

git-svn-id: https://zerberus.eonerc.rwth-aachen.de:8443/svn/s2ss/trunk@162 8ec27952-4edc-4aab-86aa-e87bb2611832
This commit is contained in:
Steffen Vogel 2014-07-18 13:36:59 +00:00
parent 22364d2708
commit 78efb846ab
2 changed files with 27 additions and 4 deletions

View file

@ -101,8 +101,8 @@ static void *SendToIPPort(void *arg)
msg.length = mdldata_size / sizeof(double);
for (i = 0; i < msg.length; i++)
msg.data[i] = (float) mdldata[i];
msg.data[i] = htonf((float) mdldata[i]);
msg_size = 4 * (msg.length + 1);
/**********************************************************************/
@ -209,7 +209,7 @@ static void *RecvFromIPPort(void *arg)
}
for (i = 0; i < msg.length; i++)
mdldata[i] = (double) msg.data[i];
mdldata[i] = (double) ntohf(msg.data[i]);
/************************************************************************/
OpalSetAsyncRecvIconData(mdldata, mdldata_size, RecvID);
@ -236,7 +236,7 @@ int main(int argc, char *argv[])
pthread_t tid_send, tid_recv;
pthread_attr_t attr_send, attr_recv;
OpalPrint("%s: This is a S2SS client\n", PROGNAME);
/* Check for the proper arguments to the program */

View file

@ -0,0 +1,23 @@
static union fi {
float f;
uint32_t i;
};
inline float ntohf(float flt)
{
union fi u = { .f = flt };
u.i = ntohl(u.i);
return u.f;
}
inline float htonf(float flt)
{
union u = { .f = flt };
u.i = htonl(u.i);
return u.f;
}