From: Lars Op den Kamp Date: Thu, 10 Nov 2011 17:30:00 +0000 (+0100) Subject: win32: prepend the com port path with '\\.\', so com ports > 9 can be accessed. thank... X-Git-Tag: upstream/2.2.0~1^2~82 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=ff50391c4f0724c10c7bb19b927e29b92dc40cd3;p=deb_libcec.git win32: prepend the com port path with '\\.\', so com ports > 9 can be accessed. thanks smolesen --- diff --git a/src/lib/platform/windows/serialport.cpp b/src/lib/platform/windows/serialport.cpp index df619ef..9e4cc48 100644 --- 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) { + CStdString strComPath = "\\\\.\\" + name; 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"; @@ -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; - if (GetDefaultCommConfig(name.c_str(), &commConfig,&dwSize)) + if (GetDefaultCommConfig(strComPath.c_str(), &commConfig,&dwSize)) { if (!SetCommConfig(m_handle, &commConfig,dwSize)) {