mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
severe bug fix: msg_swap() did not correctly swapped the values (just the header)
This commit is contained in:
parent
7dec04edfc
commit
d6e4ab5d2f
3 changed files with 10 additions and 9 deletions
|
@ -16,7 +16,7 @@
|
|||
|
||||
struct node;
|
||||
|
||||
/** Swaps message contents byte-order.
|
||||
/** Swaps the byte order of the header part of struct msg.
|
||||
*
|
||||
* Message can either be transmitted in little or big endian
|
||||
* format. The actual endianess for a message is defined by the
|
||||
|
@ -27,7 +27,7 @@ struct node;
|
|||
*
|
||||
* @param m A pointer to the message
|
||||
*/
|
||||
void msg_swap(struct msg *m);
|
||||
void msg_hdr_swap(struct msg *m);
|
||||
|
||||
/** Check the consistency of a message.
|
||||
*
|
||||
|
|
|
@ -22,15 +22,12 @@
|
|||
#include "node.h"
|
||||
#include "utils.h"
|
||||
|
||||
void msg_swap(struct msg *m)
|
||||
void msg_hdr_swap(struct msg *m)
|
||||
{
|
||||
m->length = bswap_16(m->length);
|
||||
m->sequence = bswap_32(m->sequence);
|
||||
m->ts.sec = bswap_32(m->ts.sec);
|
||||
m->ts.nsec = bswap_32(m->ts.nsec);
|
||||
|
||||
for (int i = 0; i < m->length; i++)
|
||||
m->data[i].i = bswap_32(m->data[i].i);
|
||||
|
||||
m->endian ^= 1;
|
||||
}
|
||||
|
|
|
@ -332,7 +332,7 @@ int socket_read(struct node *n, struct sample *smps[], unsigned cnt)
|
|||
|
||||
/* Convert message to host endianess */
|
||||
if (hdr.endian != MSG_ENDIAN_HOST)
|
||||
msg_swap(&hdr);
|
||||
msg_hdr_swap(&hdr);
|
||||
|
||||
samples = bytes / MSG_LEN(hdr.length);
|
||||
if (samples > cnt) {
|
||||
|
@ -373,8 +373,12 @@ int socket_read(struct node *n, struct sample *smps[], unsigned cnt)
|
|||
break;
|
||||
|
||||
/* Convert message to host endianess */
|
||||
if (m->endian != MSG_ENDIAN_HOST)
|
||||
msg_swap(m);
|
||||
if (m->endian != MSG_ENDIAN_HOST) {
|
||||
msg_hdr_swap(m);
|
||||
|
||||
for (int i = 0; i < m->length; i++)
|
||||
smp->data[i].i = bswap_32(smp->data[i].i);
|
||||
}
|
||||
|
||||
smp->length = m->length;
|
||||
smp->sequence = m->sequence;
|
||||
|
|
Loading…
Add table
Reference in a new issue