OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <windows.h> | 5 #include <windows.h> |
6 | 6 |
7 #include "device/serial/serial_io_handler_win.h" | 7 #include "device/serial/serial_io_handler_win.h" |
8 | 8 |
9 namespace device { | 9 namespace device { |
10 | 10 |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 DCHECK(CalledOnValidThread()); | 204 DCHECK(CalledOnValidThread()); |
205 DCHECK(pending_write_buffer()); | 205 DCHECK(pending_write_buffer()); |
206 DCHECK(file().IsValid()); | 206 DCHECK(file().IsValid()); |
207 | 207 |
208 BOOL ok = ::WriteFile(file().GetPlatformFile(), | 208 BOOL ok = ::WriteFile(file().GetPlatformFile(), |
209 pending_write_buffer(), | 209 pending_write_buffer(), |
210 pending_write_buffer_len(), | 210 pending_write_buffer_len(), |
211 NULL, | 211 NULL, |
212 &write_context_->overlapped); | 212 &write_context_->overlapped); |
213 if (!ok && GetLastError() != ERROR_IO_PENDING) { | 213 if (!ok && GetLastError() != ERROR_IO_PENDING) { |
| 214 VPLOG(1) << "Write failed"; |
214 QueueWriteCompleted(0, serial::SEND_ERROR_SYSTEM_ERROR); | 215 QueueWriteCompleted(0, serial::SEND_ERROR_SYSTEM_ERROR); |
215 } | 216 } |
216 } | 217 } |
217 | 218 |
218 void SerialIoHandlerWin::CancelReadImpl() { | 219 void SerialIoHandlerWin::CancelReadImpl() { |
219 DCHECK(CalledOnValidThread()); | 220 DCHECK(CalledOnValidThread()); |
220 DCHECK(file().IsValid()); | 221 DCHECK(file().IsValid()); |
221 ::CancelIo(file().GetPlatformFile()); | 222 ::CancelIo(file().GetPlatformFile()); |
222 } | 223 } |
223 | 224 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 ReadCompleted(bytes_transferred, read_cancel_reason()); | 295 ReadCompleted(bytes_transferred, read_cancel_reason()); |
295 } else if (error != ERROR_SUCCESS && error != ERROR_OPERATION_ABORTED) { | 296 } else if (error != ERROR_SUCCESS && error != ERROR_OPERATION_ABORTED) { |
296 ReadCompleted(0, serial::RECEIVE_ERROR_SYSTEM_ERROR); | 297 ReadCompleted(0, serial::RECEIVE_ERROR_SYSTEM_ERROR); |
297 } else if (pending_read_buffer()) { | 298 } else if (pending_read_buffer()) { |
298 BOOL ok = ::ReadFile(file().GetPlatformFile(), | 299 BOOL ok = ::ReadFile(file().GetPlatformFile(), |
299 pending_read_buffer(), | 300 pending_read_buffer(), |
300 pending_read_buffer_len(), | 301 pending_read_buffer_len(), |
301 NULL, | 302 NULL, |
302 &read_context_->overlapped); | 303 &read_context_->overlapped); |
303 if (!ok && GetLastError() != ERROR_IO_PENDING) { | 304 if (!ok && GetLastError() != ERROR_IO_PENDING) { |
| 305 VPLOG(1) << "Read failed"; |
304 ReadCompleted(0, serial::RECEIVE_ERROR_SYSTEM_ERROR); | 306 ReadCompleted(0, serial::RECEIVE_ERROR_SYSTEM_ERROR); |
305 } | 307 } |
306 } | 308 } |
307 } else if (context == read_context_) { | 309 } else if (context == read_context_) { |
308 if (read_canceled()) { | 310 if (read_canceled()) { |
309 ReadCompleted(bytes_transferred, read_cancel_reason()); | 311 ReadCompleted(bytes_transferred, read_cancel_reason()); |
310 } else if (error != ERROR_SUCCESS && error != ERROR_OPERATION_ABORTED) { | 312 } else if (error != ERROR_SUCCESS && error != ERROR_OPERATION_ABORTED) { |
311 ReadCompleted(0, serial::RECEIVE_ERROR_SYSTEM_ERROR); | 313 ReadCompleted(0, serial::RECEIVE_ERROR_SYSTEM_ERROR); |
312 } else { | 314 } else { |
313 ReadCompleted(bytes_transferred, | 315 ReadCompleted(bytes_transferred, |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 std::string SerialIoHandler::MaybeFixUpPortName(const std::string& port_name) { | 394 std::string SerialIoHandler::MaybeFixUpPortName(const std::string& port_name) { |
393 // For COM numbers less than 9, CreateFile is called with a string such as | 395 // For COM numbers less than 9, CreateFile is called with a string such as |
394 // "COM1". For numbers greater than 9, a prefix of "\\\\.\\" must be added. | 396 // "COM1". For numbers greater than 9, a prefix of "\\\\.\\" must be added. |
395 if (port_name.length() > std::string("COM9").length()) | 397 if (port_name.length() > std::string("COM9").length()) |
396 return std::string("\\\\.\\").append(port_name); | 398 return std::string("\\\\.\\").append(port_name); |
397 | 399 |
398 return port_name; | 400 return port_name; |
399 } | 401 } |
400 | 402 |
401 } // namespace device | 403 } // namespace device |
OLD | NEW |