Coder Social home page Coder Social logo

Comments (2)

PowerBroker2 avatar PowerBroker2 commented on May 27, 2024

Looks like an "endian" difference between the two MCUs. Try swapping the byte order on the ints on the receiver and see if it helps. Might also be useful to set the int size manually.

from serialtransfer.

adelin-mcbsoft avatar adelin-mcbsoft commented on May 27, 2024

Both MCUs report being "Little Endian".
I ran the following code to find out:

#include <Arduino.h>

#include <limits.h>
#include <stdint.h>

#if CHAR_BIT != 8
#error "unsupported char size"
#endif

enum
{
    O32_LITTLE_ENDIAN = 0x03020100ul,
    O32_BIG_ENDIAN = 0x00010203ul,
    O32_PDP_ENDIAN = 0x01000302ul
};

static const union { unsigned char bytes[4]; uint32_t value; } o32_host_order =
    { { 0, 1, 2, 3 } };

#define O32_HOST_ORDER (o32_host_order.value)

void setup() 
{
  Serial.begin( 115200 );

  if ( O32_HOST_ORDER == O32_LITTLE_ENDIAN )
  {
    Serial.println( F( "Little Endian" ) );
  }
  else if ( O32_HOST_ORDER == O32_BIG_ENDIAN )
  {
    Serial.println( F( "Big Endian" ) );
  }
  else if ( O32_HOST_ORDER == O32_PDP_ENDIAN )
  {
    Serial.println( F( "PDP Endian" ) );
  }
  else
  {
    Serial.println( F( "Other Endian" ) );
  }
}

So that might not be it.
It also fails with floats, not only ints.
Weird thing that the CRC validates the packets, so has to be some bit-shifting issue, just can't figure out what...

from serialtransfer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.