I took temperature data from the Arduino serial port. Temperature data coming out of the Arduino serial monitor are:
21.48
21.97
21.48
21.00
21.97
21.97
By using the C program to read the serial port as below code:
char TempChar;
DWORD NoBytesRead;
do{
ReadFile(hComm,&TempChar,sizeof(TempChar),&NoBytesRead,NULL);
printf("%c",TempChar); }
while(!kbhit());
Then it will appear like this.
21.48
21.97
21.48
21.00
21.97
21.97
Now I want to add and display hours, minutes and seconds using the c program like the code below:
char TempChar;
DWORD NoBytesRead;
SYSTEMTIME str_t;
GetSystemTime(&str_t);
do{
ReadFile(hComm,&TempChar,sizeof(TempChar),&NoBytesRead,NULL);
printf("%c, %d:%d:%d ",TempChar,str_t.wHour+7,str_t.wMinute,str_t.wSecond);
}while(!kbhit());
but the result is like this :
, 18:9:38 1, 18:9:38 ., 18:9:38 ., 18:9:38 0, 18:9:38 0, 18:9:38
, 18:9:38 2, 18:9:38 1, 18:9:38 ., 18:9:38 0, 18:9:38 0, 18:9:38
, 18:9:38 2, 18:9:38 1, 18:9:38 ., 18:9:38 0, 18:9:38 0, 18:9:38
I actually want the result is
21.48,18:9:38
21.97,18:9:38
21.48,18:9:38
21.00,18:9:38
21.97,18:9:38
21.97,18:9:38
What should I fix from the C language program code?