从 GPS 设备读取数据

发布于 2025-01-03 07:54:28 字数 303 浏览 1 评论 0原文

我正在为我们的一位客户构建一个位置跟踪系统。他们在车辆上安装了 GPS 设备,每个设备都编程有服务器 IP 和端口号。 GPS 设备在给定的 IP 地址和端口上进行通信。我想读取来自GPS设备的数据包(如纬度、经度和其他信息,因为数据包包含二进制信息)而不执行任何读取操作。

我正在寻找什么:

A. 从设备读取数据并存储在某个中间位置,因为我们有 TCP 侦听器,设备通过该侦听器与我们通信。

B.我不想做任何操作,就像简单的那样,无论任何格式的数据,如果GPS设备发送到监听器,它必须监听并存储它,而不需要任何操作。

谢谢

I am building a location tracking system for one of our client. They have GPS devicees installed in vehicles and each device has programmed with a server IP and a port number. GPS device communicate on given IP address and port. I would like to read the packet comes from GPS device (like latitude, longitude and other information, as packet contains information in binary) without doing any read operation.

What i am looking for :

A. Read data from Device and store in some intermediate location, since we have TCP listener by which Device communicate with us.

B. I don't want to do any operation, as simple as that whatever or any format data, if GPS device sent to listener, it must listen ans store it, without any manipulation.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

夏见 2025-01-10 07:54:28

代码可能对您有帮助。

This code might help you.

杀お生予夺 2025-01-10 07:54:28

我提供了示例代码进行检查:

public class ServerListener {

public static void main(String[] args) {
    new ServerListener().startServer();
}

public void startServer() {
    final ExecutorService clientProcessingPool = Executors.newFixedThreadPool(03);

    Runnable serverTask = new Runnable() {
        @SuppressWarnings("resource")
        @Override
        public void run() {
            try {
                ServerSocket serverSocket = new ServerSocket(5094);
                System.out.println("Waiting for clients to connect...");
                while (true) {
                    Socket clientSocket = serverSocket.accept();
                    clientProcessingPool.submit(new ClientTask(clientSocket));
                }
            } catch (IOException e) {
                System.err.println("Unable to process client request");
                e.printStackTrace();
            }
        }
    };
    Thread serverThread = new Thread(serverTask);
    serverThread.start();
}

private class ClientTask implements Runnable {
    private final Socket clientSocket;

    private ClientTask(Socket clientSocket) {
        this.clientSocket = clientSocket;
    }

    @Override
    public void run() {
        System.out.println("Got a client !");
        while (true) {

        try {
            BufferedReader reader = new BufferedReader( new InputStreamReader(clientSocket.getInputStream()));
            String clientData = "";

            clientData = reader.readLine();
            System.out.println("clientdata::::"+clientData);


        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    }


 }
}

I provide sample code for it check:

public class ServerListener {

public static void main(String[] args) {
    new ServerListener().startServer();
}

public void startServer() {
    final ExecutorService clientProcessingPool = Executors.newFixedThreadPool(03);

    Runnable serverTask = new Runnable() {
        @SuppressWarnings("resource")
        @Override
        public void run() {
            try {
                ServerSocket serverSocket = new ServerSocket(5094);
                System.out.println("Waiting for clients to connect...");
                while (true) {
                    Socket clientSocket = serverSocket.accept();
                    clientProcessingPool.submit(new ClientTask(clientSocket));
                }
            } catch (IOException e) {
                System.err.println("Unable to process client request");
                e.printStackTrace();
            }
        }
    };
    Thread serverThread = new Thread(serverTask);
    serverThread.start();
}

private class ClientTask implements Runnable {
    private final Socket clientSocket;

    private ClientTask(Socket clientSocket) {
        this.clientSocket = clientSocket;
    }

    @Override
    public void run() {
        System.out.println("Got a client !");
        while (true) {

        try {
            BufferedReader reader = new BufferedReader( new InputStreamReader(clientSocket.getInputStream()));
            String clientData = "";

            clientData = reader.readLine();
            System.out.println("clientdata::::"+clientData);


        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    }


 }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文