Author Topic: Better detection for Com0Com  (Read 4742 times)

moelski

  • Full Member
  • ***
  • Posts: 122
    • View Profile
Better detection for Com0Com
« on: June 15, 2009, 01:26:21 am »
Hi Roman,

NrComm detects not many properties from Com0Com ports:
Code: [Select]
NameFriendly - COM55
NamePDO - \Device\com0com10
NameDeviceDos - COM55
NameSymbolic -
RegKey -
Description -
Service -
Driver -
InstanceId -
BusRelations -
PortName -
Manufacturer -
GetNamePath - TnrDevice

Would you be able to detect the missing properties for Com0Com, too?
See http://com0com.sourceforge.net/

Greetz Dominik


Roman Novgorodov

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: Better detection for Com0Com
« Reply #1 on: June 15, 2009, 05:17:39 am »
Hello

Where do you see the correct information for this installed "open source" driver?
Does system Device Manager show info about Manufacturer or Description or other?

If you need to detect a virtual serial port Com0Com, you can analyze NamePDO string.
This value is formed by kernel driver and you can find substring "com0com" in it.

Roman Novgorodov
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

moelski

  • Full Member
  • ***
  • Posts: 122
    • View Profile
Re: Better detection for Com0Com
« Reply #2 on: June 15, 2009, 05:29:13 am »
Hi Roman,

Quote
Where do you see the correct information for this installed "open source" driver?
You can find it in the registry:
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\com0com\port

Quote
Does system Device Manager show info about Manufacturer or Description or other?
Yes. The device manager gets the manufacturer, the device type, driver details, ...

Quote
If you need to detect a virtual serial port Com0Com, you can analyze NamePDO string.
But it would be great if nrComm detects the ports himself.

Greetz Dominik

Roman Novgorodov

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: Better detection for Com0Com
« Reply #3 on: June 15, 2009, 05:42:46 am »
Quote
Yes. The device manager gets the manufacturer, the device type, driver details, ...

Show me.
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

moelski

  • Full Member
  • ***
  • Posts: 122
    • View Profile
Re: Better detection for Com0Com
« Reply #4 on: June 15, 2009, 05:49:03 am »
Hi Roman,

find the pictures attached:




Roman Novgorodov

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: Better detection for Com0Com
« Reply #5 on: June 15, 2009, 06:13:04 am »
Ooopppss....
I have understood. It seems you spend my time :-).

You see in the Device Manager NEW ORIGINAL Device Class "com0com"!!!
This class is not related with Port Window class. And you see this fact in your Device Manager.

TnrComm enums the serial port device class only.  
It can't know about all original device classes that are created by crazy teenagers from open source community :-)

Roman Novgorodov
« Last Edit: July 17, 2009, 09:09:29 pm by Roman Novgorodov »
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

moelski

  • Full Member
  • ***
  • Posts: 122
    • View Profile
Re: Better detection for Com0Com
« Reply #6 on: June 15, 2009, 06:19:23 am »
Hi !

Quote
It can't know about all original device classes that are created by crazy teenagers from open source community :-)
;D ;D

Ok but as far as I know there is only this one "special" solution. So it would be great if you think about adding it during enumeration.

moelski

  • Full Member
  • ***
  • Posts: 122
    • View Profile
Re: Better detection for Com0Com
« Reply #7 on: July 17, 2009, 12:08:09 pm »
Hi Roman,

any news on this topic?

Again I´m in the situation that the easiest way would be Com0Com (splitting one physical port into two virtual ports).
But nrcomm won´t detect the ports.  :(

Detecting NrComm is an easy task. You can do it with code like this:
Code: [Select]
procedure TForm1.Button1Click(Sender: TObject);
var regist : TRegistry;
    Test   : TStringList;
    i      : SmallInt;
    Resu   : String;
begin
  regist := TRegistry.Create;
  regist.RootKey := HKEY_LOCAL_MACHINE;
  // HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\com0com\port\xxxxxxxxx\Device Parameters
  regist.OpenKeyReadOnly('SYSTEM\CurrentControlSet\Enum\com0com\port\');
  Test := TStringList.Create;
  regist.GetKeyNames(Test);
  regist.CloseKey;
  for I := 0 to Test.Count - 1 do begin
    regist.OpenKeyReadOnly('SYSTEM\CurrentControlSet\Enum\com0com\port\' + Test[I] + '\Device Parameters');
    Resu := regist.ReadString('PortName') + ' (COM0COM - virtual serial Port)';
    nrDeviceBox1.Items.Add(Resu);
    regist.CloseKey;
  end;

  regist.free;
end;

It would really helpful if nrcomm could use / operate with Com0Com ports.

Roman Novgorodov

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: Better detection for Com0Com
« Reply #8 on: July 17, 2009, 09:34:45 pm »
Hello

In first post of this topic you say that Com0Com serial port was detected, but without a driver detail information.

Now this port is not detected at all?
What version of nrComm Lib do you use?

Roman Novgorodov
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

moelski

  • Full Member
  • ***
  • Posts: 122
    • View Profile
Re: Better detection for Com0Com
« Reply #9 on: July 18, 2009, 01:53:58 am »
Hello Roman,

ok let me explain it a little bit more precisely.  :)

There are different situations where nrcomm finds some portinformation or not.

Hint:
Com0Com is able to create ports which a different naming. Normal ports have names with this style COMxxx (where xxx is the port number). Com0Com can also create ports like this: CNCA0
You can access such ports with \\.\CNCA0. I think that´s the way how nrComm access ports, right ?

Com0Com is also able to rename ports from CNCA0 to COMxxx.


Ok now we have 6 situations ...
1) Com0Com port has a COMxxx name. nrComm1.EnumPorts := epQuickAll
This detects only the port COMxxx. No additional information is added. (See my first posting with the property list).
2) Com0Com port has a COMxxx name. nrComm1.EnumPorts := epFullPresent
nrComm won´t detect any Com0Com port. And we use epFullPresent in our application.
3) Com0Com port has a COMxxx name. nrComm1.EnumPorts := epQuickAll
This detects only the port COMxxx. No additional information is added. (See my first posting with the property list).

4) Com0Com port has a CNCxx name. nrComm1.EnumPorts := epQuickAll
nrComm won´t detect any Com0Com port.
5) Com0Com port has a CNCxx name. nrComm1.EnumPorts := epFullPresent
nrComm won´t detect any Com0Com port.
6) Com0Com port has a CNCxx name. nrComm1.EnumPorts := epQuickAll
nrComm won´t detect any Com0Com port.

I´ve done some tests with a very basic procedure:
Code: [Select]
procedure TForm1.Button3Click(Sender: TObject);
var NumberWritten:dword;
    PhoneNumber, CommPort:string;
    hCommFile:THandle;

    TimeOut : TCommTimeouts;
begin
  PhoneNumber := '0123456789';

  CommPort := '\\.\CNCA0';
  hCommFile := CreateFile(PChar(CommPort),
                          GENERIC_WRITE,
                          0,
                          nil,
                          OPEN_EXISTING,
                          FILE_ATTRIBUTE_NORMAL,
                          0);

  GetCommTimeOuts(hCommFile, TimeOut);

  TimeOut.ReadIntervalTimeOut := 100;
  TimeOut.ReadTotalTimeoutMultiplier := 0;
  TimeOut.ReadTotalTimeoutConstant := 250;

  TimeOut.WriteTotalTimeoutMultiplier := 0;
  TimeOut.WriteTotalTimeoutConstant := 200;
  SetCommTimeouts(hCommFile, TimeOut);

  WriteFile(hCommFile, PChar(PhoneNumber)^,
            Length(PhoneNumber), NumberWritten, nil);
  CloseHandle(hCommFile);
end;

This work really nice even with Com0Com ports. (PortMon is also capable of reading Com0com ports even if the name ic CNCxx!).

I saw in the sources that you use CreateFile, too. (function OpenPort(const n:integer):THandle;).
Maybe there must be an overloaded function which is also able to open Ports which have a different naming then "Format('COM%u',[n])".

And of course the detection of the Com0Com ports should be enhanced in order to get the ports also in epFullPresent mode (with details).

Greetings
   Dominik