• Welcome to Forum.Deepsoftware.Com. Please login or sign up.
 
April 19, 2024, 09:23:32 pm

News:

SMF - Just Installed!


Show only USB/Serial Port

Started by fvpalha, August 11, 2011, 11:04:58 am

Previous topic - Next topic

fvpalha

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

August 11, 2011, 11:09:48 am #1 Last Edit: August 11, 2011, 11:14:50 am by fvpalha
More informations:

I am using the TnrDeviceBox component to show TnrComm component.

fvpalha

Doubt:

It's possible to use a filter? How?

hid1

Hello, In fact, you don't need TnrDeviceBox !

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

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

Hi hid1 and Roman.

Thank you.

This works very well.

int __fastcall WMDeviceChange(TMessage &Msg);


  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.