X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;ds=sidebyside;f=bertos%2Fnet%2Fpocketbus.c;fp=bertos%2Fnet%2Fpocketbus.c;h=61d4d2b44261432885e33fa0bb81050a5c8d7330;hb=56df77502283f05666f8e80e7b246c3a500e1485;hp=a9cb4727c162362e7f594a702c5853e0c350a756;hpb=0b5e269f0571dac2454992b94b563f80c31291e1;p=bertos.git diff --git a/bertos/net/pocketbus.c b/bertos/net/pocketbus.c index a9cb4727..61d4d2b4 100644 --- a/bertos/net/pocketbus.c +++ b/bertos/net/pocketbus.c @@ -208,12 +208,16 @@ bool pocketbus_recv(struct PocketBusCtx *ctx, struct PocketMsg *msg) /* Compute checksum */ rotating_update(ctx->buf, ctx->len, &ctx->in_cks); - rotating_t recv_cks = be16_to_cpu(*((rotating_t *)(ctx->buf + ctx->len))); + uint8_t cks_h = *(ctx->buf + ctx->len); + uint8_t cks_l = *(ctx->buf + ctx->len + 1); + + rotating_t recv_cks = (cks_h << 8) | cks_l; /* Checksum check */ if (recv_cks == ctx->in_cks) { - PocketBusHdr *hdr = (PocketBusHdr *)(ctx->buf); + PocketBusHdr *hdr = (PocketBusHdr *)ctx; + /* Check packet version */ if (hdr->ver == POCKETBUS_VER) {