Recently we have connected one bluetooth device which receive data from our serial device. The bluetooth device further transmite this data to a Windows Mobile which is bluetooth enable. Baud rate of whole system is 19200 with 7 data bit and 1 stop bit and Even Parity.When we send command to serial device through bluetooth device it is accepting the command and respond accordingly. but some of data byte of string is desplay as question mark (?).
But in case we connect the serial device directly to PC, the string received is correct.
Code of vb.net program which I run in windows mobile is below:
Imports System
Imports System.IO.Ports
Imports System.Windows. Forms.TextBox
Public Class frmSelectComPor t
Dim WithEvent port1 as serialport = _
New SerialPort(“Com 2”,19200,Parity .Even, 7, StopBits.One)
Private Sub MnuConnect_Clic k(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MnuConnect.Clic k
If port1.IsOpen Then
port1.Close()
End If
port1.DtrEnable = True
port1.RtsEnable = True
port1.ReceivedB ytesThreshold = 1
port1.Open()
Dim str1,strcmd,str ReadSegment0 As String
Str1="09RD00000 1"
strchksum=23
strcmd = New String(Chr(2) + str1 + Chr(3) + strchksum) + Chr(0)
Delay(5000)
port1.Write(str cmd, 0, strcmd.Length)
System.Threadin g.Thread.Sleep( 70)
Delay(2000)
strReadSegment0 = port1.ReadExist ing
‘here I receive the following string "?09?D03?A D?
End Sub
Private Sub Delay(ByVal num As Double)
Dim i As Double
For i = 0 To num
Next
End Sub
End Class
Command Given to Serial Port is "09RD000001 23
Response given by Serial Port is "?09?D03?A D?
But I Expect the following input from serial port : "09RD033A DA
Kindly provide the solution ASAP
But in case we connect the serial device directly to PC, the string received is correct.
Code of vb.net program which I run in windows mobile is below:
Imports System
Imports System.IO.Ports
Imports System.Windows. Forms.TextBox
Public Class frmSelectComPor t
Dim WithEvent port1 as serialport = _
New SerialPort(“Com 2”,19200,Parity .Even, 7, StopBits.One)
Private Sub MnuConnect_Clic k(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MnuConnect.Clic k
If port1.IsOpen Then
port1.Close()
End If
port1.DtrEnable = True
port1.RtsEnable = True
port1.ReceivedB ytesThreshold = 1
port1.Open()
Dim str1,strcmd,str ReadSegment0 As String
Str1="09RD00000 1"
strchksum=23
strcmd = New String(Chr(2) + str1 + Chr(3) + strchksum) + Chr(0)
Delay(5000)
port1.Write(str cmd, 0, strcmd.Length)
System.Threadin g.Thread.Sleep( 70)
Delay(2000)
strReadSegment0 = port1.ReadExist ing
‘here I receive the following string "?09?D03?A D?
End Sub
Private Sub Delay(ByVal num As Double)
Dim i As Double
For i = 0 To num
Next
End Sub
End Class
Command Given to Serial Port is "09RD000001 23
Response given by Serial Port is "?09?D03?A D?
But I Expect the following input from serial port : "09RD033A DA
Kindly provide the solution ASAP
Comment