diff --git a/.config b/.config
index 24323d8..8cac951 100644
--- a/.config
+++ b/.config
@@ -3,7 +3,7 @@
#
# RT-Thread Kernel
#
-CONFIG_RT_NAME_MAX=8
+CONFIG_RT_NAME_MAX=18
# CONFIG_RT_USING_ARCH_DATA_TYPE is not set
# CONFIG_RT_USING_SMP is not set
CONFIG_RT_ALIGN_SIZE=4
@@ -91,7 +91,7 @@ CONFIG_ARCH_ARM_CORTEX_M4=y
CONFIG_RT_USING_COMPONENTS_INIT=y
CONFIG_RT_USING_USER_MAIN=y
CONFIG_RT_MAIN_THREAD_STACK_SIZE=2048
-CONFIG_RT_MAIN_THREAD_PRIORITY=10
+CONFIG_RT_MAIN_THREAD_PRIORITY=20
#
# C++ features
@@ -168,7 +168,7 @@ CONFIG_RT_USING_SERIAL=y
CONFIG_RT_USING_SERIAL_V1=y
# CONFIG_RT_USING_SERIAL_V2 is not set
CONFIG_RT_SERIAL_USING_DMA=y
-CONFIG_RT_SERIAL_RB_BUFSZ=64
+CONFIG_RT_SERIAL_RB_BUFSZ=2048
# CONFIG_RT_USING_CAN is not set
# CONFIG_RT_USING_HWTIMER is not set
# CONFIG_RT_USING_CPUTIME is not set
diff --git a/.cproject b/.cproject
index 98091bd..e524aba 100644
--- a/.cproject
+++ b/.cproject
@@ -1,425 +1,428 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.settings/.rtmenus b/.settings/.rtmenus
index e49cb42..cc3d387 100644
Binary files a/.settings/.rtmenus and b/.settings/.rtmenus differ
diff --git a/.settings/language.settings.xml b/.settings/language.settings.xml
index 8e61900..a5c5415 100644
--- a/.settings/language.settings.xml
+++ b/.settings/language.settings.xml
@@ -5,7 +5,7 @@
-
+
diff --git a/RTK/rtkcmn.c b/RTK/rtkcmn.c
index 80955b6..4d0c340 100644
--- a/RTK/rtkcmn.c
+++ b/RTK/rtkcmn.c
@@ -3755,30 +3755,8 @@ extern void traceb(int level, const uint8_t *p, int n) {}
*-----------------------------------------------------------------------------*/
extern int execcmd(const char *cmd)
{
-#ifdef WIN32
- PROCESS_INFORMATION info;
- STARTUPINFO si = {0};
- DWORD stat;
- char cmds[1024];
-
trace(3, "execcmd: cmd=%s\n", cmd);
-
- si.cb = sizeof(si);
- sprintf(cmds, "cmd /c %s", cmd);
- if (!CreateProcess(NULL, (LPTSTR)cmds, NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL,
- NULL, &si, &info))
- return -1;
- WaitForSingleObject(info.hProcess, INFINITE);
- if (!GetExitCodeProcess(info.hProcess, &stat))
- stat = -1;
- CloseHandle(info.hProcess);
- CloseHandle(info.hThread);
- return (int)stat;
-#else
- trace(3, "execcmd: cmd=%s\n", cmd);
-
return system(cmd);
-#endif
}
/* replace string ------------------------------------------------------------*/
diff --git a/RTK/rtklib.h b/RTK/rtklib.h
index 3532e02..adef7e3 100644
--- a/RTK/rtklib.h
+++ b/RTK/rtklib.h
@@ -53,14 +53,9 @@
#include
#include
#include
-#ifdef WIN32
-#include
-#include
-#else
+
#include
#include
-#endif
-
/* constants -----------------------------------------------------------------*/
diff --git a/applications/main.c b/applications/main.c
index 393c82b..151f912 100644
--- a/applications/main.c
+++ b/applications/main.c
@@ -21,10 +21,12 @@
/* defined the LED0 pin: PF9 */
#define LED0_PIN GET_PIN(F, 9)
+
int main(void)
{
- uart3_init();
+ uart3_init();
+ task_init();
rt_pin_mode(LED0_PIN, PIN_MODE_OUTPUT);
while (1)
@@ -38,8 +40,8 @@ int main(void)
}
void test_entry()
{
-// const char testbuff[] = "test massage!!!";
-// rt_device_write(serial3,0,testbuff,strlen(testbuff));
+ const char testbuff[] = {0xD3,0x00,0x13,0x3E,0xD7,0xD3,0x02,0x02,0x98,0x0E,0xDE,0xEF,0x34,0xB4,0xBD,0x62,0xAC,0x09,0x41,0x98,0x6F,0x33,0x36,0x0B,0x98};
+ rt_device_write(serial3,0,testbuff,sizeof(testbuff));
}
MSH_CMD_EXPORT(test_entry,test_entry);
diff --git a/rtconfig.h b/rtconfig.h
index 4c49bfc..45177b2 100644
--- a/rtconfig.h
+++ b/rtconfig.h
@@ -5,7 +5,7 @@
/* RT-Thread Kernel */
-#define RT_NAME_MAX 8
+#define RT_NAME_MAX 18
#define RT_ALIGN_SIZE 4
#define RT_THREAD_PRIORITY_32
#define RT_THREAD_PRIORITY_MAX 32
@@ -59,7 +59,7 @@
#define RT_USING_COMPONENTS_INIT
#define RT_USING_USER_MAIN
#define RT_MAIN_THREAD_STACK_SIZE 2048
-#define RT_MAIN_THREAD_PRIORITY 10
+#define RT_MAIN_THREAD_PRIORITY 20
/* C++ features */
@@ -116,7 +116,7 @@
#define RT_USING_SERIAL
#define RT_USING_SERIAL_V1
#define RT_SERIAL_USING_DMA
-#define RT_SERIAL_RB_BUFSZ 64
+#define RT_SERIAL_RB_BUFSZ 2048
#define RT_USING_PIN
#define RT_USING_RTC
#define RT_USING_SDIO
diff --git a/task/rtk_task.c b/task/rtk_task.c
new file mode 100644
index 0000000..80d0ea5
--- /dev/null
+++ b/task/rtk_task.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2006-2021, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2022-06-15 fize the first version
+ */
+
+#include
+
+#define LOG_TAG "USER_TASK"
+
+#define THREAD_get_rtcm_data_priority 10
+#define THREAD_rtcm_data_proces_priority 9
+
+#define get_rtcm_data_stack_size DEFAULT_USER_THREAD_STACK_SIZE
+#define rtcm_data_proces_stack_size DEFAULT_USER_THREAD_STACK_SIZE
+
+rtcm_t rtcm_data;
+struct rt_completion get_rtcm_data_completion;
+struct rt_completion rtcm_data_process_completion;
+
+static struct rt_thread get_rtcm_data;
+static char thread_get_rtcm_data_stack[get_rtcm_data_stack_size];
+static struct rt_thread rtcm_data_proces;
+static char thread_rtcm_data_proces_stack[DEFAULT_USER_THREAD_STACK_SIZE];
+
+
+static char rtcm_buff[2048];
+
+static void thread_get_rtcm_data(void *parameter)
+{
+
+ init_rtcm(&rtcm_data);
+ rt_completion_init(&get_rtcm_data_completion);
+ while (1)
+ {
+ rt_sem_take(&uart3_simpack.rx_sem, RT_WAITING_FOREVER);
+ //to make sure there is only one sem exist at uart,keep data from being damaged by dma transmit.
+ //rt thread could not get uart status when it receiving data.
+ //it may cross frame lost if the system runs slow.
+ if (rt_completion_wait(&rtcm_data_process_completion, RT_WAITING_FOREVER)==RT_EOK) //need a completion sem connect to rtcm data processing thread.
+ {
+ get_rtcm_data_completion.flag = RT_UNCOMPLETED;
+ length = uart3_simpack.rx_num;
+ READ_SERIAL3(rtcm_buff);
+ rt_completion_done(&get_rtcm_data_completion);
+ }
+ }
+}
+
+static void thread_rtcm_data_proces(void *parameter)
+{
+ rt_completion_init(&rtcm_data_process_completion);
+ rt_completion_done(&rtcm_data_process_completion);
+ while (1)
+ {
+ rt_completion_wait(&get_rtcm_data_completion, RT_WAITING_FOREVER);
+ rtcm_data_process_completion.flag = RT_UNCOMPLETED;
+ for (int var = 0; var < uart3_simpack.rx_num; var++)
+ {
+ input_rtcm3(&rtcm_data, rtcm_buff[var]);
+ }
+ rt_completion_done(&rtcm_data_process_completion);
+ }
+
+}
+
+static void user_init_task(rt_thread_t thread, const char *name, void (*entry)(void *parameter), void *stack_start,
+ rt_uint32_t stack_size, rt_uint8_t priority, rt_uint32_t tick, rt_uint32_t start)
+{
+ rt_err_t result = RT_EOK;
+ result = rt_thread_init(thread, name, entry, RT_NULL, stack_start, stack_size, priority, tick);
+ if (start)
+ {
+ if (result == RT_EOK)
+ {
+ rt_thread_startup(thread);
+ }
+ else
+ {
+ LOG_E("task init failed :%s", name);
+ }
+ }
+}
+
+/*===========================================================================================================*/
+void task_init(void)
+{
+ user_init_task(&get_rtcm_data, "get_rtcm_data", thread_get_rtcm_data, thread_get_rtcm_data_stack,
+ get_rtcm_data_stack_size, THREAD_get_rtcm_data_priority, DEFAULT_USER_THREA_TICK, RT_TRUE);
+ user_init_task(&rtcm_data_proces, "rtcm_data_proces", thread_rtcm_data_proces, thread_rtcm_data_proces_stack, rtcm_data_proces_stack_size, THREAD_rtcm_data_proces_priority, DEFAULT_USER_THREA_TICK, RT_TRUE);
+}
+
diff --git a/task/rtk_task.h b/task/rtk_task.h
new file mode 100644
index 0000000..bba987e
--- /dev/null
+++ b/task/rtk_task.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2006-2021, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2022-06-15 ¸µÐ¡¶þ the first version
+ */
+#ifndef TASK_RTK_TASK_H_
+#define TASK_RTK_TASK_H_
+
+#include
+#include
+#include
+#include
+
+
+#define RT_COMPLETED 1
+#define RT_UNCOMPLETED 0
+
+#define DEFAULT_USER_THREAD_STACK_SIZE 1024
+#define DEFAULT_USER_THREA_TICK 5
+
+extern uart_simpack uart3_simpack; //from user_uart.h
+extern rtcm_t rtcm_data; //from rtklib.h
+void task_init(void);
+#endif /* TASK_RTK_TASK_H_ */
diff --git a/user_uart/user_uart.c b/user_uart/user_uart.c
index bdd3608..09ea326 100644
--- a/user_uart/user_uart.c
+++ b/user_uart/user_uart.c
@@ -24,12 +24,9 @@ static rt_err_t uart3_tx_complete(rt_device_t dev, void *buffer)
//still in ISR func,so can only use ulog at asynchronous mode.
static rt_err_t uart3_rx_complete(rt_device_t dev, rt_size_t size)
{
- char testbuff[20];
+
uart3_simpack.rx_num=size;
rt_sem_release(&uart3_simpack.rx_sem);
- rt_device_read(serial3,0,testbuff, size);
- // can only use ulog at asynchronous mode.
- LOG_I("massage received : %s",testbuff);
return RT_EOK;
}
diff --git a/user_uart/user_uart.h b/user_uart/user_uart.h
index 6d2a4ef..8d1b151 100644
--- a/user_uart/user_uart.h
+++ b/user_uart/user_uart.h
@@ -17,7 +17,7 @@
#define USER_UART_NAME "uart3"
-#define READ_SERIAL3(args...) rt_device_read(serial3,0,args,args)
+#define READ_SERIAL3(...) rt_device_read(serial3,0,__VA_ARGS__,uart3_simpack.rx_num)
rt_device_t serial3;