forked from Zero-V4x/Arduino-Aime-Reader-EN
-
Notifications
You must be signed in to change notification settings - Fork 4
/
DTR-RTS.c
46 lines (42 loc) · 1.6 KB
/
DTR-RTS.c
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
42
43
44
45
46
#include <windows.h>
int main() {
HANDLE com;
com = CreateFile("COM1", GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, 0);
DCB dcbSerialParams = {0};
COMMTIMEOUTS timeouts = {0};
dcbSerialParams.DCBlength = sizeof(dcbSerialParams);
GetCommState(com, &dcbSerialParams);
dcbSerialParams.BaudRate = 115200;
dcbSerialParams.ByteSize = 8;
dcbSerialParams.StopBits = ONESTOPBIT;
dcbSerialParams.Parity = NOPARITY;
SetCommState(com, &dcbSerialParams);
timeouts.ReadIntervalTimeout = 1;
timeouts.ReadTotalTimeoutConstant = 1;
timeouts.ReadTotalTimeoutMultiplier = 1;
timeouts.WriteTotalTimeoutConstant = 1;
timeouts.WriteTotalTimeoutMultiplier = 1;
SetCommTimeouts(com, &timeouts);
EscapeCommFunction(com, SETDTR);
EscapeCommFunction(com, SETRTS);
com = CreateFile("\\\\.\\COM12", GENERIC_READ | GENERIC_WRITE, 0, 0,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
dcbSerialParams.DCBlength = sizeof(dcbSerialParams);
GetCommState(com, &dcbSerialParams);
dcbSerialParams.BaudRate = 38400;
dcbSerialParams.ByteSize = 8;
dcbSerialParams.StopBits = ONESTOPBIT;
dcbSerialParams.Parity = NOPARITY;
SetCommState(com, &dcbSerialParams);
timeouts.ReadIntervalTimeout = 1;
timeouts.ReadTotalTimeoutConstant = 1;
timeouts.ReadTotalTimeoutMultiplier = 1;
timeouts.WriteTotalTimeoutConstant = 1;
timeouts.WriteTotalTimeoutMultiplier = 1;
SetCommTimeouts(com, &timeouts);
EscapeCommFunction(com, SETDTR);
EscapeCommFunction(com, SETRTS);
return 0;
}
//