mirror of
https://gitee.com/Vancouver2017/luban-lite-t3e-pro.git
synced 2025-12-15 19:08:54 +00:00
v1.0.3
This commit is contained in:
13
bsp/examples/test-dm-lib/SConscript
Normal file
13
bsp/examples/test-dm-lib/SConscript
Normal file
@@ -0,0 +1,13 @@
|
||||
Import('AIC_ROOT')
|
||||
Import('PRJ_KERNEL')
|
||||
from building import *
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
CPPPATH = []
|
||||
src = []
|
||||
if GetDepend('AIC_DM_LIB_TEST'):
|
||||
src = Glob('*.c')
|
||||
|
||||
group = DefineGroup('test-dm-lib', src, depend = [''], CPPPATH = CPPPATH)
|
||||
|
||||
Return('group')
|
||||
40
bsp/examples/test-dm-lib/test_dm_lib.c
Normal file
40
bsp/examples/test-dm-lib/test_dm_lib.c
Normal file
@@ -0,0 +1,40 @@
|
||||
#include <stdio.h>
|
||||
#include <dlfcn.h>
|
||||
#include <rtthread.h>
|
||||
#include <dlmodule.h>
|
||||
#if defined(RT_USING_FINSH)
|
||||
#include <finsh.h>
|
||||
#endif
|
||||
|
||||
#define DM_LIB_PATH "/sdcard/hello.so"
|
||||
#define DM_LIB_FUNC "my_thread_init"
|
||||
#define DEAMON_THREAD
|
||||
|
||||
static void cmd_test_dm_lib(int argc, char **argv)
|
||||
{
|
||||
struct rt_dlmodule *module = NULL;
|
||||
int (*func)(void) = NULL;
|
||||
|
||||
module = dlopen(DM_LIB_PATH, 0);
|
||||
if (!module) {
|
||||
printf("dlopen %s fail!\n", DM_LIB_PATH);
|
||||
return;
|
||||
}
|
||||
|
||||
func = dlsym(module, DM_LIB_FUNC);
|
||||
if (!func) {
|
||||
printf("dlsym %s fail!\n", DM_LIB_FUNC);
|
||||
return;
|
||||
}
|
||||
|
||||
func();
|
||||
|
||||
#ifndef DEAMON_THREAD
|
||||
dlclose(module);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(RT_USING_FINSH)
|
||||
MSH_CMD_EXPORT_ALIAS(cmd_test_dm_lib, test_dm_lib,
|
||||
Test dynamic load DM-lib. );
|
||||
#endif
|
||||
Reference in New Issue
Block a user