Merge pull request #3110 from Cacodemon345/qt-compile-fix
Serial passthrough fixes on Windows
This commit is contained in:
@@ -46,6 +46,9 @@ extern "C" {
|
|||||||
# include <sys/stat.h>
|
# include <sys/stat.h>
|
||||||
# include <sys/sysmacros.h>
|
# include <sys/sysmacros.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef Q_OS_WINDOWS
|
||||||
|
#include <windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
DeviceConfig::DeviceConfig(QWidget *parent)
|
DeviceConfig::DeviceConfig(QWidget *parent)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
@@ -77,9 +80,15 @@ EnumerateSerialDevices()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef Q_OS_WINDOWS
|
#ifdef Q_OS_WINDOWS
|
||||||
QSettings comPorts("HKEY_LOCAL_MACHINE\\HARDWARE\\DEVICEMAP\\SERIALCOMM", QSettings::NativeFormat, nullptr);
|
for (int i = 1; i < 256; i++) {
|
||||||
for (int i = 0; i < comPorts.childKeys().length(); i++) {
|
devstr[0] = 0;
|
||||||
serialDevices.push_back(QString("\\\\.\\") + comPorts.value(comPorts.childKeys()[i]).toString());
|
snprintf(devstr.data(), 1024, "\\\\.\\COM%d", i);
|
||||||
|
auto handle = CreateFileA(devstr.data(), GENERIC_READ | GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, 0, 0);
|
||||||
|
auto dwError = GetLastError();
|
||||||
|
if (handle != INVALID_HANDLE_VALUE || (handle == INVALID_HANDLE_VALUE && ((dwError == ERROR_ACCESS_DENIED) || (dwError == ERROR_GEN_FAILURE) || (dwError == ERROR_SHARING_VIOLATION) || (dwError == ERROR_SEM_TIMEOUT)))) {
|
||||||
|
if (handle != INVALID_HANDLE_VALUE) CloseHandle(handle);
|
||||||
|
serialDevices.push_back(QString(devstr));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef Q_OS_MACOS
|
#ifdef Q_OS_MACOS
|
||||||
|
@@ -73,9 +73,6 @@ plat_serpt_write_vcon(serial_passthrough_t *dev, uint8_t data)
|
|||||||
// fwrite(dev->master_fd, &data, 1);
|
// fwrite(dev->master_fd, &data, 1);
|
||||||
DWORD bytesWritten = 0;
|
DWORD bytesWritten = 0;
|
||||||
WriteFile((HANDLE) dev->master_fd, &data, 1, &bytesWritten, NULL);
|
WriteFile((HANDLE) dev->master_fd, &data, 1, &bytesWritten, NULL);
|
||||||
if (bytesWritten == 0) {
|
|
||||||
fatal("serial_passthrough: WriteFile pipe write-buffer full!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Reference in New Issue
Block a user