Bouyei.BdProto北斗导航车载定位终端通信数据包解析
车载定位终端北斗通信协议(JT/T808-2011协议)动态解析库。完成设备的数据包解析和封装支持。结合网络通信库与设备连接后通过该库进行数据包的解析和封装全过程双向通信操作。
static void Main(string[] args) { IPacketProvider pConvert = PacketProvider.CreateProvider(); string phone = "18212004771"; //终端连接鉴权平台回复通用应答,通信内容 byte[] body = new REQ_PB_8001().Encode(new PB8001() { MessageId = JT808Cmd.RSP_0102, Serialnumber = 0, Result = 0 }); //完整通信数据包格式 byte[] buffer = pConvert.Encode(new PacketFrom() { msgBody = body, msgId = JT808Cmd.REQ_8001, msgSerialnumber = 0, pEncryptFlag = 0, pSerialnumber = 1, pSubFlag = 0, pTotal = 1, simNumber = phone.ToBCD(), }); //socket通信可以使用Bouyei.NetFactory库(推荐.net) //socket.send(buffer); //解析终端发回的数据包 PacketMessage msg = pConvert.Decode(buffer,0,buffer.Length); //解析消息体内容 if (msg.pmPacketHead.phMessageId == JT808Cmd.RSP_0102) { PB0102 bodyInfo = new REP_PB_0102().Decode(msg.pmMessageBody); } else if (msg.pmPacketHead.phMessageId == JT808Cmd.RSP_0100) { PB0100 bodyinfo = new REP_PB_0100().Decode(msg.pmMessageBody); } }
评论