1

I'm trying to write a C++ program which automatically detects the COM Port numbers of all connected arduinos.

I already found that I can get a list of all available COM Port devices in HKLM/HARDWARE/DEVICEMAP/SERIALCOMM but there are no information about the device which is listening there. Is there a way to get for example the GUID or the device description to detect which one is the Arduino? The only other way I see is to try sending something to every port and listen for a previously defined response. Thank you for your responses :)

EDIT: I think I should mention that I use g++ as compiler and MinGW. syam has linked me this How to auto-detect Arduino COM port? which seems to achieve what I want but is written in C# and uses .Net specific APIs when I need pure Win32.

Community
  • 1
  • 1

2 Answers2

0

Serial ports devices are not Plug N Play, so you cannot get device description nor GUID. So is impossible auto detect Arduino using serial port technology.

Xearinox
  • 3,224
  • 2
  • 24
  • 38
  • but the arduino uses a usb2serial adapter wich is displayed in the hardware manager (including the COM port) –  Apr 24 '13 at 12:17
  • So your question is bad tagged. May have be usb not serial/com. – Xearinox Apr 24 '13 at 16:18
0

According to this article one way you can do that is by looking at the HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services:

  1. In the HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services there are several relevant subkeys: usbaudio, usbccgb, usbehci, usbprint, usbscan and so on. Arduino will probably be in usbccgb, usbehci, but honestly, I am not sure.
  2. The inside those keys you are looking for values whose names are numbers, such as 0, 1, etc.
  3. The value is the device ID

You can find out the device ID of any device from the windows Device manager: right-click on the device, select properties, and select the details tab. Obviously you can open the necessary registry key programmatically looking for the device ID of the Arduino device. The problem with this approach for your problem is that your Arduino detector must be pre-programmed for each Arduino you plan to use.

angelatlarge
  • 4,086
  • 2
  • 19
  • 36
  • Thank you, i will try this. Pre-programming the GUIDs should be no problem cause I do this for a school project and I can use the same device. –  Apr 24 '13 at 19:26
  • Pedantic note: It isn't a GUID technically, but, good, that should work. – angelatlarge Apr 24 '13 at 19:29