none
GPS COM PORT RRS feed

  • 問題

  • 手機set 左gps 既com port 係com1,vb program 到open gps 既com1,

     

    Dim serial As New SerialPort("COM1", 4800)

    serial.Open()

     

    If (serial.IsOpen()) Then

    MsgBox("Connected to COM1",MsgBoxStyle.OkCancel, "")

    Else

    MsgBox("No COM1",MsgBoxStyle.OkCancel, "")

    End If

     

     

    This is the error: "COM1 doesn't exist". I've set GPS com port1, baud rate 4800, why fail to open com1? How to write VB to open serial port?

    2008年11月4日 上午 10:58

所有回覆

  •  BaseShow 寫信:

    手機set 左gps 既com port 係com1,vb program 到想gps 既com1,

     

    Dim serial As New SerialPort("COM1", 4800)

    serial.Open()

     

    If (serial.IsOpen()) Then

    MsgBox("Connected to COM1",MsgBoxStyle.OkCancel, "")

    Else

    MsgBox("No COM1",MsgBoxStyle.OkCancel, "")

    End If

     

     

    This is the error: "COM1 doesn't exist". I've set GPS com port1, baud rate 4800, why fail to open com1? How to write VB to open serial port?

     

    點解會出現這句error : "指定的通訊埠名稱無效。可能是有效通訊埠,但不是序列埠。 參數名稱: portName" ???

     

    MapKing2007: COM1, 4800

    ASUS P320: Hardware port: COM5, 4800

    VB program: COM1, 4800

    2008年11月4日 上午 11:32
  • Hi,

    如果你Hardware的Port是COM5,那麼在Visual Port中也要設定成COM5才對。

    可以參考下面這篇文章,裡面有如何去偵測的程式碼

    回覆:在PDA上開發GPS的程式問題 

    2008年11月5日 上午 10:46
    版主
  • I've read all GPS VB program realted in this forum and the other websites, but I can't find a solution to solve the problem of opening serial port in VB program.

     

    I've used your VB program but it really doesn't work. Following is your code:

     

    Code Snippet

    Imports System.IO.Ports

    Imports System.Text

     

    Public Class Form1

     

        Dim strPortName As String = ""

        Dim strTmp As String = ""

        Dim B(199) As Byte

        Dim intReturn As Integer = 0

     

        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

            SerialPort1.BaudRate = 4800

            SerialPort1.DataBits = 8

            SerialPort1.Handshake = Handshake.None

            SerialPort1.StopBits = StopBits.One

            SerialPort1.Parity = Parity.None

            SerialPort1.ReadTimeout = 2500

            For Each s As String In SerialPort.GetPortNames

                SerialPort1.PortName = s

                Try

                    SerialPort1.Open()

                    Threading.Thread.Sleep(200)

                    intReturn = SerialPort1.Read(B, 0, B.Length)

                    If intReturn > 0 Then

                        strTmp = Encoding.ASCII.GetString(B, 0, intReturn)

                        If strTmp.IndexOf("$GP") >= 0 Then

                            strPortName = SerialPort1.PortName

                            TextBox1.Text = strTmp

                        End If

                    End If

                    SerialPort1.Close()

                Catch ex As Exception

                    If SerialPort1.IsOpen Then SerialPort1.Close()

                End Try

            Next

        End Sub

    End Class

     

     

    Here is the error received from the VB program during implemention:

    指定的通訊埠名稱無效。可能是有效通訊埠,但不是序列埠。 參數名稱: portName"

     

    I am using the com4 in hardware in my smartphone, com4 in VB program, com1 in GPS on MapKing2007, com3 in ActiveSync4.5

     

    Everything seems perfect but 指定的通訊埠名稱無效。可能是有效通訊埠,但不是序列埠。 參數名稱: portName" , why???

     

    I want a solution. Anyone can tell me how to do?

     

     bauann 寫信:

    Hi,

    如果你Hardware的Port是COM5,那麼在Visual Port中也要設定成COM5才對。

    可以參考下面這篇文章,裡面有如何去偵測的程式碼

    回覆:在PDA上開發GPS的程式問題 

    2008年11月5日 上午 11:42
  • 你先用GPS Viewer去測試你的GPS,先確定出來你的GPS是哪一個COM,之後把任何會用到GPS的東西東關掉(例如導航軟體),再來測試你的程式

    GPS Viewer

    http://blog.yam.com/leo2016/article/13853575

     

    2008年11月5日 上午 11:54
    版主
  • 我已經set 左GPS COM1 係fix 左, 每次都係用com1, 知道GPS 用邊個COM咁有咩用? 我知道用左既COM 係唔可以用O係其他software, serial port 既問題仍然未解決.

     

    hardware com 係指 = 外部GPS hradware ???

     

    2008年11月5日 下午 02:01