读取来自GNSS接收器的UDP数据报。

问题描述 投票:1回答:1

我正试图将来自Airlink MP70 GNSS网关的位置数据读入一个模拟控制台应用程序。GNSS 句子通过以太网和 UDP 发送到我的计算机。

网关 IP:192.168.13.31 (GNSS 接收器)源端口:17335。

目标IP:192.168.13.100端口:12351

我可以用wireshark看到UDP数据报。突出显示的区域是我要提取的GNSS数据。

enter image description here

我如何将这些数据接收到一个基本的控制台应用程序中,最好是c#,但c++java python也可以。

这是我目前所拥有的东西,但我没有看到任何输出(这只是微软c#网站上一个UDP客户端的基本代码)。

 private const int listenPort = 12351;

        public static void Main()
        {
            UdpClient receivingUdpClient = new UdpClient(listenPort);

            //Creates an IPEndPoint to record the IP Address and port number of the sender.
            // The IPEndPoint will allow you to read datagrams sent from any source.
            IPEndPoint RemoteIpEndPoint = new IPEndPoint(IPAddress.Any, 0);
            try
            {

                // Blocks until a message returns on this socket from a remote host.
                Byte[] receiveBytes = receivingUdpClient.Receive(ref RemoteIpEndPoint);

                string returnData = Encoding.ASCII.GetString(receiveBytes);

                Console.WriteLine("This is the message you received " +
                                          returnData.ToString());
                Console.WriteLine("This message was sent from " +
                                            RemoteIpEndPoint.Address.ToString() +
                                            " on their port number " +
                                            RemoteIpEndPoint.Port.ToString());
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
        }
c# sockets udp ip
1个回答
0
投票

我的错--是防火墙阻止了连接。谢谢那些帮助过我的人

© www.soinside.com 2019 - 2024. All rights reserved.