00001 #ifndef DN_ROBOTALK_H_ 00002 #define DN_ROBOTALK_H_ 00003 00036 #ifndef _DN_EXP_ROBOTALK 00037 #define _DN_EXP_ROBOTALK 00038 #endif /* _DN_EXP_ROBOTALK */ 00039 00045 #define RTK_CHECK_TYPE (CHECK_TYPE_UDP | CHECK_TYPE_COM) 00046 00051 #define RTK_CHECK_SEND (RTK_CHECK_TYPE | CHECK_FUNC_SEND) 00052 00057 #define RTK_CHECK_RECV (RTK_CHECK_TYPE | CHECK_FUNC_SEND | CHECK_FUNC_RECV) 00058 00063 #define RTK_ENQ (0x05) 00064 00069 #define RTK_CMD_REJ (0x0E01) 00070 00075 #define RTK_CMD_ACK (0x0E02) 00076 00081 #define RTK_CMD_NAK (0x0E82) 00082 00087 #define RTK_SIZE_PACKET (256) 00088 00093 #define RTK_SIZE_HEADER (6) 00094 00099 #define RTK_SIZE_DATA (RTK_SIZE_PACKET - RTK_SIZE_HEADER) 00100 00105 #define RTK_SIZE_COMMAND (2) 00106 00111 #define RTK_SIZE_CRC (2) 00112 00117 #define RTK_RETRY_FLAG (0x1000) 00118 00123 #define RTK_RETRY_COUNT (0x2000) 00124 00129 #define RTK_RETRY_MASK (0xF000) 00130 00136 #define NativeCommand(cmd) ((cmd) & ~RTK_RETRY_MASK) 00137 00143 union RTK_PACKET 00144 { 00145 struct 00146 { 00147 uint8_t enq; 00148 uint8_t len; 00149 uint16_t command; 00150 uint8_t from_id; 00151 uint8_t to_id; 00152 uint8_t data[RTK_SIZE_DATA]; 00153 }; 00154 uint8_t buf[RTK_SIZE_PACKET]; 00155 }; 00156 00157 #ifdef __cplusplus 00158 extern "C" 00159 { 00160 #endif 00161 00172 _DN_EXP_ROBOTALK HRESULT 00173 rtk_param2packet(uint16_t command, const uint8_t *data, uint8_t len_data, 00174 uint8_t from_id, uint8_t to_id, union RTK_PACKET *packet); 00175 00181 _DN_EXP_ROBOTALK uint16_t 00182 rtk_calc_crc(const union RTK_PACKET *packet); 00183 00190 _DN_EXP_ROBOTALK HRESULT 00191 rtk_send(const struct CONN_PARAM_COMMON *device, 00192 union RTK_PACKET *packet_send); 00193 00202 _DN_EXP_ROBOTALK HRESULT 00203 rtk_recv(const struct CONN_PARAM_COMMON *device, 00204 union RTK_PACKET *packet_recv, int client, unsigned int retry_nak); 00205 00206 #ifdef __cplusplus 00207 } 00208 #endif 00209 00210 #endif /* DN_ROBOTALK_H_ */