-
Notifications
You must be signed in to change notification settings - Fork 0
/
SerialLogParser.cpp
42 lines (32 loc) · 941 Bytes
/
SerialLogParser.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// SerialLogParser.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
using namespace std;
int _tmain(int argc, char* argv[])
{
HANDLE hSerial;
DWORD bytesWritten;
LPCWSTR portName = L"COM3";
hSerial=CreateFile(portName, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
if(hSerial == INVALID_HANDLE_VALUE)
return 1;
DCB dcbSerialParams = {0};
dcbSerialParams.DCBlength = sizeof(dcbSerialParams);
dcbSerialParams.BaudRate = CBR_9600;
dcbSerialParams.ByteSize = 8;
dcbSerialParams.StopBits = ONESTOPBIT;
dcbSerialParams.Parity = NOPARITY;
SetCommState(hSerial, &dcbSerialParams);
char buffer[255];
FILE *fp = fopen("lcddata.txt", "r");
char output[1024];
int i=0, c;
while ((output[i++] = getc(fp)) != EOF)
;
output[i] = '\0';
if(WriteFile(hSerial, output, strlen(output), &bytesWritten, NULL) == 0) {
printf("Failed to write to serial port.\n");
}
Sleep(2000);
return 0;
}