Author Topic: Show only USB/Serial Port  (Read 1301 times)

fvpalha

  • Newbie
  • *
  • Posts: 8
    • View Profile
Show only USB/Serial Port
« on: August 11, 2011, 02:04:58 pm »
Hello.

How I can show only serial port from USB device?

I have a device CP2102 (Silicon Labs) and I want to show just this port.

IdProduct: 4292  - (10C4h)
IdVendor: 60000 - (EA60h)

Regards.

fvpalha

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Show only USB/Serial Port
« Reply #1 on: August 11, 2011, 02:09:48 pm »
More informations:

I am using the TnrDeviceBox component to show TnrComm component.
« Last Edit: August 11, 2011, 02:14:50 pm by fvpalha »

fvpalha

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Show only USB/Serial Port
« Reply #2 on: August 11, 2011, 08:55:31 pm »
Doubt:

It's possible to use a filter? How?

hid1

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Re: Show only USB/Serial Port
« Reply #3 on: August 11, 2011, 10:03:52 pm »
Hello, In fact, you don't need TnrDeviceBox !

Code: [Select]
nrX.update;

for i:= 0 to  nrX.devicecount-1 do begin
   nrx.Active :=  nrx.device[i].devicFriendlyname = 'myPort';

   if nrx.Active then break


end;

Roman Novgorodov

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: Show only USB/Serial Port
« Reply #4 on: August 12, 2011, 04:42:48 am »
Hello

Serial port does not have VendorID and ProductID numbers.

The VendorID and ProductID are specific of USB.
But USB device can provide several type of logical devices at same time.

I can recommend you to detect needed port by analyzing nrComm1.Device.Manufacturer and  nrComm1.Device.Service properties.

And you can enumerate detected serial ports list in loop as Hid1 shows above.

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

fvpalha

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Show only USB/Serial Port
« Reply #5 on: August 12, 2011, 01:11:11 pm »
Hi hid1 and Roman.

Thank you.

This works very well.

Code: [Select]
int __fastcall WMDeviceChange(TMessage &Msg);
Code: [Select]
  bool status = false;

  nrComm->Update();
  nrDeviceBox->ItemIndex = -1;
  for (int i = 0; i < nrComm->DeviceCount; i++) {
  status = (nrComm->Device[i]->NamePDO == "\\Device\\Silabser0");
  if (status) {
  nrDeviceBox->ItemIndex = nrDeviceBox->Items->IndexOf(nrComm->Device[i]->NameFriendly);
  nrx->ComPortNo = nrComm->Device[i]->Data;
  break;
  }
  }

Now the user do not need to select the serial port.