X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fnet%2Fpocketcmd.c;h=3c92a2faf5883fe2c326334d5c818a29867faf7c;hb=7d7882d05d70560c3aa9e6c6fad48bd323ff2a82;hp=7ae238be6311f8842da3b52b0730a3dee672f7a0;hpb=9ad4bfda67375c05ca590cc793da190b9dc8de5b;p=bertos.git diff --git a/bertos/net/pocketcmd.c b/bertos/net/pocketcmd.c index 7ae238be..3c92a2fa 100644 --- a/bertos/net/pocketcmd.c +++ b/bertos/net/pocketcmd.c @@ -50,7 +50,7 @@ * The CMD ID used is the same supplied by the master when * the command was sent. * - * \version $Id: pocketcmd.c 16587 2007-10-02 14:31:02Z batt $ + * \version $Id$ * * \author Francesco Sacchi */ @@ -64,7 +64,8 @@ #include -#include +#include +#include #include @@ -83,7 +84,24 @@ void pocketcmd_poll(struct PocketCmdCtx *ctx) if (msg.addr == ctx->addr || msg.addr == POCKETBUS_BROADCAST_ADDR) { - const PocketCmdHdr *hdr = (const PocketCmdHdr *)msg.payload; + + #if CPU_AVR + const PocketCmdHdr *hdr = (const PocketCmdHdr *)msg.payload; + #else + #if !CPU_ARM + #warning Fix alignment problem.. + /* + * The code below make one memcopy, this the only way to + * solve alignment problem on ARM. If you are use other + * architecture you should find other way to optimize + * this code. + */ + #endif + PocketCmdHdr hd; + memcpy(&hd, msg.payload, sizeof(PocketCmdHdr)); + const PocketCmdHdr *hdr = &hd; + #endif + pocketcmd_t cmd = be16_to_cpu(hdr->cmd); /* We're no longer waiting for a reply (in case we were) */