repositories
/
deb_libcec.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
cec: force update the device status in the background scan thread. only scan once...
[deb_libcec.git]
/
src
/
lib
/
platform
/
windows
/
serialport.cpp
diff --git
a/src/lib/platform/windows/serialport.cpp
b/src/lib/platform/windows/serialport.cpp
index ce299cf0d443177ed9ff1bf289761eede2e082e2..9e4cc486e64138a56185f1f3d30b357cc74005bd 100644
(file)
--- a/
src/lib/platform/windows/serialport.cpp
+++ b/
src/lib/platform/windows/serialport.cpp
@@
-65,8
+65,9
@@
CSerialPort::~CSerialPort(void)
bool CSerialPort::Open(string name, uint32_t baudrate, uint8_t databits, uint8_t stopbits, uint8_t parity)
{
bool CSerialPort::Open(string name, uint32_t baudrate, uint8_t databits, uint8_t stopbits, uint8_t parity)
{
+ CStdString strComPath = "\\\\.\\" + name;
CLockObject lock(&m_mutex);
CLockObject lock(&m_mutex);
- m_handle = CreateFile(
name
.c_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
+ m_handle = CreateFile(
strComPath
.c_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
if (m_handle == INVALID_HANDLE_VALUE)
{
m_error = "Unable to open COM port";
if (m_handle == INVALID_HANDLE_VALUE)
{
m_error = "Unable to open COM port";
@@
-77,7
+78,7
@@
bool CSerialPort::Open(string name, uint32_t baudrate, uint8_t databits, uint8_t
COMMCONFIG commConfig = {0};
DWORD dwSize = sizeof(commConfig);
commConfig.dwSize = dwSize;
COMMCONFIG commConfig = {0};
DWORD dwSize = sizeof(commConfig);
commConfig.dwSize = dwSize;
- if (GetDefaultCommConfig(
name
.c_str(), &commConfig,&dwSize))
+ if (GetDefaultCommConfig(
strComPath
.c_str(), &commConfig,&dwSize))
{
if (!SetCommConfig(m_handle, &commConfig,dwSize))
{
{
if (!SetCommConfig(m_handle, &commConfig,dwSize))
{
@@
-166,21
+167,21
@@
void CSerialPort::Close(void)
}
}
}
}
-int
32_t CSerialPort::Write(uint8_t* data, uint32_t len
)
+int
8_t CSerialPort::Write(CCECAdapterMessage *data
)
{
CLockObject lock(&m_mutex);
DWORD iBytesWritten = 0;
if (!m_bIsOpen)
return -1;
{
CLockObject lock(&m_mutex);
DWORD iBytesWritten = 0;
if (!m_bIsOpen)
return -1;
- if (!WriteFile(m_handle, data
, len
, &iBytesWritten, NULL))
+ if (!WriteFile(m_handle, data
->packet.data, data->size()
, &iBytesWritten, NULL))
{
m_error = "Error while writing to COM port";
FormatWindowsError(GetLastError(), m_error);
return -1;
}
{
m_error = "Error while writing to COM port";
FormatWindowsError(GetLastError(), m_error);
return -1;
}
- return iBytesWritten;
+ return
(int8_t)
iBytesWritten;
}
int32_t CSerialPort::Read(uint8_t* data, uint32_t len, uint64_t iTimeoutMs /* = 0 */)
}
int32_t CSerialPort::Read(uint8_t* data, uint32_t len, uint64_t iTimeoutMs /* = 0 */)