TK06a GPS跟踪器协议:长/ Lat格式

时间:2013-11-11 19:12:11

标签: gps format latitude-longitude

我有一台带有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卡号。
  2.   
  3. SIM卡号:此部分可以为空,也可以与第一点相同,请填写SIM卡号。
  4.   
  5. 0或1,保留(原意是ACC状态)
  6.   
  7. 设备密码(0-9位数字,数字不能超过6位数,一般为4位数字)
  8.   
  9. 保留字AUT,无法更改。
  10.   
  11. 数据的数量,00-99,以2位数字显示。
  12.         

    每个数据的格式如下:

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

2 个答案:

答案 0 :(得分:3)

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

经度给出:10341.175280 E

前三位是度数:103
剩下的就是几分钟:41.175280
现在这是fomrat“DM”度和小数分钟 谷歌使用“DEG”(十进制度)
转换:103 + 41.175280 / 60.0 = 103.686254 (DEG =度+分/ 60.0)
这非常适合您的位置

现在有点奇怪:
它应为“0121.322800”而不是“121.322800” 但后来与上述类似,但由于纬度限制为两位数:
前2位数始终为度数:01
剩下的就是几分钟:21.322800
与上述相同的形式:lat = 1 + 21.322800 / 60.0 = 1,35538​​

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

此格式部分类似于NMEA RMC句子

答案 1 :(得分: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'到

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