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 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 } | 384 } |
385 serial::ConnectionInfoPtr info(serial::ConnectionInfo::New()); | 385 serial::ConnectionInfoPtr info(serial::ConnectionInfo::New()); |
386 info->bitrate = SpeedConstantToBitrate(config.BaudRate); | 386 info->bitrate = SpeedConstantToBitrate(config.BaudRate); |
387 info->data_bits = DataBitsConstantToEnum(config.ByteSize); | 387 info->data_bits = DataBitsConstantToEnum(config.ByteSize); |
388 info->parity_bit = ParityBitConstantToEnum(config.Parity); | 388 info->parity_bit = ParityBitConstantToEnum(config.Parity); |
389 info->stop_bits = StopBitsConstantToEnum(config.StopBits); | 389 info->stop_bits = StopBitsConstantToEnum(config.StopBits); |
390 info->cts_flow_control = config.fOutxCtsFlow != 0; | 390 info->cts_flow_control = config.fOutxCtsFlow != 0; |
391 return info.Pass(); | 391 return info.Pass(); |
392 } | 392 } |
393 | 393 |
| 394 bool SerialIoHandlerWin::SetBreak() { |
| 395 if (!SetCommBreak(file().GetPlatformFile())) { |
| 396 VPLOG(1) << "Failed to set break"; |
| 397 return false; |
| 398 } |
| 399 return true; |
| 400 } |
| 401 |
| 402 bool SerialIoHandlerWin::ClearBreak() { |
| 403 if (!ClearCommBreak(file().GetPlatformFile())) { |
| 404 VPLOG(1) << "Failed to clear break"; |
| 405 return false; |
| 406 } |
| 407 return true; |
| 408 } |
| 409 |
394 std::string SerialIoHandler::MaybeFixUpPortName(const std::string& port_name) { | 410 std::string SerialIoHandler::MaybeFixUpPortName(const std::string& port_name) { |
395 // For COM numbers less than 9, CreateFile is called with a string such as | 411 // For COM numbers less than 9, CreateFile is called with a string such as |
396 // "COM1". For numbers greater than 9, a prefix of "\\\\.\\" must be added. | 412 // "COM1". For numbers greater than 9, a prefix of "\\\\.\\" must be added. |
397 if (port_name.length() > std::string("COM9").length()) | 413 if (port_name.length() > std::string("COM9").length()) |
398 return std::string("\\\\.\\").append(port_name); | 414 return std::string("\\\\.\\").append(port_name); |
399 | 415 |
400 return port_name; | 416 return port_name; |
401 } | 417 } |
402 | 418 |
403 } // namespace device | 419 } // namespace device |
OLD | NEW |