#ifndef __P_SERIAL_PACKET_H__ #define __P_SERIAL_PACKET_H__ // src_addr {1} + // dest_addr {1} + // frame_length {1} + // checksum {1} + // frame_data {512} #define MAX_MESSAGE_LEN (516) #define MAX_FRAME_DATA_LEN (512) #define MASTER_ADDR (0x01) #include class ps_packet { public: ps_packet(uint8_t* data); ~ps_packet(); uint8_t src_addr; uint8_t dest_addr; uint8_t checksum; uint8_t data[MAX_MESSAGE_LEN]; bool encode(); bool decode(); private: bool validate(); void calc_checksum(); }; #endif