• Welcome to Forum.Deepsoftware.Com. Please login or sign up.
 

Better detection for Com0Com

Started by moelski, June 14, 2009, 10:26:21 pm

Previous topic - Next topic

moelski

Hi Roman,

NrComm detects not many properties from Com0Com ports:
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

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

Hi Roman,

QuoteWhere 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

QuoteDoes system Device Manager show info about Manufacturer or Description or other?

Yes. The device manager gets the manufacturer, the device type, driver details, ...

QuoteIf 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

QuoteYes. 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

Hi Roman,

find the pictures attached:




Roman Novgorodov

June 15, 2009, 03:13:04 am #5 Last Edit: July 17, 2009, 06:09:29 pm by Roman Novgorodov
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
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

moelski

Hi !

QuoteIt 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

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:
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

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

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:
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