cannot open serial port

Y

yoavrofe

I'm trying to open a serial port on a CE device. This is a port used
by the GPS.
System.IO.Ports.SerialPort does not work, but OpenNETCF.IO.Serial.Port
does work. This happends only on a few models (QUE for example). Is
there something I'm missing?

Thanks!

Yoav.


I get:
" OpenNETCF.IO.Serial.Port opened
System.IO.Ports.SerialPort failed "


from the following code:


Sub test3()
Try

TextBox1.Text = ""

Dim s1 As OpenNETCF.IO.Serial.Port
'MsgBox("1")
Dim portSettings As
OpenNETCF.IO.Serial.DetailedPortSettings
portSettings = New OpenNETCF.IO.Serial.HandshakeNone()
'MsgBox("2")
s1 = New OpenNETCF.IO.Serial.Port("COM3:", portSettings)
'MsgBox("3")
s1.Open()
'MsgBox("4")
If s1.IsOpen Then
'MsgBox("5")
TextBox1.Text = "OpenNETCF.IO.Serial.Port opened" &
vbCrLf
s1.Close()
Else
'MsgBox("6")
TextBox1.Text = "OpenNETCF.IO.Serial.Port closed" &
vbCrLf
End If
Catch ex As Exception
'MsgBox("7")
TextBox1.Text = "OpenNETCF.IO.Serial.Port failed" & vbCrLf
End Try
'MsgBox("8")
'Exit Sub

Try
Dim s2 As New System.IO.Ports.SerialPort("COM1:")
s2.Open()
If s2.IsOpen Then TextBox1.Text &=
"System.IO.Ports.SerialPort OK" & vbCrLf : s2.Close()
Catch ex As Exception
TextBox1.Text &= "System.IO.Ports.SerialPort failed" &
vbCrLf
End Try
End Sub
 
Y

yoavrofe

of course, both use com1, not com3 as written above...




Sub test3()
Try


TextBox1.Text = ""


Dim s1 As OpenNETCF.IO.Serial.Port
'MsgBox("1")
Dim portSettings As
OpenNETCF.IO.Serial.DetailedPortSettings
portSettings = New OpenNETCF.IO.Serial.HandshakeNone()
'MsgBox("2")
s1 = New OpenNETCF.IO.Serial.Port("COM1:", portSettings)
'MsgBox("3")
s1.Open()
'MsgBox("4")
If s1.IsOpen Then
'MsgBox("5")
TextBox1.Text = "OpenNETCF.IO.Serial.Port opened" &
vbCrLf
s1.Close()
Else
'MsgBox("6")
TextBox1.Text = "OpenNETCF.IO.Serial.Port closed" &
vbCrLf
End If
Catch ex As Exception
'MsgBox("7")
TextBox1.Text = "OpenNETCF.IO.Serial.Port failed" &
vbCrLf
End Try
'MsgBox("8")
'Exit Sub


Try
Dim s2 As New System.IO.Ports.SerialPort("COM1:")
s2.Open()
If s2.IsOpen Then TextBox1.Text &=
"System.IO.Ports.SerialPort OK" & vbCrLf : s2.Close()
Catch ex As Exception
TextBox1.Text &= "System.IO.Ports.SerialPort failed" &
vbCrLf
End Try
End Sub
 
Y

yoavrofe

IOException

at System.IO.Ports.SerialStream.WinIOError()
at System.IO.Ports.SerialStream..ctor()
at System.IO.Ports.SerialPort.Open()
at test_serial_ports_cf2.Form1.test3()

Thanks!

Yoav.
 
D

Dick Grier

What is the actual error?

I'd speculate that something else (some other software) has already opened
the port.

--
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.
 
C

Chris Tacke, eMVP

It works becasue there's some difference. There's absolutely no way for us
to know why becasue we don't have your code or hardware. If the OpenNETCF
code works, use it. It's interface compatible with the CF implementation.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com
 
M

Markus Humm

It works becasue there's some difference. There's absolutely no way for us
to know why becasue we don't have your code or hardware. If the OpenNETCF
code works, use it. It's interface compatible with the CF implementation.
Yep, and when we tried it back then it didn't work on one single PDA (of
the ones we tested): HP iPAQ rx1950.

Greetings

Markus
 
C

Chris Tacke, eMVP

What didn't work? The OpenNETCF version? If so, it comes with full source
and should be "fixable" by anyone with time and a debugger.

The OP said that the CF version fails, but the OpenNETCF version works. If
that's the case, he should migrate or open a Microsoft support case. We
can't fix it for him.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com
 

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