| Index: chrome/browser/extensions/api/serial/serial_connection_win.cc
|
| diff --git a/chrome/browser/extensions/api/serial/serial_connection_win.cc b/chrome/browser/extensions/api/serial/serial_connection_win.cc
|
| index 8075643d42bc0efc0f109ee4f5f3d18f59a75875..41f86b7765d603dc38155929e10153f5365c53ba 100644
|
| --- a/chrome/browser/extensions/api/serial/serial_connection_win.cc
|
| +++ b/chrome/browser/extensions/api/serial/serial_connection_win.cc
|
| @@ -5,36 +5,32 @@
|
| #include "chrome/browser/extensions/api/serial/serial_connection.h"
|
|
|
| #include <string>
|
| +#include <windows.h>
|
|
|
| namespace extensions {
|
|
|
| -SerialConnection::SerialConnection(const std::string& port,
|
| - APIResourceEventNotifier* event_notifier)
|
| - : APIResource(APIResource::SerialConnectionResource, event_notifier),
|
| - port_(port), fd_(0) {
|
| -}
|
| -
|
| -SerialConnection::~SerialConnection() {
|
| -}
|
| -
|
| -bool SerialConnection::Open() {
|
| - // TODO(miket): implement
|
| - return false;
|
| -}
|
| -
|
| -void SerialConnection::Close() {
|
| - // TODO(miket): implement
|
| -}
|
| -
|
| -int SerialConnection::Read(uint8* byte) {
|
| - // TODO(miket): implement
|
| - return -1;
|
| -}
|
| -
|
| -int SerialConnection::Write(scoped_refptr<net::IOBuffer> io_buffer,
|
| - int byte_count) {
|
| - // TODO(miket): implement
|
| - return -1;
|
| +bool SerialConnection::PostOpen() {
|
| + // Set timeouts so that reads return immediately with whatever could be read
|
| + // without blocking.
|
| + COMMTIMEOUTS timeouts = { 0 };
|
| + timeouts.ReadIntervalTimeout = MAXDWORD;
|
| + if (!::SetCommTimeouts(file_, &timeouts))
|
| + return false;
|
| +
|
| + DCB dcb = { 0 };
|
| + dcb.DCBlength = sizeof(dcb);
|
| + if (!GetCommState(file_, &dcb))
|
| + return false;
|
| +
|
| + // TODO(miket): when we have a bit rate API, use it.
|
| + dcb.BaudRate = CBR_57600;
|
| + dcb.ByteSize = 8;
|
| + dcb.StopBits = ONESTOPBIT;
|
| + dcb.Parity = NOPARITY;
|
| + if (!SetCommState(file_, &dcb))
|
| + return false;
|
| +
|
| + return true;
|
| }
|
|
|
| } // namespace extensions
|
|
|