mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-04-15 05:32:21 +00:00
Computrainer code to open COM ports above 9 on Windows
The docs for CreateFile indicate that to open a comm port above COM9 you must use a filespec of "\\.\COMX". The original code did not apply this rule and failed to open ports above COM9 as a result. This is especially important since it is quite common for the USB->Serial converters to assign an assignable comm port number.
This commit is contained in:
committed by
Sean Rhea
parent
d1d2037883
commit
1a96535708
@@ -842,8 +842,16 @@ int Computrainer::openPort()
|
||||
|
||||
COMMTIMEOUTS timeouts; // timeout settings on serial ports
|
||||
|
||||
wchar_t deviceFilenameW[32]; // COM1 needs 4 characters, 32 should be enough?
|
||||
MultiByteToWideChar(CP_ACP, 0, deviceFilename.toAscii(), -1, (LPWSTR)deviceFilenameW,
|
||||
// if deviceFilename references a port above COM9
|
||||
// then we need to open "\\.\COMX" not "COMX"
|
||||
QString portSpec;
|
||||
int portnum = deviceFilename.midRef(3).toString().toInt();
|
||||
if (portnum < 10)
|
||||
portSpec = deviceFilename;
|
||||
else
|
||||
portSpec = "\\\\.\\" + deviceFilename;
|
||||
wchar_t deviceFilenameW[32]; // \\.\COM32 needs 9 characters, 32 should be enough?
|
||||
MultiByteToWideChar(CP_ACP, 0, portSpec.toAscii(), -1, (LPWSTR)deviceFilenameW,
|
||||
sizeof(deviceFilenameW));
|
||||
|
||||
// win32 commport API
|
||||
|
||||
Reference in New Issue
Block a user