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

use identical message format and functions across OPAL, GTFPGA and the server code

git-svn-id: https://zerberus.eonerc.rwth-aachen.de:8443/svn/s2ss/trunk@186 8ec27952-4edc-4aab-86aa-e87bb2611832
This commit is contained in:
Steffen Vogel 2014-08-31 16:15:54 +00:00
parent aaf17ffee7
commit 7fb7d6157f
2 changed files with 25 additions and 15 deletions

View file

@ -4,18 +4,23 @@
* @copyright 2014, Institute for Automation of Complex Power Systems, EONERC
*/
#include <byteswap.h>
#ifdef __linux__
#include <byteswap.h>
#elif defined(__powerpc__)
#include <xil_io.h>
#endif
#include "msg.h"
void msg_swap(struct msg *m)
{
uint32_t *data = (uint32_t *) m->data;
/* Swap data */
for (int i = 0; i < m->length; i++)
data[i] = bswap_32(data[i]);
for (int i = 0; i < m->length; i++) {
#ifdef __linux__
data[i] = bswap_32(m->data[i].i);
#elif defined(__powerpc__)
data[i] = Xil_EndianSwap32(m->data[i].i);
#endif
}
m->endian ^= 1;
}

View file

@ -7,8 +7,12 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <byteswap.h>
#include <arpa/inet.h>
#ifdef __linux__
#include <byteswap.h>
#elif defined(__powerpc__)
#include <xil_io.h>
#endif
#include "msg.h"
#include "node.h"
@ -16,12 +20,13 @@
void msg_swap(struct msg *m)
{
uint32_t *data = (uint32_t *) m->data;
/* Swap data */
for (int i = 0; i < m->length; i++)
data[i] = bswap_32(data[i]);
for (int i = 0; i < m->length; i++) {
#ifdef __linux__
m->data[i].i = bswap_32(m->data[i].i);
#elif defined(__powerpc__)
m->data[i].i = Xil_EndianSwap32(m->data[i].i);
#endif
}
m->endian ^= 1;
}