Browse Source

TUI: Support for adding new devices using the plus key from [M]anage devices

Luke Dashjr 12 years ago
parent
commit
36b0c07e5b
1 changed files with 29 additions and 1 deletions
  1. 29 1
      miner.c

+ 29 - 1
miner.c

@@ -6380,6 +6380,8 @@ retry:
 	opt_loginput = false;
 	opt_loginput = false;
 }
 }
 
 
+int scan_serial(const char *);
+
 void manage_device(void)
 void manage_device(void)
 {
 {
 	char logline[256];
 	char logline[256];
@@ -6433,7 +6435,7 @@ refresh:
 	if (drv->proc_tui_wlogprint_choices && likely(cgpu->status != LIFE_INIT))
 	if (drv->proc_tui_wlogprint_choices && likely(cgpu->status != LIFE_INIT))
 		drv->proc_tui_wlogprint_choices(cgpu);
 		drv->proc_tui_wlogprint_choices(cgpu);
 	wlogprint("\n");
 	wlogprint("\n");
-	wlogprint("Or press Enter when done\n");
+	wlogprint("Or press Enter when done or the plus key to add more devices\n");
 	if (msg)
 	if (msg)
 	{
 	{
 		applog(LOG_DEBUG, "ManageTUI: %"PRIpreprv": %s", cgpu->proc_repr, msg);
 		applog(LOG_DEBUG, "ManageTUI: %"PRIpreprv": %s", cgpu->proc_repr, msg);
@@ -6503,6 +6505,32 @@ refresh:
 				} while (devices[selected_device]->device == mdev && selected_device > 0);
 				} while (devices[selected_device]->device == mdev && selected_device > 0);
 				goto devchange;
 				goto devchange;
 			}
 			}
+			case '+':  case '=':  // add new device
+			{
+				clear_logwin();
+				_wlogprint(
+					"Enter \"auto\", \"all\", or a serial port to probe for mining devices.\n"
+					"Prefix by a driver name and colon to only probe a specific driver.\n"
+					"For example: erupter:"
+#ifdef WIN32
+					"\\\\.\\COM40"
+#elif defined(__APPLE__)
+					"/dev/cu.SLAB_USBtoUART"
+#else
+					"/dev/ttyUSB39"
+#endif
+					"\n"
+				);
+				char *scanser = curses_input("Enter target");
+				if (scan_serial(scanser))
+				{
+					selected_device = total_devices - 1;
+					msg = "Device scan succeeded\n";
+				}
+				else
+					msg = "No new devices found\n";
+				goto devchange;
+			}
 			case 'Q': case 'q':
 			case 'Q': case 'q':
 			case KEY_BREAK: case KEY_BACKSPACE: case KEY_CANCEL: case KEY_CLOSE: case KEY_EXIT:
 			case KEY_BREAK: case KEY_BACKSPACE: case KEY_CANCEL: case KEY_CLOSE: case KEY_EXIT:
 			case '\x1b':  // ESC
 			case '\x1b':  // ESC