-\r
-HANDLE OpenCOM1() {\r
-\r
- static HANDLE COM1handle = INVALID_HANDLE_VALUE;\r
- const char msg[] = "\r\n--------linexec--------\r\n";\r
- unsigned long wrote;\r
- int speed = CBR_115200;\r
- HANDLE h;\r
-\r
- if (COM1handle != INVALID_HANDLE_VALUE)\r
- return (COM1handle);\r
-\r
- h = CreateFile(TEXT("COM1:"),\r
- GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0,\r
- NULL);\r
- if (h == INVALID_HANDLE_VALUE)\r
- return (h);\r
-\r
- DCB dcb;\r
- if (!GetCommState(h, &dcb))\r
- goto bad;\r
-\r
- dcb.BaudRate = speed;\r
- if (!SetCommState(h, &dcb))\r
- goto bad;\r
-\r
- // Print banner on serial console.\r
- WriteFile(h, msg, sizeof msg, &wrote, 0);\r
-\r
- COM1handle = h;\r
-\r
- return (h);\r
- bad:\r
- CloseHandle(h);\r
- return (INVALID_HANDLE_VALUE);\r
-}\r
+
+HANDLE OpenCOM1() {
+
+ static HANDLE COM1handle = INVALID_HANDLE_VALUE;
+ const char msg[] = "\r\n--------linexec--------\r\n";
+ unsigned long wrote;
+ int speed = CBR_115200;
+ HANDLE h;
+
+ if (COM1handle != INVALID_HANDLE_VALUE)
+ return (COM1handle);
+
+ h = CreateFile(TEXT("COM1:"),
+ GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0,
+ NULL);
+ if (h == INVALID_HANDLE_VALUE)
+ return (h);
+
+ DCB dcb;
+ if (!GetCommState(h, &dcb))
+ goto bad;
+
+ dcb.BaudRate = speed;
+ if (!SetCommState(h, &dcb))
+ goto bad;
+
+ // Print banner on serial console.
+ WriteFile(h, msg, sizeof msg, &wrote, 0);
+
+ COM1handle = h;
+
+ return (h);
+ bad:
+ CloseHandle(h);
+ return (INVALID_HANDLE_VALUE);
+}