123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- /********************************************************************************
- * File Name: ProtocolPack.h
- * Function Describe: Header file for ProtocolPack.c
- * Explain:
- * Writer: ShiLiangWen
- * Date: 2019-2-9
- *******************************************************************************/
- #ifndef __PROTOCOL_PACK_H
- #define __PROTOCOL_PACK_H
- //-------------------------------------------------------------------------------
- //#include "MyUHFReader.h"
-
- #define PROPACKET_BUF_LEN 1200
- #define MSGID_UPGRADE 0xA902
- #define MSGID_IOT 0xA901//0xC900
- #define MSGID_LOGIN 0xA903//0x0929
- #define MSGID_POSITION 0xA904//0x0200
- #define MSGID_DOWNCMD 0xA905
- #define MSGID_ARRANGE 0xA906
- #define MSGID_VOICE_EVENT 0xA907
- #define MSGID_VOICE_INFO 0xA908
- #define MSGID_VOICE_DATA 0xA909
- #define MSGID_VOICE_AUTH 0xA910
- #define MSGID_VOICE_LOAD_INFO 0xB908
- #define MSGID_VOICE_LOAD_DATA 0xB909
- #define MSGID_VOICE_LOAD_AUTH 0xB910
- #define MSGID_VOICE_LOAD_TTS 0xB911
- #define MSGID_M_POSITION 0x0704
- #define MSGID_TICK 0x0002
- #define MSGID_LOGINACK 0x8929
- #define MSGID_COMACK 0x8001
- #define EXTRA_MSG_ID 0x3E
- #define EPC_NUM_MAX 25 //1°üÊý¾ÝÔÊÐí´øµÄEPC ¸öÊý
- #define EPC_LEN_MAX (7+2) //EPC±àÂ볤¶È
- #define PACKET_CONVERT_LEN_OVER -55
- #define PROTO_FLAG 0x5e
- //½á¹¹ÌåSUTDL ÓÃÓÚ½â¾öÍøÂç´«Êäunsigned longÀàÐÍʱ£¬ÒòMCUϵͳºÍPCϵͳ´æ´¢²îÒì¶ø×öµÄµ÷Õû
- typedef struct SUTDL
- {
- union {
- struct { unsigned char b1,b2,b3,b4; }ucData;
- unsigned long ulData;
- }Data;
- }SUTDL;
- //½á¹¹ÌåSUTDL ÓÃÓÚ½â¾öÍøÂç´«Êäunsigned shortÀàÐÍʱ£¬ÒòMCUϵͳºÍPCϵͳ´æ´¢²îÒì¶ø×öµÄµ÷Õû
- typedef struct SUTDS
- {
- union {
- struct { unsigned char b1,b2; }ucData;
- unsigned short usData;
- }Data;
- }SUTDS;
- typedef struct SUT_PROPACKET
- {
- unsigned char *pSendBuf;
- unsigned char *pRecvBuf;
- unsigned short SendBufLen;
- unsigned short RecvBufLen;
- unsigned char DeviceID[6];
- }SUT_PROPACKET;
- extern SUT_PROPACKET sutPropacket;
-
-
- typedef struct SUT_POS_ALARM{
- unsigned int NU1:4;//δÓÃ
- unsigned int GNSS:1;//bit 4 ¶¨Î»Ä£¿é
- unsigned int NU2:10;//δÓÃ
- unsigned int Meter:1;//bit 15 Ë®±í
- unsigned int NU3:16;//δÓÃ
- }__attribute__((packed)) SUT_POS_ALARM;
- typedef struct SUT_POS_STATUS{
- unsigned int ACC:1;//0 0£ºACC ¹Ø£»1£º ACC ¿ª
- unsigned int GNSS:1;//1 0£ºÎ´¶¨Î»£»1£º¶¨Î»
- unsigned int South:1;//2 0£º±±Î³£»1£ºÄÏγ
- unsigned int West:1;//3 0£º¶«¾£»1£ºÎ÷¾
- unsigned int NU1:14;//4~17 δÓÃ
- unsigned int GPS:1;//18 0£ºÎ´Ê¹Óà GPS ÎÀÐǽøÐж¨Î»£»1£ºÊ¹Óà GPS ÎÀÐǽøÐж¨Î»
- unsigned int BD:1;//19 0£ºÎ´Ê¹Óñ±¶·ÎÀÐǽøÐж¨Î»£»1£ºÊ¹Óñ±¶·ÎÀÐǽøÐж¨Î»
- unsigned int GLONASS:1;//20 0£ºÎ´Ê¹Óà GLONASS ÎÀÐǽøÐж¨Î»£»1£ºÊ¹Óà GLONASS ÎÀÐǽøÐж¨Î»
- unsigned int Galileo:1;//21 0£ºÎ´Ê¹Óà Galileo ÎÀÐǽøÐж¨Î»£»1£ºÊ¹Óà Galileo ÎÀÐǽøÐж¨Î»
- unsigned int NU2:10;//22-31 ±£Áô
- }__attribute__((packed)) SUT_POS_STATUS;
- typedef struct SUT_POSITION
- {
- unsigned char flag;//´æ´¢±êÖ¾£¬Óд洢Ϊ0£¬Î޴洢ΪFF
- SUT_POS_ALARM Alarm;//0 ±¨¾¯±êÖ¾ DWORD ±¨¾¯±ê־붨Òå¼û ±í 24
- SUT_POS_STATUS Status;//4 ״̬ DWORD ״̬붨Òå¼û ±í 25
- unsigned int Latitude;//8 γ¶È DWORD ÒÔ¶ÈΪµ¥Î»µÄγ¶ÈÖµ³ËÒÔ10µÄ6´Î·½£¬ ¾«È·µ½°ÙÍò·ÖÖ®Ò»¶È
- unsigned int Longitude;//12 ¾¶È DWORD ÒÔ¶ÈΪµ¥Î»µÄ¾¶ÈÖµ³ËÒÔ10µÄ6´Î·½£¬ ¾«È·µ½°ÙÍò·ÖÖ®Ò»¶È
- unsigned short Altitude; //16 ¸ß³Ì WORD º£°Î¸ß¶È£¬µ¥Î»ÎªÃ×£¨m£©
- unsigned short Speed;//18 ËÙ¶È WORD 1/10km/h
- unsigned short Aspect;//20 ·½Ïò WORD 0-359£¬Õý±±Îª 0£¬Ë³Ê±Õë
- unsigned char Time[6];//21 ʱ¼ä BCD[6] YY-MM-DD-hh-mm-ss£¨GMT+8 ʱ¼°µÄʱ¼ä¾ù²ÉÓôËʱÇø£©
- //ÉÏÃæÒÑÕ¼29bytes
- //¸½¼ÓÐÅÏ¢
- unsigned char ExtraMsgId;//¸½¼ÓÐÅÏ¢ID
- unsigned char ExtraMsgLen;//¸½¼ÓÐÅÏ¢³¤¶È --³¤¶È¹Ì¶¨Îª´ÓÏÂÒ»Ïʼµ½½á¹¹Ìå×îºóµÄ³¤¶È
- unsigned char GpsNum;
- unsigned char BDNum;
- unsigned char PDOP;
- unsigned short Ax;
- unsigned short Ay;
- unsigned short Az;
- unsigned short Mx;
- unsigned short My;
- unsigned short Mz;
- //ÉÏÃæÒÑÕ¼29+17=46bytes
- unsigned char EPCNum;//EPCÁбíÖÐÓÐЧµÄEPC¸öÊý
- //sutEPCInfoSaving EpcList[EPC_NUM_MAX];//EPCÁбí ×î¶àEPC_LIST_MAX×é ÿ¸öEPCInfo³¤¶ÈΪ8bytes
- unsigned char Res[5];//±£Áô£¬Ê¹Õ¼ÓÃ256 bytes
- unsigned long Mark;//´æ´¢±êÖ¾ 0x12345678
- }__attribute__((packed)) SUT_POSITION;
- void ProtocolPackInit(unsigned long DeviceId,unsigned char *pSendBuf,unsigned short SendBufLen,unsigned char *pRecvBuf,unsigned short RecvBufLen);
- int PacketIOT(unsigned short MsgNum);
- int PacketTick(unsigned short MsgNum);
- int PacketLogin(unsigned short MsgNum);
- int PacketPosition(unsigned short MsgNum,int max_size);
- int PacketMorePosition(unsigned short MsgNum);
- int PackeUpgradeAck(unsigned short MsgNum,unsigned short ackliushui,unsigned char result);
- void PacketConvertTest(void);
- void PacketDeConvertTest(void);
- int CheckPacket(unsigned char *pData,unsigned short DataLen,unsigned short *);
- unsigned short crc16Check(unsigned short initValue,unsigned char *pBuf,int i);
- //-------------------------------------------------------------------------------
- #include "plyRec.h"
- #define MAX_SUB_PACKET_NUM MAX_FRAMS_PCM_DATA/(MAX_USER_DATA_SIZE/2) //上传下载最大分包数,48K总数量最大量,我们按每包最大的MAX_USER_DATA_SIZE算,直接除去2,预算最大,实际没这么大
- typedef struct{
- unsigned char packetindex;
- unsigned short packetlen;
- unsigned char *packetdata;
- }PACKET_DEF;
- typedef struct{
- unsigned char packetnum;
- PACKET_DEF pInfo[MAX_SUB_PACKET_NUM];
- }PACKETLIST_DEF;
- typedef struct{
- unsigned char packetindex;
- unsigned short packetlen;
- }PACKET2_DEF;
- unsigned int getOverBytes(void);
- #endif
-
|