Modified MS/TP capture utility to emit the list of available COM ports on Windows when no command line argument is given.

This commit is contained in:
skarg
2013-10-07 17:35:44 +00:00
parent db1236d870
commit 35a8ef1ba2
3 changed files with 61 additions and 0 deletions
+23
View File
@@ -845,6 +845,24 @@ static BOOL WINAPI CtrlCHandler(
return TRUE;
}
/*************************************************************************
* Description: print available COM ports
* Returns: none
* Notes: none
**************************************************************************/
static void print_com_ports(void)
{
unsigned i = 0;
printf("List of available COM ports:\r\n");
/* try to open all 255 COM ports */
for (i=1; i<256; i++) {
if (RS485_Interface_Valid(i)) {
printf("COM%u\r\n", i);
}
}
}
#else
static void sig_int(
int signo)
@@ -945,6 +963,11 @@ int main(
}
if (argc > 1) {
RS485_Set_Interface(argv[1]);
} else {
#if defined(_WIN32)
print_com_ports();
return 0;
#endif
}
if (argc > 2) {
my_baud = strtol(argv[2], NULL, 0);