Serial Port
-
Hi hope someone can help me out here. I have a program that recieves data from the serial port of the PC and saves it into a file using:
byte rec; : : : for(i=0;i<512;i++) { ReadFile(handlePort, &rec, 1, (LPDWORD)&bytes, NULL); fprintf(out, "%C", rec); }
The problem is that it wont save the hex values 0x11 and 0x13 to the file when they are received from the serial port, I'm pretty sure it is because they are control characters, maybe? Also every so often it saves 0x0D to the file! Any ideas how I can get around this problem? Thanks in advance, Paddy -
Hi hope someone can help me out here. I have a program that recieves data from the serial port of the PC and saves it into a file using:
byte rec; : : : for(i=0;i<512;i++) { ReadFile(handlePort, &rec, 1, (LPDWORD)&bytes, NULL); fprintf(out, "%C", rec); }
The problem is that it wont save the hex values 0x11 and 0x13 to the file when they are received from the serial port, I'm pretty sure it is because they are control characters, maybe? Also every so often it saves 0x0D to the file! Any ideas how I can get around this problem? Thanks in advance, PaddyCheck out your fopen statement. I bet it looks like: fopen("file name", "w"); try this instead: fopen("file name", "wb"); -Sean ---- Shag a Lizard
-
Check out your fopen statement. I bet it looks like: fopen("file name", "w"); try this instead: fopen("file name", "wb"); -Sean ---- Shag a Lizard
-
Thanks you were right! I changed it and it has *nearly* solved the problem, it got rid of the random 0x0D in the output file but it still won't write 0x11 and 0x13 to the file. Maybe it is that it isn't reading these values from the port? Any ideas? Thanks
-
Check out your fopen statement. I bet it looks like: fopen("file name", "w"); try this instead: fopen("file name", "wb"); -Sean ---- Shag a Lizard