X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fnet%2Fpocketcmd.c;h=3c92a2faf5883fe2c326334d5c818a29867faf7c;hb=ce5ddc07440aeb1357c7133beac6959b90d21885;hp=be1a912aec5f3a274d07aaa1ab0201ad77ac7ce9;hpb=6eb6ebb5ae5953a27977f0ef66a36344462b949a;p=bertos.git diff --git a/bertos/net/pocketcmd.c b/bertos/net/pocketcmd.c index be1a912a..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 */ @@ -65,6 +65,7 @@ #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) */