串口2接收数据,comm处理信息
This commit is contained in:
1 parent
7c463c07c6
commit
9f9c96d650
14 files changed
+861
-412
No files matched your search
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2025-10-20 Administrator the first version
|
||||
*/
|
||||
#include <rtthread.h>
|
||||
#include <rtdevice.h>
|
||||
#include <board.h>
|
||||
#include "DB_SQLite.h"
|
||||
|
||||
#include <dbhelper.h>
|
||||
#define DB_NAME "/rt.db"
|
||||
|
||||
void db_sqlite(void *parameter)
|
||||
{
|
||||
int db_HelperInit;
|
||||
int db_;
|
||||
|
||||
db_HelperInit = db_helper_init();
|
||||
|
||||
if(db_HelperInit =RT_EOK){
|
||||
rt_kprintf("HelperInit database\n");
|
||||
}else {
|
||||
// db_ = db_create_database("CREATE TABLE student(id INTEGER PRIMARY KEY AUTOINCREMENT,name varchar(32) NOT NULL,score INT NOT NULL);");
|
||||
// if(db_=0){rt_kprintf("database ok\n");}else{rt_kprintf("database no\n");}
|
||||
}
|
||||
|
||||
/* int fd = 0;
|
||||
const char *dbname = db_get_name();
|
||||
fd = open(dbname, O_RDONLY);
|
||||
if (fd > 0)
|
||||
rt_kprintf("%s exist\r\n", dbname);
|
||||
else
|
||||
rt_kprintf("%s not exist\r\n");
|
||||
|
||||
|
||||
const char *sql = "CREATE TABLE IF NOT EXISTS student(id INTEGER PRIMARY KEY AUTOINCREMENT,name varchar(32) NOT NULL,score INT NOT NULL);";
|
||||
rt_kprintf("sql cmd: %s\r\n\r\n", sql);
|
||||
int ret = db_create_database(sql);
|
||||
rt_kprintf("sql ret: %d\r\n", ret);*/
|
||||
|
||||
// sqlite3_os_init();
|
||||
|
||||
/* int rc = db_connect("/rt.db");
|
||||
if (rc <0) {
|
||||
const char *sql = "CREATE TABLE student(id INTEGER PRIMARY KEY AUTOINCREMENT,name varchar(32) NOT NULL,score INT NOT NULL);";
|
||||
int db_create_database(sql);
|
||||
}*/
|
||||
}
|
||||
|
||||
/* 线程 */
|
||||
void thread_DB_SQLite(void)
|
||||
{
|
||||
/* 初始化线程 1,名称是 thread1,入口是 thread1_entry*/
|
||||
rt_thread_t tid;
|
||||
tid = rt_thread_create("db_sqlite", db_sqlite, RT_NULL, 1024*32, 3, 10);
|
||||
|
||||
if (tid != RT_NULL)
|
||||
{
|
||||
rt_thread_startup(tid);
|
||||
}
|
||||
else
|
||||
{
|
||||
rt_kprintf("Failed to create sqlite_sys thread!\n");
|
||||
}
|
||||
// return 0;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2025-10-20 Administrator the first version
|
||||
*/
|
||||
#ifndef APPLICATIONS_DB_DB_SQLITE_H_
|
||||
#define APPLICATIONS_DB_SQLITE_SYS_H_
|
||||
|
||||
void thread_DB_SQLite(void);
|
||||
|
||||
#endif /* APPLICATIONS_DB_DB_SQLITE_H_ */
|
||||
Reference in new issue
Block a user