【原创】wince bluebooth设备编程札记
来源:互联网 发布:python 定时发送邮件 编辑:程序博客网 时间:2024/05/20 18:51
【原创】wince bluebooth设备编程札记
Public Shared Function OpenBlueBoothSerialPort() As String Dim addr As BluetoothAddress = BluetoothAddress.Parse("002233445566") Dim sqlstr As String Dim DRow As System.Data.DataRow = Nothing Try Dim br As Microsoft.WindowsMobile.SharedSource.Bluetooth.BluetoothRadio = New Microsoft.WindowsMobile.SharedSource.Bluetooth.BluetoothRadio() ' '如果蓝牙设备不可见,则设置为可见状态,如果蓝牙设备被关闭会自动打开 ' If br.BluetoothRadioMode <> BluetoothRadioMode.Discoverable Then br.BluetoothRadioMode = BluetoothRadioMode.Discoverable End If BlueSelect.ShowDialog() '选择蓝牙设备 Dim endPoint As BluetoothEndPoint = New BluetoothEndPoint(addr, StandardServices.SerialPortServiceGuid) Dim port As BluetoothSerialPort = BluetoothSerialPort.CreateClient(endPoint) '创建串口端点 Return port.PortName Catch e As Exception End Try End Function.................以下为对串口的一般操作 Dim PortName As String If Frmmain.cmbComMode.Text.Contains("蓝牙") Then PortName = BlueBooth.OpenBlueBoothSerialPort() If String.IsNullOrEmpty(PortName) Then MessageBox.Show("选择端口有误!") Application.Exit() Exit Function End If Else PortName = DRow(4) End If Serial.CurrentSerialPort = Frmmain.SerialPort1 Serial.SendMode = Serial.SM_Frame Serial.DataMode = Serial.DM_Asc Serial.PortName = PortName Serial.BaudRate = CInt(DRow(2)) Serial.Parity = DRow(1) Serial.open().......
上面是蓝牙模拟串口的全部流程,使用中发现使用虚拟串口模式连接蓝牙设备时,运行一段时间总会突然丢失串口句柄。提示IO异常或无法找到串口。经测试怀疑为本方法库本身软件问题。
同时,试验中发现,使用蓝牙虚拟串口模式时,如果第一次创建虚拟串口成功时,第二次创建会失败,只有重新启动系统才能保证再次创建串口成功。一般使用方法第一次创建成功后记下串口名称,以后直接打开对应名称的串口设备即可。直到再次重启后才能再次创建成功。
0 0
- 【原创】wince bluebooth设备编程札记
- Windows编程学习札记:获取设备环境句柄
- 编程札记
- 编程札记
- Symbian 编程札记
- Linux编程札记
- MobileBASIC 编程札记 (一)
- CUDA编程札记
- CUDA编程札记
- 多线程编程札记
- windows编程学习札记
- 编程札记一
- CUDA编程札记
- WinCE获取设备ID
- WinCE设备驱动程序分类
- EVC连接WinCE设备
- Wince 添加蓝牙设备
- WMDC连接Wince设备
- Mysql 触发器
- 剑指Offer-->二叉搜索树的后序遍历序列
- 文本语言模型的参数估计-最大似然估计、MAP及贝叶斯估计
- 数据库第4个实验工作量蛮大的
- https://leetcode.com/problems/search-for-a-range/
- 【原创】wince bluebooth设备编程札记
- HTML5新特性之Communication
- UITabeViews---设置字体格式,大小,颜色
- 用例规约
- Linux tar 解压命令总结
- c# 调用Web Service的问题:The operation 'XXX' could not be loaded because it has a parameter...
- swustoj2521 acmer的约会—状态压缩+bfs
- AutoHotkey数组例子
- linux awk命令详解