I'm trying to print the Serial data packet value in text file, the data packet coming from Arduino due board,
Arduino code:
void setup()
{
Serial.begin(9600)
uint16_t packet[8];
}
void loop()
{
for(int i=0 ;i<8;i++)
{
Packet[i]=0x0A31+i;
Serial.println(packet[i]);
}
}
c++ code:
// Read function only
read()
{
uint16_t data[8];
DWORD bytesRead;
Readfile(hcomm, &data , sizeof(data) , &bytesRead,Null);
File*fp;
fp=("c:\\data.txt","a+");
for(int i=o;i<7;i++)
{
fprintf(fp,"%x/t",data[i];
}
fprintf(fp,"\n");
}
The Arduino output is :A31 A32 A33 A34 ..... (each data is 12 bit )this is correct , and then i read data from Serial port and print into text file the output is : A31A3 2A3 3A34..(i'm not getting porper 12 bit manner...)
so how to change my read function.......to print proper ( 12bit ) data in the text file