2

我有一个带有 TK06a 芯片组的 GPS 跟踪器,我有自己的 tcp 监听器,一切正常,我收到了来自设备的数据,格式如下:

#355488020131775##1#0000#AUT#01#52500100232a47#10341.175280,E,121.322800,N,0.28,0.00#111113#171607.000##

我想我知道这些是什么,(例如第一个是 IMEI),但我不知道如何将 (10341.175280,E) 和 (121.322800,N) 转换为谷歌地图可以理解的东西。

设备旁边的用户手册很差,也没有协议文档。

真正的位置应该在这里(1.355269,103.686426)也许这可以引导你解开这个谜:)

提前致谢。

编辑:

我在网上找到了这个,也许有些人会觉得它有用:

上面那行的解码。

  1. IMEI 号不能为空,如果 SIM 卡号作为设备序列号,则 IMEI 部分的数据应填写 SIM cad 号。
  2. SIM卡号:此部分可以为空,也可以和第1点一样,填写SIM卡号。
  3. 0或1,保留(原意为ACC状态)
  4. 设备密码(0-9位数字,不能超过6位,一般为4位)
  5. 保留字 AUT,不能更改。
  6. 数据的数量, 00-99 ,两位数。

每个数据的格式如下:

#base station number#Longitude, East and West identification, latitude,North and South identification,speed(nm), direction angle(0-360)#date#time
  1. 基站号可以为空。
  2. 经度,格式:dddff.ffff,度部分必须是3位整数,分部分必须是2位整数,小数部分是4位,度分之间没有分隔符。
  3. 东西方标识,只有一个字符,E/W。
  4. 纬度,格式:ddff.ffff,同经度,只有度数部分是2个整数。
  5. 南北识别,只有一个字符,N/S。
  6. 速度:可以为0。
  7. 方向:可以为 0。
  8. 日期,格式:ddmmyy。
  9. 时间,格式:hhnnss.mmm,小数点前应依次为时、分、秒,各为2位,小数点后应为毫秒,可以为000。
4

2 回答 2

3

此格式类似于 NMEA RMC 消息中的 DM,但缺少前导 0:

给定经度:10341.175280 E

前 3 位数字是度数:103
然后其余的是分钟数:41.175280
现在是格式“DM”度数和十进制分钟数。
Google 使用“DEG”(十进制度)
转换:103 + 41.175280 / 60.0 = 103.686254 (DEG = 度 + 分钟 / 60.0)
,非常适合您的位置

现在有点奇怪:
它应该读为“0121.322800”而不是“121.322800”
但与上面类似,但由于纬度限制为两位数:
前两位数总是度数:01
然后剩下的是分钟数:21.322800
与形式相同上图:lat= 1 + 21.322800 / 60.0 = 1,35538

最后:如果 W 或 S,将 deg 值乘以 -1(在您的情况下,它是 N 和 E,所以它保持原样 - 正数)

这种格式看起来有点像 NMEA RMC 语句

于 2013-11-11T21:21:32.823 回答
0

我想你想用 OpenGTS 来完成这项工作。

所以在这里我做了什么工作:(注意我不需要 tk10x 设备,所以我覆盖了文件,如果你愿意,你可以创建另一个类)

转到 $GTS_HOME/src/org/opengts/servers/tk10x

并使用此代码更改 TrackServer.java

我写了一个新的 parseInsertFunction

package org.opengts.servers.tk10x;

import java.lang.*;
import java.util.*;
import java.io.*;
import java.net.*;
import java.sql.*;

import org.opengts.util.*;
import org.opengts.db.*;
import org.opengts.db.tables.*;

public class TrackServer
{

// ------------------------------------------------------------------------
// initialize runtime configuration

public static void configInit()
{
    DCServerConfig dcs = Main.getServerConfig();
    if (dcs != null) {
        TrackServer.setTcpIdleTimeout(   dcs.getTcpIdleTimeoutMS(      Constants.TIMEOUT_TCP_IDLE   ));
        TrackServer.setTcpPacketTimeout( dcs.getTcpPacketTimeoutMS( Constants.TIMEOUT_TCP_PACKET ));
        TrackServer.setTcpSessionTimeout(dcs.getTcpSessionTimeoutMS(Constants.TIMEOUT_TCP_SESSION));
        TrackServer.setUdpIdleTimeout(   dcs.getUdpIdleTimeoutMS(   Constants.TIMEOUT_UDP_IDLE   ));
        TrackServer.setUdpPacketTimeout( dcs.getUdpPacketTimeoutMS( Constants.TIMEOUT_UDP_PACKET ));
        TrackServer.setUdpSessionTimeout(dcs.getUdpSessionTimeoutMS(Constants.TIMEOUT_UDP_SESSION));
    }
}

// ------------------------------------------------------------------------
// Start TrackServer (TrackServer is a singleton)

private static TrackServer trackServerInstance = null;

/* start TrackServer on array of ports */
public static TrackServer startTrackServer(int tcpPorts[], int udpPorts[], int commandPort)
    throws Throwable
{
    if (trackServerInstance == null) {
        trackServerInstance = new TrackServer(tcpPorts, udpPorts, commandPort);
    } else {
        //Print.logError("TrackServer already initialized!");
    }
    return trackServerInstance;
}

public static TrackServer getTrackServer()
{
    return trackServerInstance;
}

// ------------------------------------------------------------------------
// TCP Session timeouts

/* idle timeout */
private static long tcpTimeout_idle     = Constants.TIMEOUT_TCP_IDLE;
public static void setTcpIdleTimeout(long timeout)
{
    TrackServer.tcpTimeout_idle = timeout;
}
public static long getTcpIdleTimeout()
{
    return TrackServer.tcpTimeout_idle;
}

/* inter-packet timeout */
private static long tcpTimeout_packet   = Constants.TIMEOUT_TCP_PACKET;
public static void setTcpPacketTimeout(long timeout)
{
    TrackServer.tcpTimeout_packet = timeout;
}
public static long getTcpPacketTimeout()
{
    return TrackServer.tcpTimeout_packet;
}

/* total session timeout */
private static long tcpTimeout_session  = Constants.TIMEOUT_TCP_SESSION;
public static void setTcpSessionTimeout(long timeout)
{
    TrackServer.tcpTimeout_session = timeout;
}
public static long getTcpSessionTimeout()
{
    return TrackServer.tcpTimeout_session;
}

// ------------------------------------------------------------------------
// UDP Session timeouts

/* idle timeout */
private static long udpTimeout_idle     = Constants.TIMEOUT_UDP_IDLE;
public static void setUdpIdleTimeout(long timeout)
{
    TrackServer.udpTimeout_idle = timeout;
}
public static long getUdpIdleTimeout()
{
    return TrackServer.udpTimeout_idle;
}

/* inter-packet timeout */
private static long udpTimeout_packet   = Constants.TIMEOUT_UDP_PACKET;
public static void setUdpPacketTimeout(long timeout)
{
    TrackServer.udpTimeout_packet = timeout;
}
public static long getUdpPacketTimeout()
{
    return TrackServer.udpTimeout_packet;
}

/* total session timeout */
private static long udpTimeout_session  = Constants.TIMEOUT_UDP_SESSION;
public static void setUdpSessionTimeout(long timeout)
{
    TrackServer.udpTimeout_session = timeout;
}
public static long getUdpSessionTimeout()
{
    return TrackServer.udpTimeout_session;
}

// ------------------------------------------------------------------------
// ------------------------------------------------------------------------

// TCP port listener threads
private java.util.List<ServerSocketThread> tcpThread = new Vector<ServerSocketThread>();

// UDP port listener threads
private java.util.List<ServerSocketThread> udpThread = new Vector<ServerSocketThread>();

// Command port listener thread
private ServerSocketThread cmdThread = null;
private DatagramSocket     udpSocket = null;

// ------------------------------------------------------------------------

/* private constructor */
private TrackServer(int tcpPorts[], int udpPorts[], int commandPort)
    throws Throwable
{
    int listeners = 0;

    // Start TCP listeners
    if (!ListTools.isEmpty(tcpPorts)) {
        for (int i = 0; i < tcpPorts.length; i++) {
            int port = tcpPorts[i];
            if (ServerSocketThread.isValidPort(port)) {
                try {
                    this._startTCP(port);
                    listeners++;
                } catch (java.net.BindException be) {
                    Print.logError("TCP: Error binding to port: %d", port);
                }
            } else {
                throw new Exception("TCP: Invalid port number: " + port);
            }
        }
    }

    // Start UDP listeners
    if (!ListTools.isEmpty(udpPorts)) {
        for (int i = 0; i < udpPorts.length; i++) {
            int port = udpPorts[i];
            if (ServerSocketThread.isValidPort(port)) {
                try {
                    ServerSocketThread sst = this._startUDP(port);
                    if (this.udpSocket == null) {
                        this.udpSocket = sst.getDatagramSocket();
                    }
                    listeners++;
                } catch (java.net.BindException be) {
                    Print.logError("UDP: Error binding to port: %d", port);
                }
            } else {
                throw new Exception("UDP: Invalid port number: " + port);
            }
        }
    }

    /* do we have any active listeners? */
    if (listeners <= 0) {
        Print.logWarn("No active device communication listeners!");
    }

}

// ------------------------------------------------------------------------

/* start TCP listener */
private void _startTCP(int port)
    throws Throwable
{
    ServerSocketThread sst = null;

    /* create server socket */
    try {
        sst = new ServerSocketThread(port);
    } catch (Throwable t) { // trap any server exception
        Print.logException("ServerSocket error", t);
        throw t;
    }

    /* initialize */
    sst.setTextPackets(Constants.ASCII_PACKETS);
    sst.setBackspaceChar(null); // no backspaces allowed
    sst.setLineTerminatorChar(Constants.ASCII_LINE_TERMINATOR);
    sst.setIgnoreChar(Constants.ASCII_IGNORE_CHARS);
    sst.setMaximumPacketLength(Constants.MAX_PACKET_LENGTH);
    sst.setMinimumPacketLength(Constants.MIN_PACKET_LENGTH);
    sst.setIdleTimeout(TrackServer.tcpTimeout_idle);         // time between packets
    sst.setPacketTimeout(TrackServer.tcpTimeout_packet);     // time from start of packet to packet completion
    sst.setSessionTimeout(TrackServer.tcpTimeout_session);   // time for entire session
    sst.setTerminateOnTimeout(Constants.TERMINATE_ON_TIMEOUT);
    sst.setClientPacketHandlerClass(TrackClientPacketHandler.class);
    sst.setLingerTimeoutSec(Constants.LINGER_ON_CLOSE_SEC);

    /* start thread */
    Print.logInfo("Starting TCP listener thread on port " + port + " [timeout=" + sst.getSessionTimeout() + "ms] ...");
    sst.start();
    this.tcpThread.add(sst);

}

// ------------------------------------------------------------------------

/* start UDP listener */
private ServerSocketThread _startUDP(int port)
    throws Throwable
{
    ServerSocketThread sst = null;

    /* create server socket */
    try {
        sst = new ServerSocketThread(ServerSocketThread.createDatagramSocket(port));
    } catch (Throwable t) { // trap any server exception
        Print.logException("ServerSocket error", t);
        throw t;
    }

    /* initialize */
    sst.setTextPackets(Constants.ASCII_PACKETS);
    sst.setBackspaceChar(null); // no backspaces allowed
    sst.setLineTerminatorChar(Constants.ASCII_LINE_TERMINATOR);
    sst.setIgnoreChar(Constants.ASCII_IGNORE_CHARS);
    sst.setMaximumPacketLength(Constants.MAX_PACKET_LENGTH);
    sst.setMinimumPacketLength(Constants.MIN_PACKET_LENGTH);
    sst.setIdleTimeout(TrackServer.udpTimeout_idle);
    sst.setPacketTimeout(TrackServer.udpTimeout_packet);
    sst.setSessionTimeout(TrackServer.udpTimeout_session);
    sst.setTerminateOnTimeout(Constants.TERMINATE_ON_TIMEOUT);
    sst.setClientPacketHandlerClass(TrackClientPacketHandler.class);

    /* start thread */
    Print.logInfo("Starting UDP listener thread on port " + port + " [timeout=" + sst.getSessionTimeout() + "ms] ...");
    sst.start();
    this.udpThread.add(sst);
    return sst;

}

public DatagramSocket getUdpDatagramSocket()
{
    return this.udpSocket;
}

// ------------------------------------------------------------------------

}`

并在 Constant.java 中找到 'ASCII_LINE_TERMINATOR[]' 常量声明并将 '000' 添加到 with

public static final int     ASCII_LINE_TERMINATOR[]     = new int[] { 
    // this list has been construction by observation of various data packets
    0x00, 0xFF, 0xCE, '\0', '\n', '\r', ')', ';',000
};

在此之后 cd $GTS_HOME ant tk10x bin/runserver.sh -s tk10x

这应该可以解决问题

这是我创建的包的链接

https://anonfiles.com/file/0aae22ccb3822618fb693cd667283b18

于 2013-12-11T02:06:00.293 回答