pack all data sequentially to send via Serial.write as a byte array.

Hi, please help me.

I need pack all data sequentially to send via Serial.write as a byte array.

typedef struct{

byte nameSize[2];
char name[5];
float value;

}Field;

typedef struct{

int id;
byte type;
byte versionn=1;
uint64_t timeStamp;
byte numFields;
Field fields[2];

}Report;

typedef struct{

uint64_t timeStamp;
byte stationNameSize[2];
char stationName[8];
Report reports[];

}Envelope;

void loop() {

Envelope envelope;
Report report;
Field field;

}

É garantido que ao instanciar esses três tipos eles estarão alocados em sequencia? Para enviar os bytes via serial.write. Thanks.

Same as the answer to your other question.

Serial.write((uint8_t *)&envelope, sizeof(envelope));
Serial.write((uint8_t *)&report, sizeof(report));
Serial.write((uint8_t *)&field, sizeof(field));