typedef struct {
// Page that is transmitted
unsigned int page;
// Block that is transmitted
unsigned int block;
// A mumeric representation of the 32 byte segment that I send.
// I cannot send the page altogether, therefore a byte intexing is required
uint8_t bytes_index;
// Despite my buffer is 32 bytes the usable data may be less
uint8_t length;
// Data buffer containing the data to be sent via serial
byte data[BUFFER_LEN];
} usb_msg;
void setup() {
// SPI.begin();
Serial.begin(9600);
Serial.print(ACK);
}
void loop(){
usb_msg msg;
// Populate dummy data
msg.page=1;
msg.block=1;
msg.bytes_index=2;
msg.length = 10
msg.data = [1,1,1,1,1,1,1,1,1,1];
// Send it here
}
Is there a way to hex/base16 endode the msg before sending it through serial?
Yes, The first line sends the upper 4 bits as a hex character, the 2nd line sends the lower 4 bits as a hex character. If you just print(*ptr, HEX) there will be no leading zero for numbers less than 0x10. As an example 0x01 0x01 would print as "11" instead of "0101".