| 1003 | ----------------------------------------------------------*/ |
| 1004 | |
| 1005 | static int open_port(struct termios_list *port) |
| 1006 | { |
| 1007 | ENTER("open_port"); |
| 1008 | port->hComm = CreateFile(port->filename, |
| 1009 | GENERIC_READ | GENERIC_WRITE, |
| 1010 | 0, |
| 1011 | 0, |
| 1012 | OPEN_EXISTING, |
| 1013 | FILE_FLAG_OVERLAPPED, |
| 1014 | 0 |
| 1015 | ); |
| 1016 | |
| 1017 | if (port->hComm == INVALID_HANDLE_VALUE) |
| 1018 | { |
| 1019 | YACK(); |
| 1020 | set_errno(EINVAL); |
| 1021 | /* |
| 1022 | printf( "serial_open failed %s\n", port->filename ); |
| 1023 | */ |
| 1024 | return -1; |
| 1025 | } |
| 1026 | |
| 1027 | if (!SetupComm(port->hComm, 2048, 1024)) |
| 1028 | { |
| 1029 | YACK(); |
| 1030 | return -1; |
| 1031 | } |
| 1032 | |
| 1033 | memset(&port->rol, 0, sizeof(OVERLAPPED)); |
| 1034 | memset(&port->wol, 0, sizeof(OVERLAPPED)); |
| 1035 | memset(&port->sol, 0, sizeof(OVERLAPPED)); |
| 1036 | |
| 1037 | port->rol.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); |
| 1038 | |
| 1039 | if (!port->rol.hEvent) |
| 1040 | { |
| 1041 | YACK(); |
| 1042 | report("Could not create read overlapped\n"); |
| 1043 | goto fail; |
| 1044 | } |
| 1045 | |
| 1046 | port->sol.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); |
| 1047 | |
| 1048 | if (!port->sol.hEvent) |
| 1049 | { |
| 1050 | YACK(); |
| 1051 | report("Could not create select overlapped\n"); |
| 1052 | goto fail; |
| 1053 | } |
| 1054 | |
| 1055 | port->wol.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); |
| 1056 | |
| 1057 | if (!port->wol.hEvent) |
| 1058 | { |
| 1059 | YACK(); |
| 1060 | report("Could not create write overlapped\n"); |
| 1061 | goto fail; |
| 1062 | } |
no test coverage detected