From: yoavrofe on 18 Nov 2008 04:41 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
From: yoavrofe on 18 Nov 2008 04:51 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
From: Chris Tacke, eMVP on 18 Nov 2008 09:37 So what's the exception message? -- Chris Tacke, Embedded MVP OpenNETCF Consulting Giving back to the embedded community http://community.OpenNETCF.com "yoavrofe" <yoavrofe(a)gmail.com> wrote in message news:78d28a9b-e002-46a6-af13-db154c3b078a(a)l33g2000pri.googlegroups.com... > 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
From: yoavrofe on 18 Nov 2008 11:07 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.
From: Chris Tacke, eMVP on 18 Nov 2008 11:29
I can only assume that a *message* comes with that exception. My guess is that the port is in use. -- Chris Tacke, Embedded MVP OpenNETCF Consulting Giving back to the embedded community http://community.OpenNETCF.com "yoavrofe" <yoavrofe(a)gmail.com> wrote in message news:41c544b9-44ea-4ef7-bf2e-58a41c75b98d(a)l33g2000pri.googlegroups.com... > 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. |