I need to send a group of 83 bytes as a header file for my SD card datalogger. I am trying to write these 83 bytes in hex. The problem is that the compiler writes the hex as two separate characters. for example. the first byte is 0x46. I end up with a 4 and a 6 as two separate bytes rather than a single byte representing 46 (ASCII 'F'). This means the software I am trying to interface with gets confused because the header is 166 bytes long instead of 83.
The software looks for individual bytes with an offset. No spaces or line breaks can exist.
My code snippet is as follows.
FILE *fp = fopen("/sd/datalog.frd", "a");
//print header for MS.frd file
fprintf(fp,"%x",string of bytes);
fclose(fp);
Here is the string of bytes that is pasted into the fprintf line. I added spaces and linebreaks for clarity.
0x46 0x52 0x44 0x00 0x00 0x00 0x00 0x01 0x4b 0x61 0xf1 0x63 0x4d 0x53 0x49 0x49 0x20 0x52 0x65 0x76 0x20 0x32 0x2e 0x38 0x38 0x30 0x30 0x30 0x20 0x20 0x20 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x51 0x00 0x70 0x01 0x00
Thanks for your help straightening out my format isses.
I need to send a group of 83 bytes as a header file for my SD card datalogger. I am trying to write these 83 bytes in hex. The problem is that the compiler writes the hex as two separate characters. for example. the first byte is 0x46. I end up with a 4 and a 6 as two separate bytes rather than a single byte representing 46 (ASCII 'F'). This means the software I am trying to interface with gets confused because the header is 166 bytes long instead of 83.
The software looks for individual bytes with an offset. No spaces or line breaks can exist.
My code snippet is as follows.
FILE *fp = fopen("/sd/datalog.frd", "a");
//print header for MS.frd file
fprintf(fp,"%x",string of bytes);
fclose(fp);
Here is the string of bytes that is pasted into the fprintf line. I added spaces and linebreaks for clarity.
0x46 0x52 0x44 0x00 0x00 0x00 0x00 0x01 0x4b 0x61 0xf1 0x63 0x4d 0x53 0x49 0x49 0x20 0x52 0x65 0x76 0x20 0x32 0x2e 0x38 0x38 0x30 0x30 0x30 0x20 0x20 0x20 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x51 0x00 0x70 0x01 0x00
Thanks for your help straightening out my format isses.