san.kothari2002
New member
- Joined
- Jan 16, 2010
- Messages
- 1
- Programming Experience
- 3-5
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.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 frmSelectComPort
Dim WithEvent port1 as serialport = _
New SerialPort(“Com2”,19200,Parity.Even, 7, StopBits.One)
Private Sub MnuConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MnuConnect.Click
If port1.IsOpen Then
port1.Close()
End If
port1.DtrEnable = True
port1.RtsEnable = True
port1.ReceivedBytesThreshold = 1
port1.Open()
Dim str1,strcmd,strReadSegment0 As String
Str1="09RD000001"
strchksum=23
strcmd = New String(Chr(2) + str1 + Chr(3) + strchksum) + Chr(0)
Delay(5000)
port1.Write(strcmd, 0, strcmd.Length)
System.Threading.Thread.Sleep(70)
Delay(2000)
strReadSegment0 = port1.ReadExisting
‘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 frmSelectComPort
Dim WithEvent port1 as serialport = _
New SerialPort(“Com2”,19200,Parity.Even, 7, StopBits.One)
Private Sub MnuConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MnuConnect.Click
If port1.IsOpen Then
port1.Close()
End If
port1.DtrEnable = True
port1.RtsEnable = True
port1.ReceivedBytesThreshold = 1
port1.Open()
Dim str1,strcmd,strReadSegment0 As String
Str1="09RD000001"
strchksum=23
strcmd = New String(Chr(2) + str1 + Chr(3) + strchksum) + Chr(0)
Delay(5000)
port1.Write(strcmd, 0, strcmd.Length)
System.Threading.Thread.Sleep(70)
Delay(2000)
strReadSegment0 = port1.ReadExisting
‘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