WinCE COM port doesn't work on low baud rates

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
 
D

Dick Grier

Hi,

Try CFSerialIO.dll from my homepage. I know that it works on my PPCs at 300
bps. I do not have your hardware, though...

All of these use similar calls to the underlying Windows serial
communications APIs, so I suspect that there is something else causing the
trouble.

Dick

--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top