1)GPS FM1100模块发送以下数据
IMEI
123456788927333
2)我们将01作为二进制发送到GPS模块(IMEI no.accepted,我们告诉模块发送原始数据)
3)GPS发送以下原始数据
原始数据
00000000000000ff08060000014e0fcd6c30011eb91b3a0f0db2f400120019090000010402010002000118000001c700000013000000014e102471e2011eb91b3a0f0db2f4001500190b0000010402010102000118000001c700000000000000014e10396d22011eb804c50f11f254fffd0000080000010402010002000118000001c700000000000000014e10e4c5c8011eb804c50f11f25400000000000000010402010102000118000001c700000000000000014e10f90df8011eb340ff0f045796000d0000090000010402010002000118000001c70000001a000000014e14605ba4011eb340ff0f045796001c0000090000010402010102000118000001c700000000000600001880
下面是解析后的数据,解析后我们发送no。收到的数据
例如:6作为对GPS模块的确认
Array
(
[timestamp] => 2015-06-10 04:38:48
[priority] => 1
[lng] => 51.5064245
[lat] => 25.1942671
[altitude] => 42
[angle] => 100
[statilite] => 10
[speed] => 0
[is_io_generated] => 1
[io_data] => Array
(
[No IO Rec] => 04
[Data] => Array
(
[0] => Array
(
[No Rec One Byte] => 2
[Data] => Array
(
[0] => Array
(
[key] => 1
[val] => 1
)
[1] => Array
(
[key] => 2
[val] => 0
)
)
)
[1] => Array
(
[No Rec Two Byte] => 1
[Data] => Array
(
[0] => Array
(
[key] => 24
[val] => 0
)
)
)
[2] => Array
(
[No Rec Four Byte] => 1
[Data] => Array
(
[0] => Array
(
[key] => 199
[val] => 0
)
)
)
[3] => Array
(
[No Rec Eight Byte] => 0
[Data] => Array
(
)
)
)
)
[1] => Array
(
[key] => 2
[val] => 0
)
)
)
[1] => Array
(
[No Rec Two Byte] => 1
[Data] => Array
(
[0] => Array
(
[key] => 24
[val] => 0
)
)
)
[2] => Array
(
[No Rec Four Byte] => 1
[Data] => Array
(
[0] => Array
(
[key] => 199
[val] => 0
)
)
)
[3] => Array
(
[No Rec Eight Byte] => 0
[Data] => Array
(
)
)
)
)
4)我们能够解析数据并将确认发送到GPS模块
5)但是,尽管发送了正确的确认数据,GPS模块仍会不断重复发送旧数据。
我们不确定是否以GPS模块手册中提到的正确格式发送确认数据。
请在这方面提供帮助。
)
if(strlen($rdata) == 15){
$this->imei = $rdata; // imei number from the gps module
$codata = pack("H*", "01"); // accept the connection and tell to the gps module to send the data
$this->server->send('current client socket', $codata); //send to the gps module
}else{
$bh = bin2hex($rdata); // from gps module rawdata bin to hex
$sql = $this->sqlparsingfm($bh); // parsing data
$sdata = $data["norecord"]; // parsed data from the GPS module. no of record received
$hex = str_pad($sdata, 8, "0", STR_PAD_LEFT);
// $hex = "0x06";
// $hex = pack("H*", "0x06");
$this->server->send($e->parameters->idClient, $hex);
}
if(strlen($rdata) == 15){
$this->imei = $rdata; // imei number from the gps module
$codata = pack("H*", "01"); // accept the connection and tell to the gps module to send the data
$this->server->send('current client socket', $codata); //send to the gps module
}else{
$bh = bin2hex($rdata); // from gps module rawdata bin to hex
$sql = $this->sqlparsingfm($bh); // parsing data
$sdata = $data["norecord"]; // parsed data from the GPS module. no of record received
$hex = str_pad($sdata, 8, "0", STR_PAD_LEFT);
// $hex = "0x06";
// $hex = pack("H*", "0x06");
$this->server->send($e->parameters->idClient, $hex);
}
以下是GPS模块文档链接
第7页。与服务器部分通信。将响应发送回模块
答案 0 :(得分:0)
首先,如果没有必要,请不要使用pack
。
所以,替换:
$codata = pack("H*", "01"); // accept the connection and tell to the gps module to send the data
$this->server->send('current client socket', $codata); //send to the gps module
与
$this->server->send('current client socket', "\x01");
接下来,要发送正确的数据包确认,请更改
$this->server->send($e->parameters->idClient, $hex);
到
$this->server->send($e->parameters->idClient, pack('N', $sdata));
这应该可以解决所有问题。