Comments on: SerialTray – Terminal Emulator Launcher http://www.creativecodedesign.com/2010/04/01/serialtray-terminal-emulator-launcher/ ... Sun, 12 Jan 2014 03:07:32 +0000 hourly 1 https://wordpress.org/?v=4.7.6 By: Anonymous http://www.creativecodedesign.com/2010/04/01/serialtray-terminal-emulator-launcher/#comment-30 Mon, 30 Nov -0001 00:00:00 +0000 #comment-30 great tool. I had been trying ti implement similar for awhile but just didn’t get around to it so I am thankful for your work!

]]>
By: Anonymous http://www.creativecodedesign.com/2010/04/01/serialtray-terminal-emulator-launcher/#comment-64 Mon, 30 Nov -0001 00:00:00 +0000 #comment-64 I’ve been trying to do something similar and I’ve found problems with your method. Just because you find a friendly name with an active COM# in the name, does not mean that it is the device currently on the active port. Some of my devices have been installed as many different port number in the past, and all the old port numbers are still in the friendly names in the registry. There are also friendly names of different devises with the same COM#.

I have 4 USB serial devices currently connected to my computer and your app only correctly identified one of them. All the others listed friendly names of past devices.

There must be a method of pairing the active com ports to the correct friendly names, but you haven’t found it yet.

]]>
By: mediumrare http://www.creativecodedesign.com/2010/04/01/serialtray-terminal-emulator-launcher/#comment-74 Mon, 30 Nov -0001 00:00:00 +0000 #comment-74 Hi Anonymous, Did you come up with a solution to the old port numbers still being the registry. I have the same problem and don’t see an easy solution.
Thank you

]]>
By: Timur http://www.creativecodedesign.com/2010/04/01/serialtray-terminal-emulator-launcher/#comment-75 Mon, 30 Nov -0001 00:00:00 +0000 #comment-75 Hmf.. Do you guys by chance have some steps I could take to reproduce this issue? Do the devices that are now disconnected still show up in Device Manager in any form?

I guess my approach would start with exporting the key tree for an active device and exporting the key tree for the previously connected device and doing a diff on them, in hopes of identifying additional value settings that pertain to the state (like ConfigFlags or ActiveService maybe – just guessing)..

]]>
By: mediumrare http://www.creativecodedesign.com/2010/04/01/serialtray-terminal-emulator-launcher/#comment-76 Mon, 30 Nov -0001 00:00:00 +0000 #comment-76 The scenario I have is related to using COM ports for Bluetooth connections.
So in one case a user has installed Windows Bluetooth drivers and COM 4 had been assigned as one of the Windows Bluetooth ports – then I am not sure what the user did next ( maybe uninstalled the drivers – but the assignments persisted in the registry) However at some point after that – they installed a USB-serial convertor device and this also was “assigned” to COM 4.
Thus in my app I am utilizing a slightly modified version of your registry scanning method – but it is finding the Bluetooth COM 4 first in the registry and then my app concludes (wrongly) that COM 4 is a Bluetooth port. The only reason it is looking at COM 4 in the first place is because it is currently active as a USB-Serial converter port.
Here is a link I found that explains how to show hidden devices in Device Manager: http://support.microsoft.com/kb/241257
I have checked the ActiveService and ConfigFlags for the Windows Bluetooth Com ports – but they are not displayed in the registry for these ports. The path to these is HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Enum\BTHENUM\. All the windows virtual bluetooth com ports are listed here but I don’t see the difference between “active” and “inactive” ones.

]]>
By: Timur http://www.creativecodedesign.com/2010/04/01/serialtray-terminal-emulator-launcher/#comment-77 Mon, 30 Nov -0001 00:00:00 +0000 #comment-77 Well, I have a couple of suggestions but sadly no solutions.
First, I think you should modify the enumeration code to return a list instead of the dictionary. The list could contain an object (e.g. Dictionary) with COM port and the associated friendly name.. This way, at least you will solve the “last one wins” scenario, and get the ‘USB-Serial Converter’ along with the disconnected Bluetooth device.
Next step would be to figure out how to determine if the device is disconnected and remove it from the list. If Device Manager can do this, so can we (i hope :-)). I’d still try to do the diff on the …\enum\deviceName keys and check for anything obvious. The next step would maybe be to use the ClassId and see if there is anything relevant in the registry in keys like HKEY_LOCAL_MACHINE\SYSTEM\ControlSetxxx\Control\Class\{yourclassId} or other keys referencing that ClassId.
Please check back if you figure it out. Good luck!

]]>
By: mediumrare http://www.creativecodedesign.com/2010/04/01/serialtray-terminal-emulator-launcher/#comment-78 Mon, 30 Nov -0001 00:00:00 +0000 #comment-78 Thank you for the above guidance. I have added an extra check inside my slightly modified MineRegistryForPortName and this will only attempt to read get the FriendlyName of a COM port from DEVICEMAP\SERIALCOMM if it also has a Control subkey. This works for all devices I have tested so far, but there may be something out there that fails this check. Apologies for the formatting of what follows:

private void LatestMineRegistryForPortName(string startKeyPath, Dictionary targetMap, List portsToMap)
{
if (targetMap.Count >= portsToMap.Count)
return;

using (RegistryKey currentKey = Registry.LocalMachine)
{
try
{
using (RegistryKey currentSubKey = currentKey.OpenSubKey(startKeyPath, false))
{
if (currentSubKey != null)
{
string[] currentSubkeys = currentSubKey.GetSubKeyNames();
if (currentSubkeys.Contains("Device Parameters") && currentSubkeys.Contains("Control") &&
startKeyPath != "SYSTEM\\CurrentControlSet\\Enum")
{
object portName = Registry.GetValue("HKEY_LOCAL_MACHINE\\" +
startKeyPath + "\\Device Parameters", "PortName", null);
if (portName == null ||
portsToMap.Contains(portName.ToString()) == false)
return;

object friendlyPortName = Registry.GetValue("HKEY_LOCAL_MACHINE\\" + startKeyPath, "FriendlyName", null);
string friendlyName = "N/A";

if (friendlyPortName != null)
friendlyName = friendlyPortName.ToString();
if (friendlyName.Contains(portName.ToString()) == false)
friendlyName = string.Format("{0} ({1})", friendlyName, portName);
targetMap[portName.ToString()] = friendlyName;
}
else
{
foreach (string strSubKey in currentSubkeys)
LatestMineRegistryForPortName(startKeyPath + "\\" + strSubKey, targetMap, portsToMap);
}
}
}
}
catch (Exception ex)
{
loggingService.WriteException("MineRegistryForPortName", ex);
}
}
}

Let me know if any improvements can be made to this.

]]>