2 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 * @file MDev_GpsRecv.h
20 #ifndef INC_GPSCOMMON_MDEV_GPSRECV_H_
21 #define INC_GPSCOMMON_MDEV_GPSRECV_H_
23 /*---------------------------------------------------------------------------*/
27 #include "positioning_def.h"
29 /*---------------------------------------------------------------------------*/
32 /* ++ GPS _CWORD82_ support */
33 #define GPS__CWORD82__CMD_LEN_MAX 200
34 /* -- GPS _CWORD82_ support */
36 /* ++ GPS _CWORD82_ support */
37 #define GPS__CWORD82__RET_START_SEQ_NONE 0 /* _CWORD82_ Start Sequence Determination Result = None */
38 #define GPS__CWORD82__RET_START_SEQ_NMEA 1 /* _CWORD82_ Start Sequence Determination Result = NMEA */
39 #define GPS__CWORD82__RET_START_SEQ_FULL 2 /* _CWORD82_ Start Sequence Determination Result = Full customization */
40 #define GPS__CWORD82__RET_START_SEQ_BIN 3 /* _CWORD82_ Start Sequence Determination Result = Standard binary #GPF_60_024 */
42 #define GPS_UBLOX_RET_START_SEQ_UBX 4 /* Ublox Start Sequence Decision Result = UBX Protocol (binary) */
43 #define GPS__CWORD82__FULLBINARY_LEN GPS_CMD_FULLBIN_SZ /* _CWORD82_ Full Customization Instruction Length */
45 #define GPS__CWORD82__NORMALBINARY_LEN 81 /* _CWORD82_ standard binary instruction length #GPF_60_024 */
46 /* -- GPS _CWORD82_ support */
48 /* Maximum size of serial data read */
49 #define GPS_RCV_MAXREADSIZE (2048) /* Changed from 256 -> 2048 #01 */
51 /* Receive data storage buffer size */
52 #define GPS_RCV_RCVBUFSIZE 512 /* Maximum size of the command to be received must be larger than the maximum size */
54 /* Max-size receive commands ID4:(188+8)byte */
55 /* Analysis data buffer size */
56 #define GPS_RCV_ANADATABUFSIZE (GPS_RCV_MAXREADSIZE + GPS_RCV_RCVBUFSIZE)
58 /* Receive frame buffer size */
59 #define GPS_RCV_RCVFRAMEBUFSIZE GPS_RCV_RCVBUFSIZE /* Maximum size of the command to be received must be larger than the maximum size */
61 /* Reception notification data buffer size */
62 #define GPS_RCV_SNDCMD_SIZE_MAX
64 /* Common return values */
65 #define GPS_RCV_RET_ERR_EXT (-4) /* External cause error */
66 #define GPS_RCV_RET_ERR_SYSTEM (-3) /* System error */
67 #define GPS_RCV_RET_ERR (-1) /* Abnormality */
68 #define GPS_RCV_RET_NML 0 /* Normal */
70 // Reception thread reception frame detection result
71 #define GPS_RCV_FRMSRCH_ERR_FORMAT (-1) /* Frame format error */
72 #define GPS_RCV_FRMSRCH_FIXED 0 /* Frame determination */
73 #define GPS_RCV_FRMSRCH_NOT_FIXED 1 /* Frame undetermined */
74 #define GPS_RCV_FRMSRCH_NO_DATA 2 /* No analysis data */
76 // Result of receive thread receive frame analysis
77 #define GPS_RCV_FRMANA_ERR_PRM (-3) /* Parameter error */
78 #define GPS_RCV_FRMANA_ERR_FORMAT (-2) /* Frame format error */
79 #define GPS_RCV_FRMANA_ERR_CS (-1) /* Sumcheck error */
80 #define GPS_RCV_FRMANA_OK 0 /* Normal data */
82 /* Serial reception event determination result */
84 GPS_RCV_REVT_NML = 0, /* Receiving(Normal) */
85 GPS_RCV_REVT_ERR, /* Receiving(Error) */
86 GPS_RCV_REVT_NUM /* Number of events received */
90 #define ERLG_SER_FRAMEERR "Serial Framing Error"
91 #define ERLG_SER_OVERRUNERR "Serial Overrun Error"
92 #define ERLG_SER_PARITYERR "Serial Parity Error"
93 #define ERLG_RCVEV_JDGERR "DEV_Gps_Recv_JdgSerEvt error"
94 #define ERLG_RCVDATA_SNDERR "DEV_Gps_Recv_SndRcvData error"
95 #define ERLG_COMEVNT_WAITERR "WaitCommEvent error"
97 /*---------------------------------------------------------------------------*/
100 // Serial receive buffer structure
101 typedef struct GPSRecvData {
102 u_int16 us_read_size; /* Serial data read data size */
103 u_int8 uc_reserve[2]; /* Preliminary */
104 u_int8 uc_read_data[GPS_RCV_MAXREADSIZE]; /* Serial read data */
105 } TG_GPS_RECV_RcvData;
107 // Receive data storage buffer structure
108 typedef struct GPSRecvBuf {
109 u_int16 r_size; /* Received size */
110 u_int8 rsv[2]; /* Reserved */
111 u_int8 r_buf[GPS_RCV_RCVBUFSIZE]; /* Receive command data */
112 } TG_GPS_RECV_RcvBuf;
114 // Data analysis buffer
115 typedef struct GPSRecvAnaDataBuf {
116 u_int16 datsize; /* Size of the data */
117 u_int16 offset; /* Analysis start offset */
118 u_int8 datbuf[GPS_RCV_ANADATABUFSIZE]; /* Analysis data */
119 } TG_GPS_RECV_AnaDataBuf;
121 // Receive frame buffer
122 typedef struct GPSRecvFrameBuf {
123 u_int16 size; /* Frame-size */
124 u_int8 rsv[2]; /* Reserved */
125 u_int8 buf[GPS_RCV_RCVFRAMEBUFSIZE]; /* Command data */
126 } TG_GPS_RECV_RcvFrameBuf;
128 /*---------------------------------------------------------------------------*/
131 extern TG_GPS_RECV_RcvData g_gps_rcvdata; /* Serial receive buffer */
132 extern TG_GPS_RECV_RcvBuf g_gps_rcvbuf; /* Receive data storage buffer */
133 extern TG_GPS_RECV_AnaDataBuf g_gps_ana_databuf; /* Analysis data buffer */
134 extern TG_GPS_RECV_RcvFrameBuf g_gps_rcv_framebuf; /* Receive frame buffer */
135 extern u_int16 g_wrecv_err; /* Number of reception errors */
137 /*---------------------------------------------------------------------------*/
140 /* Initializing process */
141 void DevGpsRecvInit(void);
143 /* Buffer clear processing */
144 void DevGpsRecvClrRcvBuf(void);
146 /* Receive (normal) receive processing */
147 void DevGpsRecvRcvNormal(void);
149 /* Data reception processing */
150 int32 DevGpsRecvReadRcvData(TG_GPS_RECV_RcvData* pst_rcv_data);
152 /* Frame detection processing */
153 int32 DevGpsRecvSearchFrameData(const TG_GPS_RECV_AnaDataBuf *adbuf_p, u_int16 *ana_size);
155 /* Receive data transmission processing */
156 void DevGpsRecvSndRcvData(const TG_GPS_RECV_RcvFrameBuf *p_frame_buf);
158 /* Acknowledgement */
159 RET_API DevRcvData(const TG_GPS_RCV_DATA* ptg_rcv_data);
161 /* Pos_Gps_Recv Thread Stop Processing */
162 void DevGpsRecvThreadStopProcess(void);
164 EFrameworkunifiedStatus DevGpsRecvThread(HANDLE h_app);
166 /*---------------------------------------------------------------------------*/
167 #endif // INC_GPSCOMMON_MDEV_GPSRECV_H_
169 /*---------------------------------------------------------------------------*/