B
Bojan
I am working on some program that has to comunicate at low baud rates.
Problem is that data is sometime transmitted, and sometime not. There
is no pattern in that.
I tried it on HP6515 and Toradex Colibri evaluation board. HP6515 is
Pocket PC 2003, and Colibri is WM 5.0. I tried that from VS2003, and
VS2005. It is allways the same. I tried new System.IO.Ports.SerialPort
control in CF2. The problem persist.
I put some wireing connected to COM port and HyperTerminal to listen
data between PDA and my device. I even put osciloscope on TX line that
is triggered wit RTS line that goes high to make sure that data is
transmitted or not. Sometimes there is no data.
On baud rates higher than 2400 (4800,9600,19200...) the code work OK.
Here is my sample code. Just place new class in your project, and call
it with
Dim comTemp as New Comm
comTemp.SendData("Some data")
Public Class Comm
Private WithEvents COMctl As OpenNETCF.IO.Serial.Port
Public Sub OpenPort()
Dim setTemp As New OpenNETCF.IO.Serial.HandshakeNone
'Set port to 300 7 E 1
setTemp.BasicSettings.BaudRate =
OpenNETCF.IO.Serial.BaudRates.CBR_300
setTemp.BasicSettings.ByteSize = 7
setTemp.BasicSettings.Parity = OpenNETCF.IO.Serial.Parity.even
setTemp.BasicSettings.StopBits =
OpenNETCF.IO.Serial.StopBits.one
Me.COMctl = New OpenNETCF.IO.Serial.Port("COM1:", setTemp)
Me.COMctl.Open()
Me.COMctl.DTREnable = True 'DTR line drives device connected
on COM1
End Sub
Public Sub ClosePort()
Me.COMctl.DTREnable = False
Me.COMctl.Close()
Me.COMctl.Dispose()
MyBase.Finalize()
End Sub
Public Sub SendData(ByVal strOut As String)
Call OpenPort()
Dim buf() As Byte
buf = System.Text.ASCIIEncoding.ASCII.GetBytes(strOut)
Me.COMctl.RTSEnable = True 'needed to trigger osciloscope
COMctl.Output = buf
System.Threading.Thread.Sleep(500)
Me.COMctl.RTSEnable = False
Call ClosePort()
End Sub
End Class
Problem is that data is sometime transmitted, and sometime not. There
is no pattern in that.
I tried it on HP6515 and Toradex Colibri evaluation board. HP6515 is
Pocket PC 2003, and Colibri is WM 5.0. I tried that from VS2003, and
VS2005. It is allways the same. I tried new System.IO.Ports.SerialPort
control in CF2. The problem persist.
I put some wireing connected to COM port and HyperTerminal to listen
data between PDA and my device. I even put osciloscope on TX line that
is triggered wit RTS line that goes high to make sure that data is
transmitted or not. Sometimes there is no data.
On baud rates higher than 2400 (4800,9600,19200...) the code work OK.
Here is my sample code. Just place new class in your project, and call
it with
Dim comTemp as New Comm
comTemp.SendData("Some data")
Public Class Comm
Private WithEvents COMctl As OpenNETCF.IO.Serial.Port
Public Sub OpenPort()
Dim setTemp As New OpenNETCF.IO.Serial.HandshakeNone
'Set port to 300 7 E 1
setTemp.BasicSettings.BaudRate =
OpenNETCF.IO.Serial.BaudRates.CBR_300
setTemp.BasicSettings.ByteSize = 7
setTemp.BasicSettings.Parity = OpenNETCF.IO.Serial.Parity.even
setTemp.BasicSettings.StopBits =
OpenNETCF.IO.Serial.StopBits.one
Me.COMctl = New OpenNETCF.IO.Serial.Port("COM1:", setTemp)
Me.COMctl.Open()
Me.COMctl.DTREnable = True 'DTR line drives device connected
on COM1
End Sub
Public Sub ClosePort()
Me.COMctl.DTREnable = False
Me.COMctl.Close()
Me.COMctl.Dispose()
MyBase.Finalize()
End Sub
Public Sub SendData(ByVal strOut As String)
Call OpenPort()
Dim buf() As Byte
buf = System.Text.ASCIIEncoding.ASCII.GetBytes(strOut)
Me.COMctl.RTSEnable = True 'needed to trigger osciloscope
COMctl.Output = buf
System.Threading.Thread.Sleep(500)
Me.COMctl.RTSEnable = False
Call ClosePort()
End Sub
End Class