Serial structure data transfer between an Arduino and a Linux PC
The following solution isn't strictly portable, but it should work as long as both ends are little-endian (most platforms).

You can use the GCC attribute packed to tell the compiler not to pad the fields like this:

struct __attribute__ ((packed)) my_struct {
  char c;
  int32_t n;
};


Then you can send your struct like this:

Serial.write((uint8_t*) a_my_struct_ptr, sizeof(my_struct));


On the receiving end you just copy the received data to a similarly packed struct. If you would rather use Python over C/C++ you can use the struct module to unserialize the data.



I just googled your product and the MIPS processor is bi-endian, but I will assume that it is configured for little-endian by default. You can try and see if ints keep their value after transmit. Also remember to use explicit size types such as int16_t, uint64_t, etc.