2011-12-19 17 views
6

COM'un standart bir COM olup olmadığını veya COM aygıtının kablo değiştirme bluetooth adaptörü olarak da bilinen bir SPP COM mu olduğunu belirlemek için bir yol arıyorum.Seri bağlantı noktasının normal olup olmadığını belirleme COM veya SPP

Hem USB (COM -> USB) hem de Bluetooth'ta çalışan bir Bluetooth aygıtım var ve Bluetooth arabirimi SPP ile çalışıyor.

Şu anda COM'ları almak için System.IO.Ports.SerialPort.GetPortNames() kullanıyorum.

Bluetooth veya USB ile bağlı olup olmadığını belirlemenin bir yolu var mı?

ÇÖZÜM: Benzer

System.Management.ManagementObjectSearcher Searcher = new System.Management.ManagementObjectSearcher("Select * from WIN32_SerialPort"); 
foreach (System.Management.ManagementObject Port in Searcher.Get()) 
{ 
    foreach (System.Management.PropertyData Property in Port.Properties) 
    { 
     Console.WriteLine(Property.Name + " " + (Property.Value == null ? null : Property.Value.ToString())); 
    } 
} 

Ve çıkışı şey:

Availability 2 
Binary True 
Capabilities 
CapabilityDescriptions 
Caption Standard Serial over Bluetooth link (COM10) 
ConfigManagerErrorCode 0 
ConfigManagerUserConfig False 
CreationClassName Win32_SerialPort 
Description Standard Serial over Bluetooth link 
DeviceID COM10 
ErrorCleared 
ErrorDescription 
InstallDate 
LastErrorCode 
MaxBaudRate 9600 
MaximumInputBufferSize 0 
MaximumOutputBufferSize 0 
MaxNumberControlled 
Name Standard Serial over Bluetooth link (COM10) 
OSAutoDiscovered True 
PNPDeviceID BTHENUM\{00001101-0000-1000-8000-00805F9B34FB}_LOCALMFG&0000\8&3062A492&0&000000000000_0000001C 
PowerManagementCapabilities System.UInt16[] 
PowerManagementSupported False 
ProtocolSupported 
ProviderType RS232 Serial Port 
SettableBaudRate True 
SettableDataBits True 
SettableFlowControl True 
SettableParity True 
SettableParityCheck False 
SettableRLSD True 
SettableStopBits True 
Status OK 
StatusInfo 3 
Supports16BitMode False 
SupportsDTRDSR True 
SupportsElapsedTimeouts True 
SupportsIntTimeouts True 
SupportsParityCheck False 
SupportsRLSD True 
SupportsRTSCTS True 
SupportsSpecialCharacters False 
SupportsXOnXOff False 
SupportsXOnXOffSet False 
SystemCreationClassName Win32_ComputerSystem 
SystemName JVALDRON-PC 
TimeOfLastReset 
+0

http://stackoverflow.com/questions/2085179/ benim cevaplarını göster Nasıl-can-ı-bulmak-out-a-com-port-numarası-of-a-bluetooth aygıtı-c/2096728 # 2096728 ve http://stackoverflow.com/questions/6850965/how-come- getdefaultcommconfig-çalışma-ile-bluetooth-spp-cihazlar/6997320 # 6997320 – alanjmcf

cevap

6

Sen SerialPort sınıfı yoluyla bu bilgi edinmek mümkün değildir. Bir WMI sorgusu yapmalısınız.

bu satırlar boyunca bir şey yapmak o yüzden seni elde edebilirsiniz ileri hangi özellikleri bilmiyorum yüklenen bu kodu yok

ManagementObjectSearcher searcher = new ManagementObjectSearcher("Select * 
             from WIN32_SerialPort"); 

foreach(ManagementObject Port in searcher.Get()) { 

     string a = (string) Port.GetPropertyValue("Name"); 

} 

götürebilir. Ancak yine de, WMI bunu yapmanın yolu olacaktı. Ben senin bir Bluetooth bakarak bkz

+0

Mükemmel! Kullandığım kodu ve başkasına ihtiyaç duyarsa çıktıyı yayınlayacağım. – jValdron

+0

Çalıştığını görmek harika. –

0

cihazı bağlantı:

Sorgu Win32_PnPSignedDriver ve InfName özelliği bakmak. Değer bthspp.inf

olmalıdır. Inf dosyasının her satıcının SPP protokolünü destekleyen bluetooth aygıtı için DAİMA adı olacağını kesin olarak söyleyemem, ancak bu varsayılan değerdir.

Sınıf GUID COM için & LPT portları edilir: {4d36e978-E325-11CE-BFC1-08002BE10318} Ref: https://msdn.microsoft.com/en-us/library/windows/hardware/ff553426

ManagementObjectSearcher Searcher = new ManagementObjectSearcher(computer + @"root\cimv2", 
       "SELECT * FROM Win32_PnPSignedDriver " 
      + "WHERE ClassGuid = '{4d36e978-e325-11ce-bfc1-08002be10318}' " 
      +  AND DeviceID LIKE 'BTHENUM%' 
      ); 
İlgili konular