Pc Navigator 11 Free and TCP/IP interface
  • I use the free Pc Navigator 11 version and i try to communicate with through the TCP/IP interface!
    I use the PC version !
    Is it possible with the free version ?
  • 9 Comments sorted by
  • yes, it is also possible in free version
  • I have tried to create a little vb.net script that send tcp/ip command but that don't run !
    This is my code:
    Imports System.Net.Sockets
    Imports System.Net
    Imports System.Text

    Public Class Form1
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        End Sub

        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            WriteData("$destination=45.72813,8.98105;navigate\n", "")
        End Sub

        ''' <summary>
        ''' Send data over TCP/IP network
        ''' </summary>
        ''' <param name="data">Data string to write</param>
        ''' <param name="IP">The connected destination TcpClient</param>
        Public Sub WriteData(ByVal data As String, ByRef IP As String)
            'Console.WriteLine("Sending message """ & data & """ to " & IP)
            Dim client As TcpClient = New TcpClient()
            client.Connect(New IPEndPoint(IPAddress.Parse(IP), "4242"))
            Dim stream As NetworkStream = client.GetStream()
            Dim sendBytes As Byte() = Encoding.ASCII.GetBytes(data)
            stream.Write(sendBytes, 0, sendBytes.Length)
        End Sub

        Public Sub sendtonavigator()
            Dim host As IPAddress = Nothing
            Dim mySock As Socket = Nothing
                If Not IPAddress.TryParse("", host) Then
                    MessageBox.Show("Adresse non valide")
                    Exit Sub
                End If
                Dim ep As IPEndPoint = New IPEndPoint(host, Integer.Parse(4242))
                mySock = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
                If mySock.Connected Then
                End If
            Catch ex As Exception
            End Try
        End Sub

    End Class
    As you can see, i have tried two differents commands that don't run !
    Thanks for your help !
  • Is your Navigator configured to accept remote commands? (settings/Remote communication device)
    The simplest test is via telnet console.
  • Yes , my settings are :
  • I am not used to Basic, but ... can you keep the connection open? Navigator accepts only one connection. Also can you wait for Navigator response? It is possible that you terminate the connection even before Navigator reads the buffers.
  • Hoops,
    I don't know !
  • I have found a Python example on this link that i try without success (i don't know python)!

    The run option return me:
    Traceback (most recent call last):
      File "C:\tmp\VB.NET-2010\VB.NET Pc_Navigator_TCP-IP interface\python.py", line 5, in <module>
        telnet = Telnet( IP, PORT )
    NameError: name 'Telnet' is not defined
  • Ok, i worked a little beat on my issues and found to solutions, an autoit script (thanks to the french forum) and a VB.Net module.
    If you want to play with :
    Autoit script:
    #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
    #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

    #include <GUIConstantsEx.au3>

    Dim $command
    $port = "4242"
    $ip = ""
    Opt("TCPTimeout", 4000) ;100 milliseconds

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Send Commands to Pc Navigator", 400, 200, -1, -1)
    $Label2 = GUICtrlCreateLabel("Ip: "&$ip&"    "&"Port: "&$port, 10, 5, 390, 25)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
    $Label1 = GUICtrlCreateLabel("Pc Navigator return : ***", 10, 34, 390, 25)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
    $Combo1 = GUICtrlCreateCombo("", 64, 64, 300, 25)
    GUICtrlSetData(-1, "$destination=44.869740,-0.566483;navigate" & _
                        "|$window=100,500,1000,800,border" & _
                        "|$window=0,73,800,472,noborder" & _
                        "|$navigation_statistics" & _
                        "|$message="&chr(34)&"This is my message"&chr(34)&";instant" & _
                        "|$message="&chr(34)&"You check a YES/NO message"&chr(34)&";ask;instant" & _
                        "|$stop_navigation" & _
                        "|$last_position" & _
                        "|$sound_volume=0" & _
                        "|$sound_volume=100" & _
                        "|$minimize" & _
                        "|$restore" & _
                        "|exit" & _
                        "|$set_mode=day" & _
                        "|$set_mode=night" & _
                        "|$chat=message" & _
                        "|$software_version" & _
                        "|$protocol_version", "$destination=44.869740,-0.566483;navigate")
    $Button1 = GUICtrlCreateButton("Exit",300,150,80,30)
    #EndRegion ### END Koda GUI section ###

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE,$Button1

            Case $Combo1
                $command = GUICtrlRead($Combo1)
                $socket = TCPConnect($ip,$port)
                If $socket = -1 Then
                    MsgBox(16,"Erreur","Erreur de connexion : " & @error)
                $msgAEnvoyer = $command & @lf
                If Not $msgAEnvoyer = "" Then TCPSend($socket,$msgAEnvoyer)
                $recv = TCPRecv($socket,255)
                ;If Not $recv = "" Then MsgBox(64,"Message reçu","Le programme vous a renvoyé : " & $recv)
                If Not $recv = "" Then GuiCtrlSetData($Label1, "Pc Navigator return : "&$recv)
                TCPCloseSocket ( $socket )

  • The VB.NET version:

    Imports System.Net

    Imports System.Text

    Imports System.Net.Sockets

    Module TCPIPModule

        ' These vars can be formwide or local (in procedure) depending on how you want to use them.

        Dim remoteIPAddress As IPAddress

        Dim ep As IPEndPoint

        Dim tnSocket As Socket

        Dim txtRecv As String

        Public Function SendCommands(ByVal PIPAddress As String, ByVal PPort As String, ByVal Command As String)

            Dim RecvString As String = String.Empty

            Dim NumBytes As Integer = 0

            remoteIPAddress = IPAddress.Parse(PIPAddress.Trim)

            ep = New IPEndPoint(remoteIPAddress, CType(PPort.Trim, Integer))

            tnSocket = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)

            Dim SendBytes As [Byte]() = Encoding.ASCII.GetBytes(Command & vbLf)

            Dim RecvBytes(255) As [Byte]



            Catch oEX As SocketException

                ' error

                Exit Function

            End Try

            ' If we get to here then all seems good (we are connected)


                ' Wait a few seconds (3) (depending on connection) telnet can be slow.



                If tnSocket.Connected Then

                    tnSocket.Send(SendBytes, SendBytes.Length, SocketFlags.None)


                        NumBytes = tnSocket.Receive(RecvBytes, RecvBytes.Length, 0)

                        RecvString = RecvString + Encoding.ASCII.GetString(RecvBytes, 0, NumBytes)

                    Loop While NumBytes = 256

                    Return RecvString



                End If

            Catch oEX As Exception

                ' Error cleanup etc needed

            End Try

            remoteIPAddress = Nothing

            ep = Nothing

            tnSocket = Nothing

            Command = Nothing

            RecvString = Nothing

        End Function

        Private Sub Wait(ByVal PMillseconds As Integer)

            Dim TimeNow As DateTime

            Dim TimeEnd As DateTime

            Dim StopFlag As Boolean

            TimeEnd = Now()

            TimeEnd = TimeEnd.AddMilliseconds(PMillseconds)

            StopFlag = False

            While Not StopFlag

                TimeNow = Now()

                If TimeNow > TimeEnd Then

                    StopFlag = True

                End If


            End While

            TimeNow = Nothing

            TimeEnd = Nothing

        End Sub

    End Module

    I wish you a good use !!!

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion