in BusTools/MinComm/main.cpp [935:997]
int __cdecl wmain (int argc, _In_reads_(argc) const wchar_t* argv[])
{
std::wstring devicePath;
auto paramMask = SerialParamMask();
auto dcb = DCB();
dcb.DCBlength = sizeof(DCB);
if (argc < 2) {
// connect to the first serial port found in the port's
// current configuration
devicePath = GetFirstDevice();
if (devicePath.empty()) {
fwprintf(
stderr,
L"No serial devices were found.\n");
return 1;
}
} else if (!_wcsicmp(argv[1], L"-?") || !_wcsicmp(argv[1], L"/?") ||
!_wcsicmp(argv[1], L"-h") || !_wcsicmp(argv[1], L"/h") ||
!_wcsicmp(argv[1], L"-help") || !_wcsicmp(argv[1], L"/help")) {
wprintf(Help, argv[0], argv[0], argv[0], argv[0], argv[0], argv[0]);
return 0;
} else if (!_wcsicmp(argv[1], L"-list") || !_wcsicmp(argv[1], L"/list")) {
try {
ListDevices();
} catch (const wexception& ex) {
std::wcerr << L"Error: " << ex.wwhat() << L"\n";
return 1;
}
return 0;
} else {
// if the first positional parameter contains an '=',
// take the first enumerated device.
int optind;
devicePath = argv[1];
if (devicePath.find_first_of(L'=') == devicePath.npos) {
optind = 2;
} else {
optind = 1;
devicePath = GetFirstDevice();
}
if (!ParseConnectionParams(
argc - optind,
argv + optind,
&dcb,
¶mMask)) {
return 1;
}
}
try {
RunSerialConsole(devicePath.c_str(), &dcb, paramMask);
} catch (const wexception& ex) {
std::wcerr << L"Error: " << ex.wwhat() << L"\n";
return 1;
}
return 0;
}