Tôi đang tìm cách xác định xem COM có phải là COM chuẩn hay nếu nó là SPP COM, còn được gọi là bộ điều hợp bluetooth thay thế cáp cho thiết bị COM.Xác định xem cổng nối tiếp có bình thường là COM hay SPP
Tôi có một thiết bị hoạt động cả trong USB (COM -> USB) và Bluetooth và giao diện Bluetooth hoạt động với SPP.
Tôi hiện đang sử dụng System.IO.Ports.SerialPort.GetPortNames()
để nhận COM.
Có cách nào để xác định xem nó có được kết nối với Bluetooth hoặc USB không?
SOLUTION:
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()));
}
}
Và đầu ra là một cái gì đó tương tự:
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
Xem câu trả lời của tôi tại http://stackoverflow.com/questions/2085179/ how-can-i-find-out-a-com-port-number-of-a-bluetooth-thiết bị-in-c/2096728 # 2096728 và http://stackoverflow.com/questions/6850965/how-come- getdefaultcommconfig-doesnt-work-with-bluetooth-spp-devices/6997320 # 6997320 – alanjmcf