增加以太网传入RTCM数据
This commit is contained in:
@@ -256,13 +256,20 @@ typedef struct _StrRequestMessage
|
|||||||
// uint8_t data[4];
|
// uint8_t data[4];
|
||||||
// }YisDateFrame;
|
// }YisDateFrame;
|
||||||
|
|
||||||
|
typedef enum{
|
||||||
|
init = 0,
|
||||||
|
uart,
|
||||||
|
ethernet,
|
||||||
|
}rtcm_type;
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
uint8_t dma_buffer[2][RX_BUFFER_LEN]; // 双缓冲
|
uint8_t dma_buffer[2][RX_BUFFER_LEN]; // 双缓冲
|
||||||
volatile uint8_t active_buf; // 当前活跃缓冲区索引
|
volatile uint8_t active_buf; // 当前活跃缓冲区索引
|
||||||
volatile uint16_t buf_len; // 当前活跃缓冲区索引
|
volatile uint16_t buf_len; // 当前活跃缓冲区索引
|
||||||
|
volatile rtcm_type type; // 串口或者以太网
|
||||||
|
volatile uint8_t eth_cnt; // 当前活跃缓冲区索引
|
||||||
} rtcmBuffer;
|
} rtcmBuffer;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,10 @@ u16 Desport = 7900;
|
|||||||
|
|
||||||
u8 pc_ipAddr[4] = { 192, 168, 17, 2 }; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IP address
|
u8 pc_ipAddr[4] = { 192, 168, 17, 2 }; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IP address
|
||||||
|
|
||||||
u8 tcp_socket[WCHNET_NUM_TCP]; //Save the currently connected socket
|
u8 remote_base_ip[4] = { 192, 168, 10, 8 }; //Զ<>̻<EFBFBD>վIP address
|
||||||
|
u16 remote_port = 1008; //Զ<>̻<EFBFBD>վ<EFBFBD>˿<EFBFBD>
|
||||||
|
|
||||||
|
u8 tcp_socket[WCHNET_NUM_TCP]; //Save the currently connected socket
|
||||||
|
|
||||||
|
|
||||||
SystemDataRecord g_systemDataRecord = {0,0,0,0};
|
SystemDataRecord g_systemDataRecord = {0,0,0,0};
|
||||||
@@ -50,6 +53,8 @@ uint8_t portableOcuOnline = 0;
|
|||||||
uint8_t remoteOcuOnline = 0;
|
uint8_t remoteOcuOnline = 0;
|
||||||
|
|
||||||
Timer ethernet_timer_interface;
|
Timer ethernet_timer_interface;
|
||||||
|
|
||||||
|
Timer ethernet_timer_interface1;
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
* @fn mStopIfError
|
* @fn mStopIfError
|
||||||
*
|
*
|
||||||
@@ -277,6 +282,33 @@ void WCHNET_UdpServerRecv2(struct _SCOK_INF *socinf, u32 ipaddr, u16 port, u8 *b
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*********************************************************************
|
||||||
|
* @fn WCHNET_CreateTcpSocket
|
||||||
|
*
|
||||||
|
* @brief Create TCP Socket
|
||||||
|
*
|
||||||
|
* @return none
|
||||||
|
*/
|
||||||
|
void WCHNET_CreateTcpSocket(void)
|
||||||
|
{
|
||||||
|
u8 i;
|
||||||
|
SOCK_INF TmpSocketInf;
|
||||||
|
|
||||||
|
memset((void *) &TmpSocketInf, 0, sizeof(SOCK_INF));
|
||||||
|
memcpy((void *) TmpSocketInf.IPAddr, remote_base_ip, 4);
|
||||||
|
TmpSocketInf.DesPort = remote_port;
|
||||||
|
TmpSocketInf.SourPort = 1008;
|
||||||
|
TmpSocketInf.ProtoType = PROTO_TYPE_TCP;
|
||||||
|
TmpSocketInf.RecvBufLen = RECE_BUF_LEN;
|
||||||
|
i = WCHNET_SocketCreat(&SocketId3, &TmpSocketInf);
|
||||||
|
printf("SocketId %d\r\n", SocketId3);
|
||||||
|
mStopIfError(i);
|
||||||
|
i = WCHNET_SocketConnect(SocketId3); //make a TCP connection
|
||||||
|
mStopIfError(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
* @fn WCHNET_CreateUdpSocket
|
* @fn WCHNET_CreateUdpSocket
|
||||||
*
|
*
|
||||||
@@ -286,7 +318,7 @@ void WCHNET_UdpServerRecv2(struct _SCOK_INF *socinf, u32 ipaddr, u16 port, u8 *b
|
|||||||
*/
|
*/
|
||||||
void WCHNET_CreateUdpSocket(void)
|
void WCHNET_CreateUdpSocket(void)
|
||||||
{
|
{
|
||||||
u8 i;
|
// u8 i;
|
||||||
SOCK_INF TmpSocketInf;
|
SOCK_INF TmpSocketInf;
|
||||||
|
|
||||||
// memset((void *) &TmpSocketInf, 0, sizeof(SOCK_INF));
|
// memset((void *) &TmpSocketInf, 0, sizeof(SOCK_INF));
|
||||||
@@ -310,14 +342,15 @@ void WCHNET_CreateUdpSocket(void)
|
|||||||
#endif
|
#endif
|
||||||
memset(tcp_socket, 0xff, WCHNET_NUM_TCP);
|
memset(tcp_socket, 0xff, WCHNET_NUM_TCP);
|
||||||
|
|
||||||
memset((void *) &TmpSocketInf, 0, sizeof(SOCK_INF));
|
WCHNET_CreateTcpSocket();
|
||||||
TmpSocketInf.SourPort = srcport;
|
// memset((void *) &TmpSocketInf, 0, sizeof(SOCK_INF));
|
||||||
TmpSocketInf.ProtoType = PROTO_TYPE_TCP;
|
// TmpSocketInf.SourPort = srcport;
|
||||||
i = WCHNET_SocketCreat(&SocketId, &TmpSocketInf);
|
// TmpSocketInf.ProtoType = PROTO_TYPE_TCP;
|
||||||
printf("SocketIdForListen %d\r\n", SocketId);
|
// i = WCHNET_SocketCreat(&SocketId, &TmpSocketInf);
|
||||||
mStopIfError(i);
|
// printf("SocketIdForListen %d\r\n", SocketId);
|
||||||
i = WCHNET_SocketListen(SocketId); //listen for connections
|
// mStopIfError(i);
|
||||||
mStopIfError(i);
|
// i = WCHNET_SocketListen(SocketId); //listen for connections
|
||||||
|
// mStopIfError(i);
|
||||||
|
|
||||||
//
|
//
|
||||||
memset((void *)&TmpSocketInf, 0, sizeof(SOCK_INF));
|
memset((void *)&TmpSocketInf, 0, sizeof(SOCK_INF));
|
||||||
@@ -336,21 +369,77 @@ void WCHNET_CreateUdpSocket(void)
|
|||||||
TmpSocketInf.RecvStartPoint = (u32) SocketRecvBuf2;
|
TmpSocketInf.RecvStartPoint = (u32) SocketRecvBuf2;
|
||||||
TmpSocketInf.RecvBufLen = RECE_BUF_LEN;
|
TmpSocketInf.RecvBufLen = RECE_BUF_LEN;
|
||||||
TmpSocketInf.AppCallBack = WCHNET_UdpServerRecv2;
|
TmpSocketInf.AppCallBack = WCHNET_UdpServerRecv2;
|
||||||
i = WCHNET_SocketCreat(&SocketId3, &TmpSocketInf);
|
WCHNET_SocketCreat(&SocketId3, &TmpSocketInf);
|
||||||
printf("WCHNET_SocketCreat %d\r\n", SocketId3);
|
printf("WCHNET_SocketCreat %d\r\n", SocketId3);
|
||||||
|
|
||||||
|
|
||||||
// mStopIfError(i);
|
// mStopIfError(i);
|
||||||
|
|
||||||
// memset((void *) &TmpSocketInf, 0, sizeof(SOCK_INF));
|
}
|
||||||
// memcpy((void *) TmpSocketInf.IPAddr, DESIP, 4);
|
|
||||||
// TmpSocketInf.DesPort = desport;
|
/*********************************************************************
|
||||||
// TmpSocketInf.SourPort = srcport++;
|
* @fn WCHNET_DataLoopback
|
||||||
// TmpSocketInf.ProtoType = PROTO_TYPE_TCP;
|
*
|
||||||
// TmpSocketInf.RecvBufLen = RECE_BUF_LEN;
|
* @brief Data loopback function.
|
||||||
// i = WCHNET_SocketCreat(&SocketId4, &TmpSocketInf);
|
*
|
||||||
// printf("SocketId4 %d\r\n", SocketId4);
|
* @param id - socket id.
|
||||||
// mStopIfError(i);
|
*
|
||||||
// i = WCHNET_SocketConnect(SocketId4); //make a TCP connection
|
* @return none
|
||||||
// mStopIfError(i);
|
*/
|
||||||
|
void WCHNET_DataLoopback(u8 id)
|
||||||
|
{
|
||||||
|
#if 1
|
||||||
|
u8 i;
|
||||||
|
u32 len;
|
||||||
|
u32 endAddr = SocketInf[id].RecvStartPoint + SocketInf[id].RecvBufLen; //Receive buffer end address
|
||||||
|
|
||||||
|
if ((SocketInf[id].RecvReadPoint + SocketInf[id].RecvRemLen) > endAddr)
|
||||||
|
{ //Calculate the length of the received data
|
||||||
|
len = endAddr - SocketInf[id].RecvReadPoint;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
len = SocketInf[id].RecvRemLen;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(remote_port == SocketInf[id].DesPort)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>Դ<EFBFBD>˿<EFBFBD><CBBF><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>̫<EFBFBD><CCAB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>RTCM<43><4D><EFBFBD><EFBFBD>
|
||||||
|
{
|
||||||
|
memcpy(&RTCM_Buffer1.dma_buffer[RTCM_Buffer1.active_buf][0],(u8 *) SocketInf[id].RecvReadPoint,len);
|
||||||
|
RTCM_Buffer1.type = ethernet;
|
||||||
|
RTCM_Buffer1.buf_len = (uint16_t)len;
|
||||||
|
RTCM_Buffer1.active_buf ^= 1;
|
||||||
|
RTCM_Buffer1.eth_cnt ++;//<2F>ۼ<EFBFBD><DBBC>ж<EFBFBD>
|
||||||
|
publishMessage(&RTCM_Buffer1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// printf("Դ<>˿<EFBFBD>: %u, Ŀ<><C4BF><EFBFBD>˿<EFBFBD>: %u\n",
|
||||||
|
// SocketInf[id].SourPort, SocketInf[id].DesPort);
|
||||||
|
|
||||||
|
|
||||||
|
// i = WCHNET_SocketSend(id, (u8 *) SocketInf[id].RecvReadPoint, &len); //send data
|
||||||
|
|
||||||
|
if (i == WCHNET_ERR_SUCCESS) {
|
||||||
|
WCHNET_SocketRecv(id, NULL, &len); //Clear sent data
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
u32 len, totallen;
|
||||||
|
u8 *p = MyBuf, TransCnt = 255;
|
||||||
|
|
||||||
|
len = WCHNET_SocketRecvLen(id, NULL); //query length
|
||||||
|
printf("Receive Len = %d\r\n", len);
|
||||||
|
totallen = len;
|
||||||
|
WCHNET_SocketRecv(id, MyBuf, &len); //Read the data of the receive buffer into MyBuf
|
||||||
|
while(1){
|
||||||
|
len = totallen;
|
||||||
|
WCHNET_SocketSend(id, p, &len); //Send the data
|
||||||
|
totallen -= len; //Subtract the sent length from the total length
|
||||||
|
p += len; //offset buffer pointer
|
||||||
|
if( !--TransCnt ) break; //Timeout exit
|
||||||
|
if(totallen) continue; //If the data is not sent, continue to send
|
||||||
|
break; //After sending, exit
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
@@ -368,6 +457,7 @@ void WCHNET_HandleSockInt(u8 socketid, u8 intstat)
|
|||||||
u8 i;
|
u8 i;
|
||||||
if (intstat & SINT_STAT_RECV) //receive data
|
if (intstat & SINT_STAT_RECV) //receive data
|
||||||
{
|
{
|
||||||
|
WCHNET_DataLoopback(socketid);
|
||||||
}
|
}
|
||||||
if (intstat & SINT_STAT_CONNECT) //connect successfully
|
if (intstat & SINT_STAT_CONNECT) //connect successfully
|
||||||
{
|
{
|
||||||
@@ -403,6 +493,7 @@ void WCHNET_HandleSockInt(u8 socketid, u8 intstat)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf("TCP Timeout\r\n");
|
printf("TCP Timeout\r\n");
|
||||||
|
WCHNET_CreateTcpSocket();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -498,7 +589,7 @@ uint8_t CalculateChecksum(const uint8_t* data, size_t len)
|
|||||||
static void ethernetInterfaceTimerProcess(void *signal_id)
|
static void ethernetInterfaceTimerProcess(void *signal_id)
|
||||||
{
|
{
|
||||||
static u_int32_t navigation_output_len = 0;
|
static u_int32_t navigation_output_len = 0;
|
||||||
static u_int32_t navigation_output_len1 = 0;
|
// static u_int32_t navigation_output_len1 = 0;
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
if (signal_id == &navigation_output1)
|
if (signal_id == &navigation_output1)
|
||||||
{
|
{
|
||||||
@@ -536,21 +627,21 @@ static void ethernetInterfaceTimerProcess(void *signal_id)
|
|||||||
navigation_outputC1.bit_data.crc1 = CalculateChecksum(&navigation_outputC1.arr[0],sizeof(UnInfNavigationOutputC)-1);
|
navigation_outputC1.bit_data.crc1 = CalculateChecksum(&navigation_outputC1.arr[0],sizeof(UnInfNavigationOutputC)-1);
|
||||||
|
|
||||||
|
|
||||||
for(uint8_t i = 0; i < WCHNET_NUM_TCP; i++)
|
// for(uint8_t i = 0; i < WCHNET_NUM_TCP; i++)
|
||||||
{
|
// {
|
||||||
if(tcp_socket[i] != 0xFF)
|
// if(tcp_socket[i] != 0xFF)
|
||||||
{
|
// {
|
||||||
if(0 == navigation_output_len1)
|
// if(0 == navigation_output_len1)
|
||||||
{
|
// {
|
||||||
navigation_output_len1 = sizeof(navigation_outputC1);
|
// navigation_output_len1 = sizeof(navigation_outputC1);
|
||||||
}
|
// }
|
||||||
|
|
||||||
i = WCHNET_SocketSend(tcp_socket[i], (uint8_t *)&navigation_outputC1, &navigation_output_len1); //send data
|
// i = WCHNET_SocketSend(tcp_socket[i], (uint8_t *)&navigation_outputC1, &navigation_output_len1); //send data
|
||||||
if (i == WCHNET_ERR_SUCCESS) {
|
// if (i == WCHNET_ERR_SUCCESS) {
|
||||||
WCHNET_SocketRecv(tcp_socket[i], NULL, &navigation_output_len1); //Clear sent data
|
// WCHNET_SocketRecv(tcp_socket[i], NULL, &navigation_output_len1); //Clear sent data
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
else if (signal_id == &navigation_output2)
|
else if (signal_id == &navigation_output2)
|
||||||
{
|
{
|
||||||
@@ -593,7 +684,7 @@ static void ethernetInterfaceTimerProcess(void *signal_id)
|
|||||||
}
|
}
|
||||||
UdpSendToData(SocketId2, (uint8_t *)&navigation_output2, &navigation_output_len, &str_RequestMessage.ip_adesser[0],str_RequestMessage.port);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
UdpSendToData(SocketId2, (uint8_t *)&navigation_output2, &navigation_output_len, &str_RequestMessage.ip_adesser[0],str_RequestMessage.port);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -614,6 +705,22 @@ void ethInterruptProcess(void *signal_id)
|
|||||||
timerStart(ðernet_timer_interface, 1,1); //1ms<6D><73><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
timerStart(ðernet_timer_interface, 1,1); //1ms<6D><73><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ethernetFaultProcess(void *signal_id)//<2F><>̫<EFBFBD><CCAB>RTCM<43><4D><EFBFBD><EFBFBD><EFBFBD>жϡ<D0B6>
|
||||||
|
{
|
||||||
|
static uint8_t eth_cnt_last = 0;
|
||||||
|
if( (RTCM_Buffer1.eth_cnt == eth_cnt_last) && (ethernet == RTCM_Buffer1.type) )//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>5s<35><73><EFBFBD>ǶϿ<C7B6><CFBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˡ<EFBFBD>
|
||||||
|
{
|
||||||
|
RTCM_Buffer1.type = init;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
eth_cnt_last = RTCM_Buffer1.eth_cnt;
|
||||||
|
}
|
||||||
|
timerStart(ðernet_timer_interface1, 8000,1); //8s<38><73><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ethernetInterfaceInit(void)
|
void ethernetInterfaceInit(void)
|
||||||
{
|
{
|
||||||
@@ -622,7 +729,14 @@ void ethernetInterfaceInit(void)
|
|||||||
subscribe(&navigation_output1, ethernetInterfaceTimerProcess);
|
subscribe(&navigation_output1, ethernetInterfaceTimerProcess);
|
||||||
subscribe(&navigation_output2, ethernetInterfaceTimerProcess);
|
subscribe(&navigation_output2, ethernetInterfaceTimerProcess);
|
||||||
subscribe(ðernet_timer_interface, ethInterruptProcess);
|
subscribe(ðernet_timer_interface, ethInterruptProcess);
|
||||||
|
subscribe(ðernet_timer_interface1, ethernetFaultProcess); //1ms<6D><73><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
||||||
|
|
||||||
timerStart(ðernet_timer_interface, 1,1); //1ms<6D><73><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
timerStart(ðernet_timer_interface, 1,1); //1ms<6D><73><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
||||||
|
|
||||||
|
timerStart(ðernet_timer_interface1, 5000,1); //5s<35><73><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
printf( "ethernetInterface: initial OK %d\n",getCurrentTime());
|
printf( "ethernetInterface: initial OK %d\n",getCurrentTime());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* eth_drive.c
|
* eth_drive.c
|
||||||
*
|
*
|
||||||
* Created on: 2023<EFBFBD><EFBFBD>1<EFBFBD><EFBFBD>5<EFBFBD><EFBFBD>
|
* Created on: 2023??1??5??
|
||||||
* Author: Administrator
|
* Author: Administrator
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ static RingBuffer nmea_rx_buf;
|
|||||||
#define DMA_BUF_SIZE 1400
|
#define DMA_BUF_SIZE 1400
|
||||||
uint8_t dma_rx_buffer[DMA_BUF_SIZE] __attribute__((aligned(4)));
|
uint8_t dma_rx_buffer[DMA_BUF_SIZE] __attribute__((aligned(4)));
|
||||||
|
|
||||||
//__attribute__((aligned(4))) uint8_t dma_buffer[2048]; // GCC<EFBFBD>
|
//__attribute__((aligned(4))) uint8_t dma_buffer[2048]; // GCC??
|
||||||
|
|
||||||
|
|
||||||
//void USART2_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
|
//void USART2_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
|
||||||
@@ -48,7 +48,7 @@ void USART3_IRQHandler(void)
|
|||||||
{
|
{
|
||||||
imu_buffer1.buf_len = IMU_LEN - DMA_GetCurrDataCounter(IMU_RX_CH);
|
imu_buffer1.buf_len = IMU_LEN - DMA_GetCurrDataCounter(IMU_RX_CH);
|
||||||
|
|
||||||
if( (imu_buffer1.dma_buffer[imu_buffer1.active_buf][0] == IMU_IIM46234_HEADER1) && //<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
if( (imu_buffer1.dma_buffer[imu_buffer1.active_buf][0] == IMU_IIM46234_HEADER1) && //??????????????
|
||||||
(imu_buffer1.dma_buffer[imu_buffer1.active_buf][1] == IMU_IIM46234_HEADER2) )
|
(imu_buffer1.dma_buffer[imu_buffer1.active_buf][1] == IMU_IIM46234_HEADER2) )
|
||||||
{
|
{
|
||||||
imu_buffer1.type = IIM46234;
|
imu_buffer1.type = IIM46234;
|
||||||
@@ -80,19 +80,24 @@ void UART4_IRQHandler(void)
|
|||||||
enter_critical_section();
|
enter_critical_section();
|
||||||
if(USART_GetITStatus(UART4, USART_IT_IDLE) != RESET)
|
if(USART_GetITStatus(UART4, USART_IT_IDLE) != RESET)
|
||||||
{
|
{
|
||||||
RTCM_Buffer1.buf_len = RX_BUFFER_LEN - DMA_GetCurrDataCounter(RTCM_RX_CH);
|
if(ethernet != RTCM_Buffer1.type)//ֻҪ<D6BB><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̫<EFBFBD><CCAB>״̬
|
||||||
RTCM_Buffer1.active_buf ^= 1;
|
{
|
||||||
|
RTCM_Buffer1.type = uart;//<2F><><EFBFBD>ڽ<EFBFBD><DABD><EFBFBD>ģʽ
|
||||||
|
RTCM_Buffer1.buf_len = RX_BUFFER_LEN - DMA_GetCurrDataCounter(RTCM_RX_CH);
|
||||||
|
RTCM_Buffer1.active_buf ^= 1;
|
||||||
|
|
||||||
DMA_Cmd(RTCM_RX_CH, DISABLE);
|
DMA_Cmd(RTCM_RX_CH, DISABLE);
|
||||||
DMA_SetCurrDataCounter(RTCM_RX_CH, RX_BUFFER_LEN);
|
DMA_SetCurrDataCounter(RTCM_RX_CH, RX_BUFFER_LEN);
|
||||||
// Switch buffer
|
// Switch buffer
|
||||||
RTCM_RX_CH->MADDR = (uint32_t)(uintptr_t)&(RTCM_Buffer1.dma_buffer[RTCM_Buffer1.active_buf][0]);
|
RTCM_RX_CH->MADDR = (uint32_t)(uintptr_t)&(RTCM_Buffer1.dma_buffer[RTCM_Buffer1.active_buf][0]);
|
||||||
DMA_Cmd(RTCM_RX_CH, ENABLE);
|
DMA_Cmd(RTCM_RX_CH, ENABLE);
|
||||||
printf("rtcm receive\n");
|
printf("rtcm receive\n");
|
||||||
|
|
||||||
|
USART_ReceiveData(UART4); // clear IDLE flag
|
||||||
|
publishMessage(&RTCM_Buffer1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
USART_ReceiveData(UART4); // clear IDLE flag
|
|
||||||
|
|
||||||
publishMessage(&RTCM_Buffer1, 1);
|
|
||||||
}
|
}
|
||||||
exit_critical_section(0);
|
exit_critical_section(0);
|
||||||
}
|
}
|
||||||
@@ -103,9 +108,8 @@ void UART8_IRQHandler(void)
|
|||||||
enter_critical_section();
|
enter_critical_section();
|
||||||
if(USART_GetITStatus(UART8, USART_IT_RXNE) != RESET)
|
if(USART_GetITStatus(UART8, USART_IT_RXNE) != RESET)
|
||||||
{
|
{
|
||||||
uint8_t UART_temp = 0;
|
USART_ReceiveData(UART8);
|
||||||
UART_temp = USART_ReceiveData(UART8);
|
// printf("USART8:%d\n", UART_temp); // ????
|
||||||
// printf("USART8:%d\n", UART_temp); // <20><><EFBFBD><EFBFBD>
|
|
||||||
}
|
}
|
||||||
exit_critical_section(0);
|
exit_critical_section(0);
|
||||||
}
|
}
|
||||||
@@ -118,7 +122,7 @@ void UART6_IRQHandler(void)
|
|||||||
enter_critical_section();
|
enter_critical_section();
|
||||||
if(USART_GetITStatus(UART6, USART_IT_RXNE) != RESET)
|
if(USART_GetITStatus(UART6, USART_IT_RXNE) != RESET)
|
||||||
{
|
{
|
||||||
char ch = USART_ReceiveData(UART6);
|
USART_ReceiveData(UART6);
|
||||||
}
|
}
|
||||||
exit_critical_section(0);
|
exit_critical_section(0);
|
||||||
}
|
}
|
||||||
@@ -131,7 +135,7 @@ void UART7_IRQHandler(void)
|
|||||||
DMA_Cmd(UM982_RX_CH, DISABLE);
|
DMA_Cmd(UM982_RX_CH, DISABLE);
|
||||||
uint16_t received_len = DMA_BUF_SIZE - DMA_GetCurrDataCounter(UM982_RX_CH);
|
uint16_t received_len = DMA_BUF_SIZE - DMA_GetCurrDataCounter(UM982_RX_CH);
|
||||||
|
|
||||||
// 3. <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// 3. ??????????????<3F><>?????
|
||||||
for(uint16_t i = 0; i < received_len; i++)
|
for(uint16_t i = 0; i < received_len; i++)
|
||||||
{
|
{
|
||||||
uint16_t next_head = (nmea_rx_buf.head + 1) % RING_BUF_SIZE;
|
uint16_t next_head = (nmea_rx_buf.head + 1) % RING_BUF_SIZE;
|
||||||
@@ -166,7 +170,7 @@ void DMA1_Channel3_IRQHandler(void)
|
|||||||
enter_critical_section();
|
enter_critical_section();
|
||||||
imu_buffer1.buf_len = RX_BUFFER_LEN;
|
imu_buffer1.buf_len = RX_BUFFER_LEN;
|
||||||
|
|
||||||
DMA_ClearITPendingBit(DMA1_IT_TC3);//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
DMA_ClearITPendingBit(DMA1_IT_TC3);//?????<3F><>?
|
||||||
exit_critical_section(0);
|
exit_critical_section(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,7 +188,7 @@ void DMA2_Channel3_IRQHandler(void)
|
|||||||
enter_critical_section();
|
enter_critical_section();
|
||||||
RTCM_Buffer1.buf_len = RX_BUFFER_LEN;
|
RTCM_Buffer1.buf_len = RX_BUFFER_LEN;
|
||||||
|
|
||||||
DMA_ClearITPendingBit(DMA2_IT_TC3);//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
DMA_ClearITPendingBit(DMA2_IT_TC3);//?????<3F><>?
|
||||||
exit_critical_section(0);
|
exit_critical_section(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,7 +202,7 @@ void DMA2_Channel3_IRQHandler(void)
|
|||||||
void DMA2_Channel9_IRQHandler(void)
|
void DMA2_Channel9_IRQHandler(void)
|
||||||
{
|
{
|
||||||
enter_critical_section();
|
enter_critical_section();
|
||||||
DMA_ClearITPendingBit(DMA2_IT_TC9);//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
DMA_ClearITPendingBit(DMA2_IT_TC9);//?????<3F><>?
|
||||||
exit_critical_section(0);
|
exit_critical_section(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,7 +246,7 @@ void dmaInit(void)
|
|||||||
DMA_Cmd(RTCM_RX_CH, ENABLE);
|
DMA_Cmd(RTCM_RX_CH, ENABLE);
|
||||||
USART_DMACmd(RTCM_UART, USART_DMAReq_Rx, ENABLE);
|
USART_DMACmd(RTCM_UART, USART_DMAReq_Rx, ENABLE);
|
||||||
|
|
||||||
//IMU DMA<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
//IMU DMA????
|
||||||
DMA_DeInit(IMU_RX_CH);
|
DMA_DeInit(IMU_RX_CH);
|
||||||
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
|
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
|
||||||
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
|
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
|
||||||
@@ -270,7 +274,7 @@ void dmaInit(void)
|
|||||||
USART_DMACmd(IMU_UART, USART_DMAReq_Rx, ENABLE);
|
USART_DMACmd(IMU_UART, USART_DMAReq_Rx, ENABLE);
|
||||||
|
|
||||||
|
|
||||||
//982 DMA<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
//982 DMA????
|
||||||
DMA_DeInit(UM982_RX_CH);
|
DMA_DeInit(UM982_RX_CH);
|
||||||
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
|
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
|
||||||
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
|
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
|
||||||
@@ -363,7 +367,7 @@ void initUart(void)
|
|||||||
NVIC_Init(&NVIC_InitStructure);
|
NVIC_Init(&NVIC_InitStructure);
|
||||||
USART_Cmd(UART4, ENABLE);
|
USART_Cmd(UART4, ENABLE);
|
||||||
|
|
||||||
/* UART6 TX-->C.0 RX-->C.1 */ //<EFBFBD>ӵ<EFBFBD>982<EFBFBD><EFBFBD>com1
|
/* UART6 TX-->C.0 RX-->C.1 */ //???982??com1
|
||||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
|
||||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
|
||||||
@@ -389,7 +393,7 @@ void initUart(void)
|
|||||||
NVIC_Init(&NVIC_InitStructure);
|
NVIC_Init(&NVIC_InitStructure);
|
||||||
USART_Cmd(UART6, ENABLE);
|
USART_Cmd(UART6, ENABLE);
|
||||||
|
|
||||||
/* UART7 TX-->C.2 RX-->C.3 *///<EFBFBD>ӵ<EFBFBD>982<EFBFBD><EFBFBD>com2
|
/* UART7 TX-->C.2 RX-->C.3 *///???982??com2
|
||||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
|
||||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
|
||||||
@@ -443,7 +447,7 @@ void initUart(void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void uartSendto(USART_TypeDef *USARTx, uint8_t * ucData, uint16_t len)//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>2<EFBFBD><EFBFBD><EFBFBD>ͺ<EFBFBD><EFBFBD><EFBFBD>
|
void uartSendto(USART_TypeDef *USARTx, uint8_t * ucData, uint16_t len)//????2???????
|
||||||
{
|
{
|
||||||
for(uint16_t i = 0; i<len; i++)
|
for(uint16_t i = 0; i<len; i++)
|
||||||
{
|
{
|
||||||
@@ -457,9 +461,9 @@ void uartSendto(USART_TypeDef *USARTx, uint8_t * ucData, uint16_t len)//<2F><>
|
|||||||
|
|
||||||
void rtcmProcess(void *signal_id)
|
void rtcmProcess(void *signal_id)
|
||||||
{
|
{
|
||||||
(void)signal_id; // <EFBFBD><EFBFBD>DZ<EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>ʹ<EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
(void)signal_id; // ??????????????????????????
|
||||||
|
|
||||||
uartSendto(UART6, (uint8_t *)&(RTCM_Buffer1.dma_buffer[RTCM_Buffer1.active_buf^1][0]), RTCM_Buffer1.buf_len);//ֱ<EFBFBD>ӷ<EFBFBD><EFBFBD>ͷǼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>
|
uartSendto(UART6, (uint8_t *)&(RTCM_Buffer1.dma_buffer[RTCM_Buffer1.active_buf^1][0]), RTCM_Buffer1.buf_len);//?????????????
|
||||||
printf("rtcm forwarding\n");
|
printf("rtcm forwarding\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -468,25 +472,25 @@ void rtcmProcess(void *signal_id)
|
|||||||
|
|
||||||
void setDataProcess(void *signal_id)
|
void setDataProcess(void *signal_id)
|
||||||
{
|
{
|
||||||
(void)signal_id; // <EFBFBD><EFBFBD>DZ<EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>ʹ<EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
(void)signal_id; // ??????????????????????????
|
||||||
uartSendto(USART3, set_output_data, 20);
|
uartSendto(USART3, set_output_data, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setRateProcess(void *signal_id)
|
void setRateProcess(void *signal_id)
|
||||||
{
|
{
|
||||||
(void)signal_id; // <EFBFBD><EFBFBD>DZ<EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>ʹ<EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
(void)signal_id; // ??????????????????????????
|
||||||
uartSendto(USART3, set_rate, 20);
|
uartSendto(USART3, set_rate, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setSaveProcess(void *signal_id)
|
void setSaveProcess(void *signal_id)
|
||||||
{
|
{
|
||||||
(void)signal_id; // <EFBFBD><EFBFBD>DZ<EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>ʹ<EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
(void)signal_id; // ??????????????????????????
|
||||||
uartSendto(USART3, save_cmd, 20);
|
uartSendto(USART3, save_cmd, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setSteamProcess(void *signal_id)
|
void setSteamProcess(void *signal_id)
|
||||||
{
|
{
|
||||||
(void)signal_id; // <EFBFBD><EFBFBD>DZ<EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>ʹ<EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
(void)signal_id; // ??????????????????????????
|
||||||
uartSendto(USART3, stream_cmd, 20);
|
uartSendto(USART3, stream_cmd, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -494,18 +498,18 @@ void setSteamProcess(void *signal_id)
|
|||||||
|
|
||||||
|
|
||||||
/* /?**?
|
/* /?**?
|
||||||
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD>NMEA<EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><EFBFBD>ͣ<EFBFBD>XOR<EFBFBD><EFBFBD><EFBFBD>У<EFBFBD>飩
|
* @brief ????NMEA????<3F><>????XOR???<3F><>?<3F><>
|
||||||
* @param nmea_str <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>NMEA<EFBFBD><EFBFBD>䣨<EFBFBD><EFBFBD><EFBFBD><EFBFBD>$<24><>*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>β<EFBFBD><CEB2>CRLF<EFBFBD><EFBFBD>
|
* @param nmea_str ??????NMEA???????$??*??????????<3F><>??CRLF??
|
||||||
* @return <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>8λУ<EFBFBD><EFBFBD>ͣ<EFBFBD>0x00~0xFF<EFBFBD><EFBFBD>
|
* @return ???????8<>˧<EFBFBD>????0x00~0xFF??
|
||||||
*/
|
*/
|
||||||
uint8_t nmea_checksum(const char *nmea_str)
|
uint8_t nmea_checksum(const char *nmea_str)
|
||||||
{
|
{
|
||||||
uint8_t checksum = 0;
|
uint8_t checksum = 0;
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>'$'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>
|
// ?????????'$'??????????
|
||||||
if (*nmea_str == '$') nmea_str++;
|
if (*nmea_str == '$') nmea_str++;
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'*'<27><><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// ???????????????'*'???????????
|
||||||
while (*nmea_str && *nmea_str != '*') {
|
while (*nmea_str && *nmea_str != '*') {
|
||||||
checksum ^= (uint8_t)*nmea_str++;
|
checksum ^= (uint8_t)*nmea_str++;
|
||||||
}
|
}
|
||||||
@@ -514,24 +518,24 @@ uint8_t nmea_checksum(const char *nmea_str)
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @brief <EFBFBD><EFBFBD>֤NMEA<EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><EFBFBD><EFBFBD>
|
* @brief ???NMEA????<3F><>???
|
||||||
* @param nmea_str <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>NMEA<EFBFBD><EFBFBD>䣨<EFBFBD><EFBFBD>"$GPGGA,...*2A\r\n"<EFBFBD><EFBFBD>
|
* @param nmea_str ??????NMEA?????"$GPGGA,...*2A\r\n"??
|
||||||
* @return У<EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><EFBFBD>ʧ<EFBFBD>ܷ<EFBFBD><EFBFBD><EFBFBD>0
|
* @return <EFBFBD><EFBFBD>????????1????????0
|
||||||
*/
|
*/
|
||||||
bool nmea_validate_checksum(const char *nmea_str)
|
bool nmea_validate_checksum(const char *nmea_str)
|
||||||
{
|
{
|
||||||
const char *p = nmea_str;
|
const char *p = nmea_str;
|
||||||
uint8_t computed_cs, received_cs;
|
uint8_t computed_cs, received_cs;
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼλ<EFBFBD><EFBFBD>'*'
|
// ????<3F><>??????<3F><>??'*'
|
||||||
while (*p && *p != '*') p++;
|
while (*p && *p != '*') p++;
|
||||||
if (*p != '*') return 0; // <EFBFBD><EFBFBD>У<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>
|
if (*p != '*') return 0; // ??<3F><>??????
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><EFBFBD>ͣ<EFBFBD>2λʮ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD>
|
// ??????????<3F><>????2<><32>????????
|
||||||
if (!isxdigit(p[1]) || !isxdigit(p[2])) return 0;
|
if (!isxdigit(p[1]) || !isxdigit(p[2])) return 0;
|
||||||
received_cs = (uint8_t)strtol(p+1, NULL, 16);
|
received_cs = (uint8_t)strtol(p+1, NULL, 16);
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><EFBFBD>У<EFBFBD><EFBFBD><EFBFBD>
|
// ???????<3F><>???
|
||||||
computed_cs = nmea_checksum(nmea_str);
|
computed_cs = nmea_checksum(nmea_str);
|
||||||
|
|
||||||
return (computed_cs == received_cs);
|
return (computed_cs == received_cs);
|
||||||
@@ -542,7 +546,6 @@ void ProcessNMEAFrames(void *signal_id)
|
|||||||
static uint8_t parsing_buf[1024];
|
static uint8_t parsing_buf[1024];
|
||||||
static uint16_t parse_idx = 0;
|
static uint16_t parse_idx = 0;
|
||||||
bool frame_complete = false;
|
bool frame_complete = false;
|
||||||
static uint8_t debug1s_cnt = 0;
|
|
||||||
|
|
||||||
// debug1s_cnt ++;
|
// debug1s_cnt ++;
|
||||||
// if(debug1s_cnt >= 20)
|
// if(debug1s_cnt >= 20)
|
||||||
@@ -555,82 +558,86 @@ void ProcessNMEAFrames(void *signal_id)
|
|||||||
|
|
||||||
|
|
||||||
while(nmea_rx_buf.tail != nmea_rx_buf.head && !frame_complete)
|
while(nmea_rx_buf.tail != nmea_rx_buf.head && !frame_complete)
|
||||||
{ // <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǿ<EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><EFBFBD><EFBFBD>һ֡<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
{ // ???????????<3F><>?????????
|
||||||
uint8_t ch = nmea_rx_buf.buffer[nmea_rx_buf.tail];
|
uint8_t ch = nmea_rx_buf.buffer[nmea_rx_buf.tail];
|
||||||
nmea_rx_buf.tail = (nmea_rx_buf.tail + 1) % RING_BUF_SIZE;
|
nmea_rx_buf.tail = (nmea_rx_buf.tail + 1) % RING_BUF_SIZE;
|
||||||
|
|
||||||
if(nmea_rx_buf.overflow) {
|
if(nmea_rx_buf.overflow) {
|
||||||
nmea_rx_buf.tail = nmea_rx_buf.head;
|
nmea_rx_buf.tail = nmea_rx_buf.head;
|
||||||
// 3. <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־
|
// 3. ??????????
|
||||||
nmea_rx_buf.overflow = 0;
|
nmea_rx_buf.overflow = 0;
|
||||||
// 4. <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>̣<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ط<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// 4. ????????????????????????
|
||||||
printf("Overflow recovery\n");
|
printf("Overflow recovery\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ֡ͷ<EFBFBD><EFBFBD><EFBFBD>
|
// ?????
|
||||||
if(ch == '$') {
|
if(ch == '$') {
|
||||||
if(parse_idx > 0 && parsing_buf[parse_idx-1] == '\n')
|
if(parse_idx > 0 && parsing_buf[parse_idx-1] == '\n')
|
||||||
{
|
{
|
||||||
if (nmea_validate_checksum((char *)parsing_buf)) //У<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
if (nmea_validate_checksum((char *)parsing_buf)) //<2F><>?????
|
||||||
{
|
{
|
||||||
memcpy(&nema_output1.buffer[0],parsing_buf,parse_idx);
|
memcpy(&nema_output1.buffer[0],parsing_buf,parse_idx);
|
||||||
publishMessage(&nema_output1, 1);
|
publishMessage(&nema_output1, 1);
|
||||||
frame_complete = true; // <EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
frame_complete = true; // ???????????
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf("nmea crc error");
|
printf("nmea crc error");
|
||||||
frame_complete = true; // <EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
frame_complete = true; // ???????????
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
parse_idx = 0;
|
parse_idx = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// <EFBFBD>洢<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// ?<3F><>????
|
||||||
if(parse_idx < RING_BUF_SIZE-1 && !frame_complete)
|
if(parse_idx < RING_BUF_SIZE-1 && !frame_complete)
|
||||||
{
|
{
|
||||||
parsing_buf[parse_idx++] = ch;
|
parsing_buf[parse_idx++] = ch;
|
||||||
|
|
||||||
// ֡β<EFBFBD><EFBFBD><EFBFBD>
|
// ?<3F><>???
|
||||||
if(parse_idx >= 2 &&
|
if(parse_idx >= 2 &&
|
||||||
parsing_buf[parse_idx-2] == '\r' &&
|
parsing_buf[parse_idx-2] == '\r' &&
|
||||||
parsing_buf[parse_idx-1] == '\n')
|
parsing_buf[parse_idx-1] == '\n')
|
||||||
{
|
{
|
||||||
if (nmea_validate_checksum((char *)parsing_buf)) //У<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
if (nmea_validate_checksum((char *)parsing_buf)) //<2F><>?????
|
||||||
{
|
{
|
||||||
memcpy(&nema_output1.buffer[0],parsing_buf,parse_idx);
|
memcpy(&nema_output1.buffer[0],parsing_buf,parse_idx);
|
||||||
publishMessage(&nema_output1, 1);
|
publishMessage(&nema_output1, 1);
|
||||||
frame_complete = true; // <EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
frame_complete = true; // ???????????
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf("nmea buf error");
|
printf("nmea buf error");
|
||||||
frame_complete = true; // <EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
frame_complete = true; // ???????????
|
||||||
}
|
}
|
||||||
parse_idx = 0;
|
parse_idx = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(!frame_complete)
|
else if(!frame_complete)
|
||||||
{
|
{
|
||||||
parse_idx = 0; // <EFBFBD><EFBFBD>ֹ<EFBFBD><EFBFBD><EFBFBD>
|
parse_idx = 0; // ??????
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
timerStart(&nmea_timer, 10, 1); // 100ms<EFBFBD><EFBFBD><EFBFBD>ٴδ<EFBFBD><EFBFBD><EFBFBD>
|
timerStart(&nmea_timer, 10, 1); // 100ms????<3F><>???
|
||||||
}
|
}
|
||||||
|
|
||||||
void navigationRs232Process(void *signal_id)
|
void navigationRs232Process(void *signal_id)
|
||||||
{
|
{
|
||||||
uartSendto(UART8, (uint8_t *)&navigation_rs232_output, sizeof(navigation_rs232_output));
|
uartSendto(UART8, (uint8_t *)&navigation_rs232_output, sizeof(navigation_rs232_output));
|
||||||
|
|
||||||
|
// uint32_t debubg_len = sizeof(navigation_rs232_output);
|
||||||
|
// uint8_t debug_ip[4] = {192,168,17,8};
|
||||||
|
// UdpSendToData(SocketId2, (uint8_t *)&navigation_rs232_output, &debubg_len,debug_ip,8011);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// APPģ<EFBFBD><EFBFBD>ij<EFBFBD>ʼ<EFBFBD><EFBFBD>
|
// APP????????
|
||||||
void interfaceUartInit(void)
|
void interfaceUartInit(void)
|
||||||
{
|
{
|
||||||
subscribe(&set_output_data, setDataProcess);
|
subscribe(&set_output_data, setDataProcess);
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ extern "C" {
|
|||||||
|
|
||||||
#define WCHNET_NUM_TCP 1 /* Number of TCP connections */
|
#define WCHNET_NUM_TCP 1 /* Number of TCP connections */
|
||||||
|
|
||||||
#define WCHNET_NUM_TCP_LISTEN 1 /* Number of TCP listening */
|
#define WCHNET_NUM_TCP_LISTEN 0 /* Number of TCP listening */
|
||||||
|
|
||||||
/* The number of sockets, the maximum is 31 */
|
/* The number of sockets, the maximum is 31 */
|
||||||
#define WCHNET_MAX_SOCKET_NUM (WCHNET_NUM_IPRAW+WCHNET_NUM_UDP+WCHNET_NUM_TCP+WCHNET_NUM_TCP_LISTEN)
|
#define WCHNET_MAX_SOCKET_NUM (WCHNET_NUM_IPRAW+WCHNET_NUM_UDP+WCHNET_NUM_TCP+WCHNET_NUM_TCP_LISTEN)
|
||||||
|
|||||||
@@ -378,12 +378,6 @@ void rs232Process(void)
|
|||||||
navigation_rs232_output.bit_data.checksum = calculate_checksum(&navigation_rs232_output.arr[0],57);
|
navigation_rs232_output.bit_data.checksum = calculate_checksum(&navigation_rs232_output.arr[0],57);
|
||||||
publishMessage(&navigation_rs232_output, 1);
|
publishMessage(&navigation_rs232_output, 1);
|
||||||
|
|
||||||
// uint32_t debubg_len = 58;
|
|
||||||
// uint8_t debug_ip[4] = {192,168,17,77};
|
|
||||||
// UdpSendToData(SocketId2, (uint8_t *)&navigation_output2, &debubg_len,debug_ip,8011);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// timerStart(&rs232_output_timer, 20,1);//10ms
|
// timerStart(&rs232_output_timer, 20,1);//10ms
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -479,29 +473,29 @@ void iim6234Init(void *signal_id)
|
|||||||
|
|
||||||
void nmeaPrintf(void *signal_id)
|
void nmeaPrintf(void *signal_id)
|
||||||
{
|
{
|
||||||
printf("[THS] Heading:%.1f<EFBFBD><EFBFBD> Mode:%c\n",
|
// printf("[THS] Heading:%.1f<EFBFBD><EFBFBD> Mode:%c\n",
|
||||||
ths_data1.heading, ths_data1.mode);
|
// ths_data1.heading, ths_data1.mode);
|
||||||
printf("[VTG] Course:%.1f<EFBFBD><EFBFBD> Speed:%.1fkm/h\n",
|
// printf("[VTG] Course:%.1f<EFBFBD><EFBFBD> Speed:%.1fkm/h\n",
|
||||||
vtg_data1.course_true, vtg_data1.speed_kmh);
|
// vtg_data1.course_true, vtg_data1.speed_kmh);
|
||||||
|
|
||||||
printf("[GGA] Time:%.2f Lat:%.5f%c Lon:%.5f%c Alt:%.2f rtk_state:%d satellite:%d hdop:%2f\n",
|
// printf("[GGA] Time:%.2f Lat:%.5f%c Lon:%.5f%c Alt:%.2f rtk_state:%d satellite:%d hdop:%2f\n",
|
||||||
gga_data1.utc_time,
|
// gga_data1.utc_time,
|
||||||
gga_data1.latitude, gga_data1.lat_dir,
|
// gga_data1.latitude, gga_data1.lat_dir,
|
||||||
gga_data1.longitude, gga_data1.lon_dir,
|
// gga_data1.longitude, gga_data1.lon_dir,
|
||||||
gga_data1.altitude, // <20><><EFBFBD><EFBFBD><EFBFBD>߶ȵ<DFB6>λΪM(<28><>)
|
// gga_data1.altitude, // <20><><EFBFBD><EFBFBD><EFBFBD>߶ȵ<DFB6>λΪM(<28><>)
|
||||||
gga_data1.fix_quality,
|
// gga_data1.fix_quality,
|
||||||
gga_data1.satellites,
|
// gga_data1.satellites,
|
||||||
gga_data1.hdop
|
// gga_data1.hdop
|
||||||
);
|
// );
|
||||||
|
|
||||||
printf("<EFBFBD><EFBFBD>Ԫ<EFBFBD><EFBFBD>: (%.6f, %.6f, %.6f, %.6f)\n",
|
// printf("<EFBFBD><EFBFBD>Ԫ<EFBFBD><EFBFBD>: (%.6f, %.6f, %.6f, %.6f)\n",
|
||||||
yis321_data.bit_data.q0*0.000001, yis321_data.bit_data.q1*0.000001, yis321_data.bit_data.q2*0.000001, (int32_t)yis321_data.bit_data.q3*0.000001);
|
// yis321_data.bit_data.q0*0.000001, yis321_data.bit_data.q1*0.000001, yis321_data.bit_data.q2*0.000001, (int32_t)yis321_data.bit_data.q3*0.000001);
|
||||||
|
|
||||||
printf("ŷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>: (%.6f, %.6f, %.6f)\n",
|
// printf("ŷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>: (%.6f, %.6f, %.6f)\n",
|
||||||
yis321_data.bit_data.pitch*0.000001, yis321_data.bit_data.roll*0.000001, yis321_data.bit_data.yaw*0.000001);
|
// yis321_data.bit_data.pitch*0.000001, yis321_data.bit_data.roll*0.000001, yis321_data.bit_data.yaw*0.000001);
|
||||||
|
|
||||||
printf("AccX:%f,AccY:%f,AccZ:%f,",Acc[0],Acc[1],Acc[2]);
|
// printf("AccX:%f,AccY:%f,AccZ:%f,",Acc[0],Acc[1],Acc[2]);
|
||||||
printf("GyroX:%f,GyroY:%f,GyroZ:%f\r\n",Gyro[0],Gyro[1],Gyro[2]);//ʹ<>ô<EFBFBD><C3B4>ڴ<EFBFBD>ӡ<EFBFBD><D3A1><EFBFBD>ٶȣ<D9B6><C8A3><EFBFBD><EFBFBD>ٶ<EFBFBD><D9B6><EFBFBD><EFBFBD><EFBFBD>
|
// printf("GyroX:%f,GyroY:%f,GyroZ:%f\r\n",Gyro[0],Gyro[1],Gyro[2]);//ʹ<>ô<EFBFBD><C3B4>ڴ<EFBFBD>ӡ<EFBFBD><D3A1><EFBFBD>ٶȣ<D9B6><C8A3><EFBFBD><EFBFBD>ٶ<EFBFBD><D9B6><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
timerStart(&data_processing_timer, 1000,1);//100ms
|
timerStart(&data_processing_timer, 1000,1);//100ms
|
||||||
}
|
}
|
||||||
@@ -517,6 +511,8 @@ void dataProcessingAppInit(void)
|
|||||||
timerInit(&rm3100_timer);
|
timerInit(&rm3100_timer);
|
||||||
timerInit(&data_processing_timer);
|
timerInit(&data_processing_timer);
|
||||||
timerInit(&rs232_output_timer);
|
timerInit(&rs232_output_timer);
|
||||||
|
|
||||||
|
RTCM_Buffer1.type = init;
|
||||||
|
|
||||||
rm3100Init();//<2F><>ʼ<EFBFBD><CABC>RM3100
|
rm3100Init();//<2F><>ʼ<EFBFBD><CABC>RM3100
|
||||||
// <20><><EFBFBD>Ķ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>źţ<C5BA><C5A3><EFBFBD><EFBFBD>ڽ<EFBFBD><DABD><EFBFBD>GNGGA<47><41><EFBFBD><EFBFBD>
|
// <20><><EFBFBD>Ķ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>źţ<C5BA><C5A3><EFBFBD><EFBFBD>ڽ<EFBFBD><DABD><EFBFBD>GNGGA<47><41><EFBFBD><EFBFBD>
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ Timer test_timer;
|
|||||||
void testTimerProcess(void *signal_id)
|
void testTimerProcess(void *signal_id)
|
||||||
{
|
{
|
||||||
(void)signal_id; // 标记变量为已使用,避免编译器警告
|
(void)signal_id; // 标记变量为已使用,避免编译器警告
|
||||||
static uint32_t start_time = 0;
|
// static uint32_t start_time = 0;
|
||||||
// short hx,hy,hz=0;
|
// short hx,hy,hz=0;
|
||||||
|
|
||||||
printf("testAPP\n");
|
printf("testAPP\n");
|
||||||
@@ -50,7 +50,7 @@ void testTimerProcess(void *signal_id)
|
|||||||
// UdpSendToData(SocketId,arrtest4,ÐUDPTxLen,IP1,8011);//测试
|
// UdpSendToData(SocketId,arrtest4,ÐUDPTxLen,IP1,8011);//测试
|
||||||
|
|
||||||
|
|
||||||
start_time = getCurrentTime();
|
// start_time = getCurrentTime();
|
||||||
|
|
||||||
// 再次启动定时器,实现周期定时
|
// 再次启动定时器,实现周期定时
|
||||||
timerStart(&test_timer, 1000,1);
|
timerStart(&test_timer, 1000,1);
|
||||||
|
|||||||
Reference in New Issue
Block a user