Sto cercando un modo per determinare se una COM è una COM standard o se è una COM SPP, nota anche come adattatore bluetooth sostitutivo via cavo per un dispositivo COM.Determinare se la porta seriale è normale COM o SPP
Ho un dispositivo che funziona sia in USB (COM -> USB) e Bluetooth, e l'interfaccia Bluetooth funziona con SPP.
Attualmente sto usando System.IO.Ports.SerialPort.GetPortNames()
per ottenere i COM.
C'è un modo per determinare se è connesso o meno con Bluetooth o USB?
SOLUZIONE:
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()));
}
}
e l'uscita è qualcosa di simile:
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
Guarda i miei risposte a http://stackoverflow.com/questions/2085179/ how-can-i-find-out-a-com-port-number-of-a-bluetooth-device-in-c/2096728 # 2096728 e http://stackoverflow.com/questions/6850965/how-come- getdefaultcommconfig-doesnt-work-with-bluetooth-spp-devices/6997320 # 6997320 – alanjmcf